|
1 | 1 | use std::ffi::OsStr;
|
2 | 2 | use std::fs;
|
3 | 3 | use std::path::{Path, PathBuf};
|
4 |
| -use std::process::Command; |
| 4 | +use std::process::{Command, Stdio}; |
5 | 5 |
|
6 | 6 | use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
7 | 7 | use super::path::{Dirs, RelPath};
|
8 | 8 | use super::rustc_info::{get_default_sysroot, get_rustc_version};
|
9 | 9 | use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait};
|
10 | 10 |
|
11 |
| -pub(crate) fn prepare(dirs: &Dirs) { |
| 11 | +pub(crate) fn prepare(dirs: &Dirs, vendor: bool) { |
12 | 12 | RelPath::DOWNLOAD.ensure_fresh(dirs);
|
13 | 13 |
|
14 |
| - spawn_and_wait(super::build_backend::CG_CLIF.fetch("cargo", dirs)); |
| 14 | + if Path::new(".cargo/config.toml").exists() { |
| 15 | + std::fs::remove_file(".cargo/config.toml").unwrap(); |
| 16 | + } |
| 17 | + |
| 18 | + let mut cargo_workspaces = vec![super::build_backend::CG_CLIF.manifest_path(dirs)]; |
15 | 19 |
|
16 | 20 | prepare_sysroot(dirs);
|
17 |
| - spawn_and_wait(super::build_sysroot::STANDARD_LIBRARY.fetch("cargo", dirs)); |
18 |
| - spawn_and_wait(super::tests::LIBCORE_TESTS.fetch("cargo", dirs)); |
| 21 | + cargo_workspaces.push(super::build_sysroot::STANDARD_LIBRARY.manifest_path(dirs)); |
| 22 | + cargo_workspaces.push(super::tests::LIBCORE_TESTS.manifest_path(dirs)); |
19 | 23 |
|
20 | 24 | super::abi_cafe::ABI_CAFE_REPO.fetch(dirs);
|
21 |
| - spawn_and_wait(super::abi_cafe::ABI_CAFE.fetch("cargo", dirs)); |
| 25 | + cargo_workspaces.push(super::abi_cafe::ABI_CAFE.manifest_path(dirs)); |
22 | 26 | super::tests::RAND_REPO.fetch(dirs);
|
23 |
| - spawn_and_wait(super::tests::RAND.fetch("cargo", dirs)); |
| 27 | + cargo_workspaces.push(super::tests::RAND.manifest_path(dirs)); |
24 | 28 | super::tests::REGEX_REPO.fetch(dirs);
|
25 |
| - spawn_and_wait(super::tests::REGEX.fetch("cargo", dirs)); |
| 29 | + cargo_workspaces.push(super::tests::REGEX.manifest_path(dirs)); |
26 | 30 | super::tests::PORTABLE_SIMD_REPO.fetch(dirs);
|
27 |
| - spawn_and_wait(super::tests::PORTABLE_SIMD.fetch("cargo", dirs)); |
| 31 | + cargo_workspaces.push(super::tests::PORTABLE_SIMD.manifest_path(dirs)); |
28 | 32 | super::bench::SIMPLE_RAYTRACER_REPO.fetch(dirs);
|
29 |
| - spawn_and_wait(super::bench::SIMPLE_RAYTRACER.fetch("cargo", dirs)); |
| 33 | + cargo_workspaces.push(super::bench::SIMPLE_RAYTRACER.manifest_path(dirs)); |
| 34 | + |
| 35 | + if vendor { |
| 36 | + let mut vendor_cmd = Command::new("cargo"); |
| 37 | + |
| 38 | + vendor_cmd.arg("vendor").arg("--manifest-path").arg(&cargo_workspaces[0]); |
| 39 | + |
| 40 | + for workspace in cargo_workspaces.iter().skip(1) { |
| 41 | + vendor_cmd.arg("--sync").arg(workspace); |
| 42 | + } |
| 43 | + |
| 44 | + vendor_cmd.arg("download/vendor"); |
| 45 | + |
| 46 | + let vendor_output = vendor_cmd.stderr(Stdio::inherit()).output().unwrap(); |
| 47 | + assert!(vendor_output.status.success()); |
| 48 | + let replacement_config = String::from_utf8(vendor_output.stdout).unwrap(); |
| 49 | + |
| 50 | + std::fs::create_dir_all(".cargo").unwrap(); |
| 51 | + std::fs::write(".cargo/config.toml", replacement_config).unwrap(); |
| 52 | + } else { |
| 53 | + for workspace in &cargo_workspaces { |
| 54 | + let mut fetch_cmd = Command::new("cargo"); |
| 55 | + fetch_cmd.arg("fetch").arg("--manifest-path").arg(workspace); |
| 56 | + spawn_and_wait(fetch_cmd) |
| 57 | + } |
| 58 | + } |
30 | 59 | }
|
31 | 60 |
|
32 | 61 | fn prepare_sysroot(dirs: &Dirs) {
|
|
0 commit comments