Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 6c0bbf5

Browse files
committed
Auto merge of #1299 - Xanewok:monorepo, r=Xanewok
Set up a monorepo by pulling the external rls-* packages Set up a monorepo, pulling every `rls-*` package into the repository. This is done to facilitate and centralize development and also to improve the discoverability of those packages. An important thing to note is that this isn't and can't be a Cargo workspace, because it's used as a submodule inside a Rust repository, which is a Cargo workspace itself (and we don't support nested configurations). Because of that, I also didn't use the `[patch.crates-io]` to point to the local repositories, since it might be counter-intuitive, as the patches in a Cargo workspace member manifest is not taken into account and only patch sections from the root manifest are. Also got rid of Cargo.locks for the dependencies, since these are meant to be used as a library and so the lockfile is only respected for the primarily compiled package anyway. Didn't move build.rs inside `rls/` since it seems there is a Cargo bug where it expects the build script to be at the top level, rebuilding everything on subsequent runs (despite specifying the `build = "rls/build.rs` key in Cargo.toml)? r? @nrc I'll move related issues here, after this is merged.
2 parents 5ef6dd3 + 04de213 commit 6c0bbf5

File tree

115 files changed

+6034
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+6034
-24
lines changed

.travis.yml

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
language: rust
22
dist: trusty
33
sudo: false
4-
branches:
5-
except:
6-
- staging.tmp
7-
- trying.tmp
84
cache:
95
cargo: false
106
os:
11-
- linux
12-
- osx
13-
- windows
7+
- linux
8+
- osx
9+
- windows
1410
rust:
15-
- nightly
16-
install: |
17-
# Required for Racer autoconfiguration
18-
rustup component add rust-src
19-
rustup component add rust-analysis
11+
- nightly
12+
install:
13+
# Required for Racer autoconfiguration
14+
- rustup component add rust-src
15+
- rustup component add rust-analysis
2016
script:
21-
- cargo build -v
22-
- cargo test -v
23-
- cargo test test_tooltip_std -- --ignored
17+
- cargo build -v
18+
- cargo test -v
19+
- cargo test test_tooltip_std -- --ignored
20+
# Since the rls-* subcrates use crates.io-based dependencies of themselves it
21+
# makes sense to test them in isolation rather than just RLS itself
22+
- (cd rls-analysis && cargo test -v)
23+
- (cd rls-blacklist && cargo test -v)
24+
- (cd rls-data && cargo test -v)
25+
- (cd rls-rustc && cargo test -v)
26+
- (cd rls-span && cargo test -v)
27+
- (cd rls-vfs && cargo test -v)
2428

2529
env:
2630
global:
27-
- RUST_BACKTRACE=1
28-
- RLS_TEST_WAIT_FOR_AGES=1
29-
- CARGO_INCREMENTAL=0
31+
- RUST_BACKTRACE=1
32+
- RLS_TEST_WAIT_FOR_AGES=1
33+
- CARGO_INCREMENTAL=0

Cargo.toml

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ build = "build.rs"
1313
[lib]
1414
name = "rls"
1515
doctest = false
16+
path = "rls/src/lib.rs"
1617

1718
[[bin]]
1819
name = "rls"
1920
test = false
21+
path = "rls/src/main.rs"
2022

2123
[dependencies]
24+
rls-analysis = "0.16.12"
25+
rls-blacklist = "0.1.3"
26+
rls-data = { version = "0.18.2", features = ["serialize-serde", "serialize-rustc"] }
27+
rls-rustc = "0.5.0"
28+
rls-span = { version = "0.4", features = ["serialize-serde"] }
29+
rls-vfs = "0.7"
30+
2231
cargo = { git = "https://github.com/rust-lang/cargo", rev = "4e74e2fc0908524d17735c768067117d3e84ee9c" }
2332
cargo_metadata = "0.7"
2433
clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "5725726345039830677a0aeb8389ae78ce01ff97", optional = true }
@@ -34,12 +43,6 @@ num_cpus = "1"
3443
racer = { version = "=2.1.18", default-features = false }
3544
rand = "0.6"
3645
rayon = "1"
37-
rls-analysis = "0.16.12"
38-
rls-blacklist = "0.1.3"
39-
rls-data = { version = "0.18.2", features = ["serialize-serde", "serialize-rustc"] }
40-
rls-rustc = "0.5.0"
41-
rls-span = { version = "0.4", features = ["serialize-serde"] }
42-
rls-vfs = "0.7"
4346
rustc_tools_util = "0.1.1"
4447
rustfmt-nightly = "1.0.2"
4548
rustc-serialize = "0.3"

rls-analysis/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
3+
Cargo.lock

rls-analysis/Cargo.toml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "rls-analysis"
3+
version = "0.16.12"
4+
authors = ["Nick Cameron <ncameron@mozilla.com>"]
5+
description = "Library for processing rustc's save-analysis data for the RLS"
6+
license = "Apache-2.0/MIT"
7+
repository = "https://github.com/rust-lang/rls"
8+
categories = ["development-tools"]
9+
exclude = [
10+
"test_data/*",
11+
]
12+
13+
[dependencies]
14+
rustc-serialize = "0.3"
15+
log = "0.4"
16+
rls-data = "= 0.18.2"
17+
rls-span = "0.4"
18+
derive-new = "0.5"
19+
fst = { version = "0.3", default-features = false }
20+
itertools = "0.7.3"
21+
json = "0.11.13"
22+
23+
[dev-dependencies]
24+
lazy_static = "1"
25+
env_logger = "0.5"

