Auto merge of #53586 - eddyb:top-lock, r=alexcrichton

Move Cargo.{toml,lock} to the repository root directory.

This should give us back `src/` in errors, panics and debuginfo, for free.

r? @Mark-Simulacrum @alexcrichton cc @michaelwoerister
This commit is contained in:
bors 2018-11-22 15:54:10 +00:00
commit c08840d5c3
11 changed files with 70 additions and 52 deletions

View File

@ -494,16 +494,11 @@ the version in `Cargo.lock`, so the build can no longer continue.
To resolve this, we need to update `Cargo.lock`. Luckily, cargo provides a To resolve this, we need to update `Cargo.lock`. Luckily, cargo provides a
command to do this easily. command to do this easily.
First, go into the `src/` directory since that is where `Cargo.toml` is in
the rust repository. Then run, `cargo update -p rustfmt-nightly` to solve
the problem.
``` ```
$ cd src
$ cargo update -p rustfmt-nightly $ cargo update -p rustfmt-nightly
``` ```
This should change the version listed in `src/Cargo.lock` to the new version you updated This should change the version listed in `Cargo.lock` to the new version you updated
the submodule to. Running `./x.py build` should work now. the submodule to. Running `./x.py build` should work now.
## Writing Documentation ## Writing Documentation

View File

@ -1,31 +1,31 @@
[workspace] [workspace]
members = [ members = [
"bootstrap", "src/bootstrap",
"rustc", "src/rustc",
"libstd", "src/libstd",
"libtest", "src/libtest",
"librustc_codegen_llvm", "src/librustc_codegen_llvm",
"tools/cargotest", "src/tools/cargotest",
"tools/clippy", "src/tools/clippy",
"tools/compiletest", "src/tools/compiletest",
"tools/error_index_generator", "src/tools/error_index_generator",
"tools/linkchecker", "src/tools/linkchecker",
"tools/rustbook", "src/tools/rustbook",
"tools/unstable-book-gen", "src/tools/unstable-book-gen",
"tools/tidy", "src/tools/tidy",
"tools/build-manifest", "src/tools/build-manifest",
"tools/remote-test-client", "src/tools/remote-test-client",
"tools/remote-test-server", "src/tools/remote-test-server",
"tools/rust-installer", "src/tools/rust-installer",
"tools/cargo", "src/tools/cargo",
"tools/rustdoc", "src/tools/rustdoc",
"tools/rls", "src/tools/rls",
"tools/rustfmt", "src/tools/rustfmt",
"tools/miri", "src/tools/miri",
"tools/rustdoc-themes", "src/tools/rustdoc-themes",
] ]
exclude = [ exclude = [
"tools/rls/test_data", "src/tools/rls/test_data",
] ]
# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3 # Curiously, LLVM 7.0 will segfault if compiled with opt-level=3
@ -50,18 +50,18 @@ debug-assertions = false
# so we use a `[patch]` here to override the github repository with our local # so we use a `[patch]` here to override the github repository with our local
# vendored copy. # vendored copy.
[patch."https://github.com/rust-lang/cargo"] [patch."https://github.com/rust-lang/cargo"]
cargo = { path = "tools/cargo" } cargo = { path = "src/tools/cargo" }
[patch.crates-io] [patch.crates-io]
# Similar to Cargo above we want the RLS to use a vendored version of `rustfmt` # Similar to Cargo above we want the RLS to use a vendored version of `rustfmt`
# that we're shipping as well (to ensure that the rustfmt in RLS and the # that we're shipping as well (to ensure that the rustfmt in RLS and the
# `rustfmt` executable are the same exact version). # `rustfmt` executable are the same exact version).
rustfmt-nightly = { path = "tools/rustfmt" } rustfmt-nightly = { path = "src/tools/rustfmt" }
# See comments in `tools/rustc-workspace-hack/README.md` for what's going on # See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
# here # here
rustc-workspace-hack = { path = 'tools/rustc-workspace-hack' } rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
[patch."https://github.com/rust-lang-nursery/rust-clippy"] [patch."https://github.com/rust-lang-nursery/rust-clippy"]
clippy_lints = { path = "tools/clippy/clippy_lints" } clippy_lints = { path = "src/tools/clippy/clippy_lints" }
rustc_tools_util = { path = "tools/clippy/rustc_tools_util" } rustc_tools_util = { path = "src/tools/clippy/rustc_tools_util" }

