Skip to content

Commit

Permalink
Rollup merge of rust-lang#39728 - eddyb:vendeur-tres-bien, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

Automate vendoring by invoking cargo-vendor when building src dist tarballs.

This avoids rust-lang#39633 bringing the `src/vendor` checked into git by rust-lang#37524, past 200,000 lines of code.

I believe the strategy of having rustbuild run `cargo vendor` during the `dist src` step is sound.

However, the only way to be sure `cargo-vendor` exists is to run `cargo install --force cargo-vendor`, which will recompile it every time (not passing `--force` means you can't tell between "already exists" and "build error"). ~~This is quite suboptimal and I'd like to somehow do it in each `Dockerfile` that would need it.~~

* [ ] Cache `CARGO_HOME` (i.e. `~/.cargo`) between CI runs
  * `bin/cargo-vendor` and the actual caches are the relevant bits
* [x] Do not build `cargo-vendor` all the time
  * ~~Maybe detect `~/.cargo/bin/cargo-vendor` already exists?~~
  * ~~Could also try to build it in a `Dockerfile` but do we have `cargo`/`rustc` there?~~
  * Final solution: check `cargo install --list` for a line starting with `cargo-vendor `

cc @rust-lang/tools
  • Loading branch information
frewsxcv authored Feb 13, 2017
2 parents 3b8a457 + aa44186 commit 02b29f2
Show file tree
Hide file tree
Showing 354 changed files with 99 additions and 39,930 deletions.
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ environment:

# MSVC cargotest
- MSYS_BITS: 64
NO_VENDOR: 1
RUST_CHECK_TARGET: check-aux
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc

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

Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ def build_bootstrap(self):
raise Exception("no cargo executable found at `%s`" % self.cargo())
args = [self.cargo(), "build", "--manifest-path",
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
if self.use_locked_deps:
args.append("--locked")
if self.use_vendored_sources:
args.append("--frozen")
self.run(args, env)
Expand Down Expand Up @@ -440,6 +442,9 @@ def main():
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
'CFG_ENABLE_VENDOR' in rb.config_mk

rb.use_locked_deps = '\nlocked-deps = true' in rb.config_toml or \
'CFG_ENABLE_LOCKED_DEPS' in rb.config_mk

if 'SUDO_USER' in os.environ and not rb.use_vendored_sources:
if os.environ.get('USER') != os.environ['SUDO_USER']:
rb.use_vendored_sources = True
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
pub fn tidy(build: &Build, host: &str) {
println!("tidy check ({})", host);
let compiler = Compiler::new(0, host);
build.run(build.tool_cmd(&compiler, "tidy")
.arg(build.src.join("src")));
let mut cmd = build.tool_cmd(&compiler, "tidy");
cmd.arg(build.src.join("src"));
if !build.config.vendor {
cmd.arg("--no-vendor");
}
build.run(&mut cmd);
}

fn testdir(build: &Build, host: &str) -> PathBuf {
Expand Down Expand Up @@ -643,6 +647,7 @@ pub fn distcheck(build: &Build) {
build.run(&mut cmd);
build.run(Command::new("./configure")
.args(&build.config.configure_args)
.arg("--enable-vendor")
.current_dir(&dir));
build.run(Command::new(build_helper::make(&build.config.build))
.arg("check")
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct Config {
pub submodules: bool,
pub compiler_docs: bool,
pub docs: bool,
pub locked_deps: bool,
pub vendor: bool,
pub target_config: HashMap<String, Target>,
pub full_bootstrap: bool,
Expand Down Expand Up @@ -145,6 +146,7 @@ struct Build {
docs: Option<bool>,
submodules: Option<bool>,
gdb: Option<String>,
locked_deps: Option<bool>,
vendor: Option<bool>,
nodejs: Option<String>,
python: Option<String>,
Expand Down Expand Up @@ -294,6 +296,7 @@ impl Config {
set(&mut config.compiler_docs, build.compiler_docs);
set(&mut config.docs, build.docs);
set(&mut config.submodules, build.submodules);
set(&mut config.locked_deps, build.locked_deps);
set(&mut config.vendor, build.vendor);
set(&mut config.full_bootstrap, build.full_bootstrap);
set(&mut config.extended, build.extended);
Expand Down Expand Up @@ -440,6 +443,7 @@ impl Config {
("LOCAL_REBUILD", self.local_rebuild),
("NINJA", self.ninja),
("CODEGEN_TESTS", self.codegen_tests),
("LOCKED_DEPS", self.locked_deps),
("VENDOR", self.vendor),
("FULL_BOOTSTRAP", self.full_bootstrap),
("EXTENDED", self.extended),
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
# Note that Python 2 is currently required.
#python = "python2.7"

# Force Cargo to check that Cargo.lock describes the precise dependency
# set that all the Cargo.toml files create, instead of updating it.
#locked-deps = false

# Indicate whether the vendored sources are used for Rust dependencies or not
#vendor = false

Expand Down
32 changes: 25 additions & 7 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
t!(fs::remove_dir_all(&image));
}

const CARGO_VENDOR_VERSION: &'static str = "0.1.4";

/// Creates the `rust-src` installer component and the plain source tarball
pub fn rust_src(build: &Build) {
println!("Dist src");
Expand Down Expand Up @@ -404,13 +406,6 @@ pub fn rust_src(build: &Build) {
}
}

// If we're inside the vendor directory then we need to preserve
// everything as Cargo's vendoring support tracks all checksums and we
// want to be sure we don't accidentally leave out a file.
if spath.contains("vendor") {
return true
}

let excludes = [
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
Expand All @@ -433,6 +428,29 @@ pub fn rust_src(build: &Build) {
copy(&build.src.join(item), &dst_src.join(item));
}

// Get cargo-vendor installed, if it isn't already.
let mut has_cargo_vendor = false;
let mut cmd = Command::new(&build.cargo);
for line in output(cmd.arg("install").arg("--list")).lines() {
has_cargo_vendor |= line.starts_with("cargo-vendor ");
}
if !has_cargo_vendor {
let mut cmd = Command::new(&build.cargo);
cmd.arg("install")
.arg("--force")
.arg("--debug")
.arg("--vers").arg(CARGO_VENDOR_VERSION)
.arg("cargo-vendor")
.env("RUSTC", &build.rustc);
build.run(&mut cmd);
}

// Vendor all Cargo dependencies
let mut cmd = Command::new(&build.cargo);
cmd.arg("vendor")
.current_dir(&dst_src.join("src"));
build.run(&mut cmd);

// Create source tarball in rust-installer format
let mut cmd = Command::new("sh");
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ impl Build {
if self.config.rust_optimize && cmd != "bench" {
cargo.arg("--release");
}
if self.config.locked_deps {
cargo.arg("--locked");
}
if self.config.vendor || self.is_sudo {
cargo.arg("--frozen");
}
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ RUN dpkg --add-architecture i386 && \
openjdk-9-jre \
sudo \
libstdc++6:i386 \
xz-utils
xz-utils \
libssl-dev \
pkg-config

WORKDIR /android/
ENV PATH=$PATH:/android/ndk-arm-9/bin:/android/sdk/tools:/android/sdk/platform-tools
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc-sparc64-linux-gnu \
libc6-dev-sparc64-cross \
bzip2 \
patch
patch \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-arm-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
texinfo \
wget \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-armv7-aarch64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
texinfo \
wget \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-freebsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
bzip2 \
xz-utils \
wget
wget \
libssl-dev \
pkg-config

COPY build-toolchain.sh /tmp/
RUN /tmp/build-toolchain.sh x86_64
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-mips-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
xz-utils \
g++-mips-linux-gnu \
g++-mipsel-linux-gnu
g++-mipsel-linux-gnu \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-mips64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gdb \
xz-utils \
g++-mips64-linux-gnuabi64 \
g++-mips64el-linux-gnuabi64
g++-mips64el-linux-gnuabi64 \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-powerpc-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
texinfo \
wget \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-powerpc64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
texinfo \
wget \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/dist-s390x-linux-netbsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
texinfo \
wget \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/dist-x86-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ RUN yum upgrade -y && yum install -y \
pkg-config \
wget \
autoconf \
gettext
gettext \
libssl-dev

ENV PATH=/rustroot/bin:$PATH
ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/i686-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/linux-tested-targets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xz-utils \
sudo \
gdb \
patch
patch \
libssl-dev \
pkg-config

WORKDIR /build/
COPY musl-libunwind-patch.patch build-musl.sh /build/
Expand Down
1 change: 0 additions & 1 deletion src/ci/docker/x86_64-gnu-aux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ ENTRYPOINT ["/usr/bin/dumb-init", "--"]

ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu
ENV RUST_CHECK_TARGET check-aux
ENV NO_VENDOR 1
4 changes: 3 additions & 1 deletion src/ci/docker/x86_64-gnu-distcheck/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/x86_64-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
xz-utils
xz-utils \
libssl-dev \
pkg-config

ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
Expand Down
8 changes: 1 addition & 7 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fi
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"

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

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

set -ex

$SRC/configure $RUST_CONFIGURE_ARGS
Expand Down
6 changes: 5 additions & 1 deletion src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ fn main() {
let path = env::args_os().skip(1).next().expect("need an argument");
let path = PathBuf::from(path);

let args: Vec<String> = env::args().skip(1).collect();

let mut bad = false;
bins::check(&path, &mut bad);
style::check(&path, &mut bad);
errors::check(&path, &mut bad);
cargo::check(&path, &mut bad);
features::check(&path, &mut bad);
pal::check(&path, &mut bad);
deps::check(&path, &mut bad);
if !args.iter().any(|s| *s == "--no-vendor") {
deps::check(&path, &mut bad);
}

if bad {
panic!("some tidy checks failed");
Expand Down
1 change: 0 additions & 1 deletion src/vendor/cmake/.cargo-checksum.json

This file was deleted.

Empty file removed src/vendor/cmake/.cargo-ok
Empty file.
2 changes: 0 additions & 2 deletions src/vendor/cmake/.gitignore

This file was deleted.

Loading

0 comments on commit 02b29f2

Please sign in to comment.