Skip to content

Commit

Permalink
bootstrap: test that src/tools/semverver builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jul 5, 2020
1 parent f726125 commit 0527be9
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 9 deletions.
47 changes: 46 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ dependencies = [
"cargo-test-support",
"clap",
"core-foundation",
"crates-io",
"crates-io 0.31.1",
"crossbeam-utils 0.7.2",
"crypto-hash",
"curl",
Expand Down Expand Up @@ -680,6 +680,21 @@ dependencies = [
"url 2.1.0",
]

[[package]]
name = "crates-io"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65949ecc100abd1df7d80740ee58afb599f2447c5011bbf5acb5a039a67607ca"
dependencies = [
"anyhow",
"curl",
"percent-encoding 2.1.0",
"serde",
"serde_derive",
"serde_json",
"url 2.1.0",
]

[[package]]
name = "crc32fast"
version = "1.1.2"
Expand Down Expand Up @@ -2376,6 +2391,18 @@ version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"

[[package]]
name = "quickcheck"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
dependencies = [
"env_logger 0.7.1",
"log",
"rand 0.7.3",
"rand_core 0.5.1",
]

[[package]]
name = "quine-mc_cluskey"
version = "0.2.4"
Expand Down Expand Up @@ -4170,6 +4197,24 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"

[[package]]
name = "semverver"
version = "0.1.46"
dependencies = [
"anyhow",
"cargo",
"crates-io 0.32.0",
"curl",
"env_logger 0.7.1",
"log",
"quickcheck",
"rand 0.7.3",
"rustc-workspace-hack",
"semver 0.9.0",
"serde",
"serde_json",
]

[[package]]
name = "serde"
version = "1.0.99"
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ members = [
"src/tools/rustdoc-themes",
"src/tools/unicode-table-generator",
"src/tools/expand-yaml-anchors",
"src/tools/semverver",
]
exclude = [
"build",
Expand Down Expand Up @@ -69,6 +70,9 @@ cargo = { path = "src/tools/cargo" }
# `rustfmt` executable are the same exact version).
rustfmt-nightly = { path = "src/tools/rustfmt" }

# Cargo again but from `crates.io` (semverver uses that instead of a git dependency).
cargo = { path = "src/tools/cargo" }

# See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
# here
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
Expand Down
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
# Installs chosen set of extended tools if `extended = true`. By default builds all.
# If chosen tool failed to build the installation fails. If `extended = false`, this
# option is ignored.
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"]
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src", "semverver"]

# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
#verbose = 0
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ impl<'a> Builder<'a> {
tool::Rustdoc,
tool::Clippy,
tool::CargoClippy,
tool::Semverver,
tool::SemverPublic,
tool::CargoSemver,
native::Llvm,
native::Sanitizers,
tool::Rustfmt,
Expand All @@ -380,7 +383,7 @@ impl<'a> Builder<'a> {
native::Lld
),
Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => {
describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy)
describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy, check::Semverver)
}
Kind::Test => describe!(
crate::toolstate::ToolStateCheck,
Expand Down Expand Up @@ -426,6 +429,7 @@ impl<'a> Builder<'a> {
test::RustdocJSNotStd,
test::RustdocTheme,
test::RustdocUi,
test::Semverver,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
Expand Down
10 changes: 6 additions & 4 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ macro_rules! tool_check_step {
}

tool_check_step!(Rustdoc, "src/tools/rustdoc", SourceType::InTree);
// Clippy is a hybrid. It is an external tool, but uses a git subtree instead
// of a submodule. Since the SourceType only drives the deny-warnings
// behavior, treat it as in-tree so that any new warnings in clippy will be
// rejected.
// Clippy and semverver are hybrids. They're external tools, but use git subtrees
// instead of submodules. Since the SourceType only drives the deny-warnings
// behavior, treat it as in-tree so that any new warnings will be rejected.
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
// FIXME(eddyb) use `InTree` here as per the comment above, when Cargo can build
// with deny-warnings + `-Wrust_2018_idioms` (which it can't today).
tool_check_step!(Semverver, "src/tools/semverver", SourceType::Submodule);

/// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target.
Expand Down
39 changes: 39 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,45 @@ impl Step for Clippy {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Semverver {
stage: u32,
host: Interned<String>,
}

impl Step for Semverver {
type Output = ();
const ONLY_HOSTS: bool = true;
const DEFAULT: bool = false;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/semverver")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Semverver { stage: run.builder.top_stage, host: run.target });
}

/// Runs `cargo test` for semverver.
fn run(self, builder: &Builder<'_>) {
let stage = self.stage;
let host = self.host;
let compiler = builder.compiler(stage, host);

builder
.ensure(tool::CargoSemver { compiler, target: self.host, extra_features: Vec::new() })
.expect("in-tree tool");
builder
.ensure(tool::Semverver { compiler, target: self.host, extra_features: Vec::new() })
.expect("in-tree tool");
builder
.ensure(tool::SemverPublic { compiler, target: self.host, extra_features: Vec::new() })
.expect("in-tree tool");

// FIXME(eddyb) actually run tests from `src/tools/semverver`.
}
}

fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
// Configure PATH to find the right rustc. NB. we have to use PATH
// and not RUSTC because the Cargo test suite has tests that will
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ pub fn prepare_tool_cargo(
|| path.ends_with("clippy")
|| path.ends_with("miri")
|| path.ends_with("rustfmt")
|| path.ends_with("semverver")
{
cargo.env("LIBZ_SYS_STATIC", "1");
features.push("rustc-workspace-hack/all-static".to_string());
Expand Down Expand Up @@ -604,6 +605,7 @@ macro_rules! tool_extended {
|tools| {
tools.iter().any(|tool| match tool.as_ref() {
"clippy" => $tool_name == "clippy-driver",
"semverver" => $tool_name == "rust-semverver",
x => $tool_name == x,
})
}),
Expand Down Expand Up @@ -659,6 +661,11 @@ tool_extended!((self, builder),
};
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, {};
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=false, {};
// FIXME(eddyb) use `in_tree=true` for semverver, when Cargo can build
// with deny-warnings + `-Wrust_2018_idioms` (which it can't today).
CargoSemver, semverver, "src/tools/semverver", "cargo-semver", stable=false, {};
Semverver, semverver, "src/tools/semverver", "rust-semverver", stable=false, {};
SemverPublic, semverver, "src/tools/semverver", "rust-semver-public", stable=false, {};
);

impl<'a> Builder<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ set -e
# debugging: print out the saved toolstates
cat /tmp/toolstate/toolstates.json
python3 "$X_PY" test check-tools
python3 "$X_PY" test src/tools/clippy
python3 "$X_PY" test src/tools/clippy src/tools/semverver
7 changes: 6 additions & 1 deletion src/tools/semverver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ name = "rust-semver-public"
path = "src/bin/rust_semver_public.rs"

[dependencies]
cargo = "0.44"
cargo = "0.47"
crates-io = "0.32"
curl = "0.4.21"
env_logger = "0.7"
Expand All @@ -40,3 +40,8 @@ serde_json = "1.0.34"

[dev-dependencies]
quickcheck = "0.9"

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
# for more information.
rustc-workspace-hack = "1.0.0"

0 comments on commit 0527be9

Please sign in to comment.