View File

@ -801,7 +801,7 @@ def bootstrap(help_triggered):
registry = 'https://example.com' registry = 'https://example.com'
[source.vendored-sources] [source.vendored-sources]
directory = '{}/src/vendor' directory = '{}/vendor'
""".format(build.rust_root)) """.format(build.rust_root))
else: else:
if os.path.exists('.cargo'): if os.path.exists('.cargo'):

View File

@ -851,7 +851,7 @@ fn run(self, builder: &Builder) -> PathBuf {
t!(fs::create_dir_all(&dst_src)); t!(fs::create_dir_all(&dst_src));
let src_files = [ let src_files = [
"src/Cargo.lock", "Cargo.lock",
]; ];
// This is the reduced set of paths which will become the rust-src component // This is the reduced set of paths which will become the rust-src component
// (essentially libstd and all of its path dependencies) // (essentially libstd and all of its path dependencies)
@ -949,6 +949,8 @@ fn run(self, builder: &Builder) -> PathBuf {
"configure", "configure",
"x.py", "x.py",
"config.toml.example", "config.toml.example",
"Cargo.toml",
"Cargo.lock",
]; ];
let src_dirs = [ let src_dirs = [
"src", "src",
@ -992,7 +994,7 @@ fn run(self, builder: &Builder) -> PathBuf {
// Vendor all Cargo dependencies // Vendor all Cargo dependencies
let mut cmd = Command::new(&builder.initial_cargo); let mut cmd = Command::new(&builder.initial_cargo);
cmd.arg("vendor") cmd.arg("vendor")
.current_dir(&plain_dst_src.join("src")); .current_dir(&plain_dst_src);
builder.run(&mut cmd); builder.run(&mut cmd);
} }

View File

@ -1934,6 +1934,7 @@ fn run(self, builder: &Builder) {
.arg("generate-lockfile") .arg("generate-lockfile")
.arg("--manifest-path") .arg("--manifest-path")
.arg(&toml) .arg(&toml)
.env("__CARGO_TEST_ROOT", &dir)
.current_dir(&dir), .current_dir(&dir),
); );
} }

View File

@ -260,8 +260,13 @@ pub fn prepare_tool_cargo(
} }
macro_rules! tool { macro_rules! tool {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr ($(
$(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => { $name:ident, $path:expr, $tool_name:expr, $mode:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
$(,cargo_test_root = $cargo_test_root:expr)*
;
)+) => {
#[derive(Copy, PartialEq, Eq, Clone)] #[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool { pub enum Tool {
$( $(
@ -283,6 +288,15 @@ pub fn uses_llvm_tools(&self) -> bool {
$(Tool::$name => false $(|| $llvm)*,)+ $(Tool::$name => false $(|| $llvm)*,)+
} }
} }
/// Whether this tool requires may run Cargo for test crates,
/// which currently needs setting the environment variable
/// `__CARGO_TEST_ROOT` to separate it from the workspace.
pub fn needs_cargo_test_root(&self) -> bool {
match self {
$(Tool::$name => false $(|| $cargo_test_root)*,)+
}
}
} }
impl<'a> Builder<'a> { impl<'a> Builder<'a> {
@ -358,8 +372,9 @@ fn run(self, builder: &Builder) -> PathBuf {
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap; UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap;
Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap; Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap; Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap;
CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap; CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap, cargo_test_root = true;
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true; Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap,
llvm_tools = true, cargo_test_root = true;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap; BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap, RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
@ -678,6 +693,11 @@ fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
} }
} }
// Set `__CARGO_TEST_ROOT` to the build directory if needed.
if tool.needs_cargo_test_root() {
cmd.env("__CARGO_TEST_ROOT", &self.config.out);
}
add_lib_path(lib_paths, cmd); add_lib_path(lib_paths, cmd);
} }

