From 7c166f54b201dbefe27d4ab61dfdf640ac3a2722 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 22 Aug 2018 05:50:46 +0300 Subject: Move Cargo.{toml,lock} to the repository root directory. --- src/bootstrap/bootstrap.py | 2 +- src/bootstrap/dist.rs | 6 ++++-- src/bootstrap/test.rs | 1 + src/bootstrap/tool.rs | 28 ++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 7 deletions(-) (limited to 'src/bootstrap') diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index cd48e6aa4c4..d143dffb24b 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -801,7 +801,7 @@ def bootstrap(help_triggered): registry = 'https://example.com' [source.vendored-sources] - directory = '{}/src/vendor' + directory = '{}/vendor' """.format(build.rust_root)) else: if os.path.exists('.cargo'): diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 0aab64465fd..cd8d5642b25 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -851,7 +851,7 @@ impl Step for Src { t!(fs::create_dir_all(&dst_src)); let src_files = [ - "src/Cargo.lock", + "Cargo.lock", ]; // This is the reduced set of paths which will become the rust-src component // (essentially libstd and all of its path dependencies) @@ -949,6 +949,8 @@ impl Step for PlainSourceTarball { "configure", "x.py", "config.toml.example", + "Cargo.toml", + "Cargo.lock", ]; let src_dirs = [ "src", @@ -992,7 +994,7 @@ impl Step for PlainSourceTarball { // Vendor all Cargo dependencies let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("vendor") - .current_dir(&plain_dst_src.join("src")); + .current_dir(&plain_dst_src); builder.run(&mut cmd); } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e55773011df..c50e6a27033 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1934,6 +1934,7 @@ impl Step for Distcheck { .arg("generate-lockfile") .arg("--manifest-path") .arg(&toml) + .env("__CARGO_TEST_ROOT", &dir) .current_dir(&dir), ); } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d8e86644ee0..4acc739db57 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,8 +260,13 @@ pub fn prepare_tool_cargo( } 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)] pub enum Tool { $( @@ -283,6 +288,15 @@ macro_rules! tool { $(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> { @@ -358,8 +372,9 @@ tool!( UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen", Mode::ToolBootstrap; Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap; Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::ToolBootstrap; - CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap; - Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true; + CargoTest, "src/tools/cargotest", "cargotest", Mode::ToolBootstrap, cargo_test_root = true; + Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, + llvm_tools = true, cargo_test_root = true; BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap, @@ -678,6 +693,11 @@ impl<'a> Builder<'a> { } } + // 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); } -- cgit 1.4.1-3-g733a5