rls-analysis/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[![Build Status](https://travis-ci.org/nrc/rls-analysis.svg?branch=master)](https://travis-ci.org/nrc/rls-analysis)
2+
3+
# rls-analysis
4+
5+
Library for processing rustc's save-analysis data for the RLS.
6+
7+
[API Documentation](https://docs.rs/rls-analysis/)

rls-analysis/benches/std_api_crate.rs

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright 2017 The RLS Project Developers.
2+
//
3+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6+
// option. This file may not be copied, modified, or distributed
7+
// except according to those terms.
8+
9+
#![feature(test)]
10+
11+
extern crate rls_analysis;
12+
#[macro_use]
13+
extern crate derive_new;
14+
#[macro_use]
15+
extern crate lazy_static;
16+
extern crate test;
17+
use test::Bencher;
18+
19+
use std::path::{Path, PathBuf};
20+
use std::sync::RwLock;
21+
22+
use rls_analysis::{AnalysisHost, AnalysisLoader, SearchDirectory};
23+
24+
#[derive(Clone, new)]
25+
struct TestAnalysisLoader {
26+
path: PathBuf,
27+
}
28+
29+
impl AnalysisLoader for TestAnalysisLoader {
30+
fn needs_hard_reload(&self, _path_prefix: &Path) -> bool {
31+
true
32+
}
33+
34+
fn fresh_host(&self) -> AnalysisHost<Self> {
35+
AnalysisHost::new_with_loader(self.clone())
36+
}
37+
38+
fn set_path_prefix(&mut self, _path_prefix: &Path) {}
39+
40+
fn abs_path_prefix(&self) -> Option<PathBuf> {
41+
panic!();
42+
}
43+
44+
fn search_directories(&self) -> Vec<SearchDirectory> {
45+
vec![SearchDirectory::new(self.path.clone(), None)]
46+
}
47+
}
48+
49+
lazy_static! {
50+
static ref STDLIB_FILE_PATH: PathBuf = PathBuf::from("/checkout/src/libstd/lib.rs");
51+
static ref STDLIB_DATA_PATH: PathBuf = PathBuf::from("test_data/rust-analysis");
52+
53+
static ref HOST: RwLock<AnalysisHost<TestAnalysisLoader>> = {
54+
let host = AnalysisHost::new_with_loader(TestAnalysisLoader::new(
55+
STDLIB_DATA_PATH.clone(),
56+
));
57+
host.reload(&STDLIB_DATA_PATH, &STDLIB_DATA_PATH).unwrap();
58+
RwLock::new(host)
59+
};
60+
}
61+
62+
#[bench]
63+
fn search_for_id(b: &mut Bencher) {
64+
let host = HOST.read().unwrap();
65+
66+
b.iter(|| {
67+
let _ = host.search_for_id("no_std");
68+
});
69+
}
70+
71+
#[bench]
72+
fn search(b: &mut Bencher) {
73+
let host = HOST.read().unwrap();
74+
b.iter(|| {
75+
let _ = host.search("some_inexistent_symbol");
76+
77+
})
78+
}
79+
80+
#[bench]
81+
fn symbols(b: &mut Bencher) {
82+
let host = HOST.read().unwrap();
83+
b.iter(|| {
84+
let _ = host.symbols(&STDLIB_FILE_PATH);
85+
})
86+
}
87+
88+
#[bench]
89+
fn reload(b: &mut Bencher) {
90+
let host = HOST.write().unwrap();
91+
b.iter(|| {
92+
host.reload(&STDLIB_DATA_PATH, &STDLIB_DATA_PATH).unwrap();
93+
})
94+
}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
extern crate rls_analysis;
2+
extern crate env_logger;
3+
4+
use rls_analysis::{AnalysisHost, AnalysisLoader, SearchDirectory};
5+
use std::path::{Path, PathBuf};
6+
use std::env;
7+
8+
#[derive(Clone)]
9+
pub struct Loader {
10+
deps_dir: PathBuf,
11+
}
12+
13+
impl Loader {
14+
pub fn new(deps_dir: PathBuf) -> Self {
15+
Self { deps_dir }
16+
}
17+
}
18+
19+
impl AnalysisLoader for Loader {
20+
fn needs_hard_reload(&self, _: &Path) -> bool {
21+
true
22+
}
23+
24+
fn fresh_host(&self) -> AnalysisHost<Self> {
25+
AnalysisHost::new_with_loader(self.clone())
26+
}
27+
28+
fn set_path_prefix(&mut self, _: &Path) {}
29+
30+
fn abs_path_prefix(&self) -> Option<PathBuf> {
31+
None
32+
}
33+
fn search_directories(&self) -> Vec<SearchDirectory> {
34+
vec![SearchDirectory {
35+
path: self.deps_dir.clone(),
36+
prefix_rewrite: None,
37+
}]
38+
}
39+
}
40+
41+
fn main() {
42+
env_logger::init();
43+
if env::args().len() < 2 {
44+
println!("Usage: print-crate-id <save-analysis-dir>");
45+
std::process::exit(1);
46+
}
47+
let loader = Loader::new(PathBuf::from(env::args().nth(1).unwrap()));
48+
let crates = rls_analysis::read_analysis_from_files(&loader, Default::default(), &[]);
49+
50+
for krate in &crates {
51+
println!("Crate {:?} data version {:?}", krate.id, krate.analysis.version);
52+
}
53+
}

0 commit comments

Comments
 (0)