View File

@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
3 | no 3 | no
| ^^ not found in this scope | ^^ not found in this scope
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 27)' panicked at 'couldn't compile the test', librustdoc/test.rs:323:13 thread '$DIR/failed-doctest-output.rs - OtherStruct (line 27)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:323:13
note: Run with `RUST_BACKTRACE=1` for a backtrace. note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- $DIR/failed-doctest-output.rs - SomeStruct (line 21) stdout ---- ---- $DIR/failed-doctest-output.rs - SomeStruct (line 21) stdout ----
@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 21)' panicked at 'test
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
note: Run with `RUST_BACKTRACE=1` for a backtrace. note: Run with `RUST_BACKTRACE=1` for a backtrace.
', librustdoc/test.rs:358:17 ', src/librustdoc/test.rs:358:17
failures: failures:

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//! Check license of third-party deps by inspecting src/vendor //! Check license of third-party deps by inspecting vendor
use std::collections::{BTreeSet, HashSet, HashMap}; use std::collections::{BTreeSet, HashSet, HashMap};
use std::fs::File; use std::fs::File;
@ -203,7 +203,7 @@ fn from(cv: CrateVersion<'a>) -> Crate<'a> {
/// Specifically, this checks that the license is correct. /// Specifically, this checks that the license is correct.
pub fn check(path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) {
// Check licences // Check licences
let path = path.join("vendor"); let path = path.join("../vendor");
assert!(path.exists(), "vendor directory missing"); assert!(path.exists(), "vendor directory missing");
let mut saw_dir = false; let mut saw_dir = false;
for dir in t!(path.read_dir()) { for dir in t!(path.read_dir()) {
@ -215,7 +215,7 @@ pub fn check(path: &Path, bad: &mut bool) {
dir.path() dir.path()
.to_str() .to_str()
.unwrap() .unwrap()
.contains(&format!("src/vendor/{}", exception)) .contains(&format!("vendor/{}", exception))
}); });
if is_exception { if is_exception {
continue; continue;
@ -304,7 +304,7 @@ fn get_deps(path: &Path, cargo: &Path) -> Resolve {
.arg("--format-version") .arg("--format-version")
.arg("1") .arg("1")
.arg("--manifest-path") .arg("--manifest-path")
.arg(path.join("Cargo.toml")) .arg(path.join("../Cargo.toml"))
.output() .output()
.expect("Unable to run `cargo metadata`") .expect("Unable to run `cargo metadata`")
.stdout; .stdout;

View File

@ -21,8 +21,8 @@
/// check for external package sources /// check for external package sources
pub fn check(path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) {
// Cargo.lock of rust: src/Cargo.lock // Cargo.lock of rust (tidy runs inside src/)
let path = path.join("Cargo.lock"); let path = path.join("../Cargo.lock");
// open and read the whole file // open and read the whole file
let mut cargo_lock = String::new(); let mut cargo_lock = String::new();

View File

@ -64,7 +64,6 @@ fn filter_dirs(path: &Path) -> bool {
"src/librustc_data_structures/owning_ref", "src/librustc_data_structures/owning_ref",
"src/compiler-rt", "src/compiler-rt",
"src/liblibc", "src/liblibc",
"src/vendor",
"src/rt/hoedown", "src/rt/hoedown",
"src/tools/cargo", "src/tools/cargo",
"src/tools/clang", "src/tools/clang",
@ -78,6 +77,7 @@ fn filter_dirs(path: &Path) -> bool {
"src/target", "src/target",
"src/stdsimd", "src/stdsimd",
"target", "target",
"vendor",
]; ];
skip.iter().any(|p| path.ends_with(p)) skip.iter().any(|p| path.ends_with(p))
} }