Skip to content

Commit aa44186

Browse files
committed
Automatically vendor Cargo deps when building the source tarballs.
1 parent 42c1ea2 commit aa44186

File tree

26 files changed

+99
-34
lines changed

26 files changed

+99
-34
lines changed

appveyor.yml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ environment:
1717

1818
# MSVC cargotest
1919
- MSYS_BITS: 64
20-
NO_VENDOR: 1
2120
RUST_CHECK_TARGET: check-aux
2221
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc
2322

configure

+1
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ opt rustbuild 1 "use the rust and cargo based build system"
648648
opt codegen-tests 1 "run the src/test/codegen tests"
649649
opt option-checking 1 "complain about unrecognized options in this configure script"
650650
opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
651+
opt locked-deps 0 "force Cargo.lock to be up to date"
651652
opt vendor 0 "enable usage of vendored Rust crates"
652653
opt sanitizers 0 "build the sanitizer runtimes (asan, lsan, msan, tsan)"
653654

src/bootstrap/bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ def build_bootstrap(self):
294294
raise Exception("no cargo executable found at `%s`" % self.cargo())
295295
args = [self.cargo(), "build", "--manifest-path",
296296
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
297+
if self.use_locked_deps:
298+
args.append("--locked")
297299
if self.use_vendored_sources:
298300
args.append("--frozen")
299301
self.run(args, env)
@@ -440,6 +442,9 @@ def main():
440442
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
441443
'CFG_ENABLE_VENDOR' in rb.config_mk
442444

445+
rb.use_locked_deps = '\nlocked-deps = true' in rb.config_toml or \
446+
'CFG_ENABLE_LOCKED_DEPS' in rb.config_mk
447+
443448
if 'SUDO_USER' in os.environ and not rb.use_vendored_sources:
444449
if os.environ.get('USER') != os.environ['SUDO_USER']:
445450
rb.use_vendored_sources = True

src/bootstrap/check.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
108108
pub fn tidy(build: &Build, host: &str) {
109109
println!("tidy check ({})", host);
110110
let compiler = Compiler::new(0, host);
111-
build.run(build.tool_cmd(&compiler, "tidy")
112-
.arg(build.src.join("src")));
111+
let mut cmd = build.tool_cmd(&compiler, "tidy");
112+
cmd.arg(build.src.join("src"));
113+
if !build.config.vendor {
114+
cmd.arg("--no-vendor");
115+
}
116+
build.run(&mut cmd);
113117
}
114118

115119
fn testdir(build: &Build, host: &str) -> PathBuf {
@@ -643,6 +647,7 @@ pub fn distcheck(build: &Build) {
643647
build.run(&mut cmd);
644648
build.run(Command::new("./configure")
645649
.args(&build.config.configure_args)
650+
.arg("--enable-vendor")
646651
.current_dir(&dir));
647652
build.run(Command::new(build_helper::make(&build.config.build))
648653
.arg("check")

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct Config {
4444
pub submodules: bool,
4545
pub compiler_docs: bool,
4646
pub docs: bool,
47+
pub locked_deps: bool,
4748
pub vendor: bool,
4849
pub target_config: HashMap<String, Target>,
4950
pub full_bootstrap: bool,
@@ -145,6 +146,7 @@ struct Build {
145146
docs: Option<bool>,
146147
submodules: Option<bool>,
147148
gdb: Option<String>,
149+
locked_deps: Option<bool>,
148150
vendor: Option<bool>,
149151
nodejs: Option<String>,
150152
python: Option<String>,
@@ -294,6 +296,7 @@ impl Config {
294296
set(&mut config.compiler_docs, build.compiler_docs);
295297
set(&mut config.docs, build.docs);
296298
set(&mut config.submodules, build.submodules);
299+
set(&mut config.locked_deps, build.locked_deps);
297300
set(&mut config.vendor, build.vendor);
298301
set(&mut config.full_bootstrap, build.full_bootstrap);
299302
set(&mut config.extended, build.extended);
@@ -440,6 +443,7 @@ impl Config {
440443
("LOCAL_REBUILD", self.local_rebuild),
441444
("NINJA", self.ninja),
442445
("CODEGEN_TESTS", self.codegen_tests),
446+
("LOCKED_DEPS", self.locked_deps),
443447
("VENDOR", self.vendor),
444448
("FULL_BOOTSTRAP", self.full_bootstrap),
445449
("EXTENDED", self.extended),

src/bootstrap/config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
# Note that Python 2 is currently required.
109109
#python = "python2.7"
110110

111+
# Force Cargo to check that Cargo.lock describes the precise dependency
112+
# set that all the Cargo.toml files create, instead of updating it.
113+
#locked-deps = false
114+
111115
# Indicate whether the vendored sources are used for Rust dependencies or not
112116
#vendor = false
113117

src/bootstrap/dist.rs

+25-7
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
360360
t!(fs::remove_dir_all(&image));
361361
}
362362

363+
const CARGO_VENDOR_VERSION: &'static str = "0.1.4";
364+
363365
/// Creates the `rust-src` installer component and the plain source tarball
364366
pub fn rust_src(build: &Build) {
365367
println!("Dist src");
@@ -404,13 +406,6 @@ pub fn rust_src(build: &Build) {
404406
}
405407
}
406408

407-
// If we're inside the vendor directory then we need to preserve
408-
// everything as Cargo's vendoring support tracks all checksums and we
409-
// want to be sure we don't accidentally leave out a file.
410-
if spath.contains("vendor") {
411-
return true
412-
}
413-
414409
let excludes = [
415410
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
416411
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
@@ -433,6 +428,29 @@ pub fn rust_src(build: &Build) {
433428
copy(&build.src.join(item), &dst_src.join(item));
434429
}
435430

431+
// Get cargo-vendor installed, if it isn't already.
432+
let mut has_cargo_vendor = false;
433+
let mut cmd = Command::new(&build.cargo);
434+
for line in output(cmd.arg("install").arg("--list")).lines() {
435+
has_cargo_vendor |= line.starts_with("cargo-vendor ");
436+
}
437+
if !has_cargo_vendor {
438+
let mut cmd = Command::new(&build.cargo);
439+
cmd.arg("install")
440+
.arg("--force")
441+
.arg("--debug")
442+
.arg("--vers").arg(CARGO_VENDOR_VERSION)
443+
.arg("cargo-vendor")
444+
.env("RUSTC", &build.rustc);
445+
build.run(&mut cmd);
446+
}
447+
448+
// Vendor all Cargo dependencies
449+
let mut cmd = Command::new(&build.cargo);
450+
cmd.arg("vendor")
451+
.current_dir(&dst_src.join("src"));
452+
build.run(&mut cmd);
453+
436454
// Create source tarball in rust-installer format
437455
let mut cmd = Command::new("sh");
438456
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))

src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ impl Build {
528528
if self.config.rust_optimize && cmd != "bench" {
529529
cargo.arg("--release");
530530
}
531+
if self.config.locked_deps {
532+
cargo.arg("--locked");
533+
}
531534
if self.config.vendor || self.is_sudo {
532535
cargo.arg("--frozen");
533536
}

src/ci/docker/android/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ RUN dpkg --add-architecture i386 && \
1616
openjdk-9-jre \
1717
sudo \
1818
libstdc++6:i386 \
19-
xz-utils
19+
xz-utils \
20+
libssl-dev \
21+
pkg-config
2022

2123
WORKDIR /android/
2224
ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools

src/ci/docker/cross/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
gcc-sparc64-linux-gnu \
1818
libc6-dev-sparc64-cross \
1919
bzip2 \
20-
patch
20+
patch \
21+
libssl-dev \
22+
pkg-config
2123

2224
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2325
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-arm-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
sudo \
2424
texinfo \
2525
wget \
26-
xz-utils
26+
xz-utils \
27+
libssl-dev \
28+
pkg-config
2729

2830
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2931
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-armv7-aarch64-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
sudo \
2424
texinfo \
2525
wget \
26-
xz-utils
26+
xz-utils \
27+
libssl-dev \
28+
pkg-config
2729

2830
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2931
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-freebsd/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1212
sudo \
1313
bzip2 \
1414
xz-utils \
15-
wget
15+
wget \
16+
libssl-dev \
17+
pkg-config
1618

1719
COPY build-toolchain.sh /tmp/
1820
RUN /tmp/build-toolchain.sh x86_64

src/ci/docker/dist-mips-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
gdb \
1414
xz-utils \
1515
g++-mips-linux-gnu \
16-
g++-mipsel-linux-gnu
16+
g++-mipsel-linux-gnu \
17+
libssl-dev \
18+
pkg-config
1719

1820
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
1921
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-mips64-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313
gdb \
1414
xz-utils \
1515
g++-mips64-linux-gnuabi64 \
16-
g++-mips64el-linux-gnuabi64
16+
g++-mips64el-linux-gnuabi64 \
17+
libssl-dev \
18+
pkg-config
1719

1820
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
1921
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-powerpc-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
sudo \
2424
texinfo \
2525
wget \
26-
xz-utils
26+
xz-utils \
27+
libssl-dev \
28+
pkg-config
2729

2830
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2931
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-powerpc64-linux/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
sudo \
2424
texinfo \
2525
wget \
26-
xz-utils
26+
xz-utils \
27+
libssl-dev \
28+
pkg-config
2729

2830
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2931
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-s390x-linux-netbsd/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
sudo \
2424
texinfo \
2525
wget \
26-
xz-utils
26+
xz-utils \
27+
libssl-dev \
28+
pkg-config
2729

2830
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2931
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/dist-x86-linux/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ RUN yum upgrade -y && yum install -y \
1616
pkg-config \
1717
wget \
1818
autoconf \
19-
gettext
19+
gettext \
20+
libssl-dev
2021

2122
ENV PATH=/rustroot/bin:$PATH
2223
ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib

src/ci/docker/i686-gnu/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14-
xz-utils
14+
xz-utils \
15+
libssl-dev \
16+
pkg-config
1517

1618
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
1719
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/linux-tested-targets/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1212
xz-utils \
1313
sudo \
1414
gdb \
15-
patch
15+
patch \
16+
libssl-dev \
17+
pkg-config
1618

1719
WORKDIR /build/
1820
COPY musl-libunwind-patch.patch build-musl.sh /build/

src/ci/docker/x86_64-gnu-aux/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ ENTRYPOINT ["/usr/bin/dumb-init", "--"]
2525

2626
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu
2727
ENV RUST_CHECK_TARGET check-aux
28-
ENV NO_VENDOR 1

src/ci/docker/x86_64-gnu-distcheck/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14-
xz-utils
14+
xz-utils \
15+
libssl-dev \
16+
pkg-config
1517

1618
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
1719
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/docker/x86_64-gnu/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111
cmake \
1212
sudo \
1313
gdb \
14-
xz-utils
14+
xz-utils \
15+
libssl-dev \
16+
pkg-config
1517

1618
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
1719
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \

src/ci/run.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fi
2323
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
2424
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
2525
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
26+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
2627

2728
# If we're deploying artifacts then we set the release channel, otherwise if
2829
# we're not deploying then we want to be sure to enable all assertions becauase
@@ -47,13 +48,6 @@ else
4748
fi
4849
fi
4950

50-
# We want to enable usage of the `src/vendor` dir as much as possible, but not
51-
# all test suites have all their deps in there (just the main bootstrap) so we
52-
# have the ability to disable this flag
53-
if [ "$NO_VENDOR" = "" ]; then
54-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-vendor"
55-
fi
56-
5751
set -ex
5852

5953
$SRC/configure $RUST_CONFIGURE_ARGS

src/tools/tidy/src/main.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ fn main() {
4242
let path = env::args_os().skip(1).next().expect("need an argument");
4343
let path = PathBuf::from(path);
4444

45+
let args: Vec<String> = env::args().skip(1).collect();
46+
4547
let mut bad = false;
4648
bins::check(&path, &mut bad);
4749
style::check(&path, &mut bad);
4850
errors::check(&path, &mut bad);
4951
cargo::check(&path, &mut bad);
5052
features::check(&path, &mut bad);
5153
pal::check(&path, &mut bad);
52-
deps::check(&path, &mut bad);
54+
if !args.iter().any(|s| *s == "--no-vendor") {
55+
deps::check(&path, &mut bad);
56+
}
5357

5458
if bad {
5559
panic!("some tidy checks failed");

0 commit comments

Comments
 (0)