Skip to content

xtask: Fix channel of cargo operations #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion xtask/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ impl Cargo {
pub fn command(&self) -> Result<Command> {
let mut cmd = Command::new("cargo");

// Cargo automatically sets some env vars that can prevent the
// channel arg (e.g. "+nightly") from working. Unset them in the
// child's environment.
cmd.env_remove("RUSTC");
cmd.env_remove("RUSTDOC");

if let Some(toolchain) = &self.toolchain {
cmd.arg(&format!("+{}", toolchain));
}
Expand Down Expand Up @@ -206,7 +212,7 @@ mod tests {
};
assert_eq!(
command_to_string(&cargo.command().unwrap()),
"RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open"
"RUSTC= RUSTDOC= RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open"
);
}
}
11 changes: 10 additions & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,28 @@ fn test_latest_release() -> Result<()> {
// it explicit that it matches the command in `BUILDING.md`.
let mut build_cmd = Command::new("cargo");
build_cmd
.env_remove("RUSTC")
.args(&["+nightly", "build", "--target", "x86_64-unknown-uefi"])
.current_dir(tmp_dir.join("template"));

// Check that the command is indeed in BUILDING.md, then verify the
// build succeeds.
let building_md = include_str!("../../BUILDING.md");
assert!(building_md.contains(&command_to_string(&build_cmd)));
let cmd_str = command_to_string(&build_cmd).replace("RUSTC= ", "");
assert!(building_md.contains(&cmd_str));
run_cmd(build_cmd)
}

fn main() -> Result<()> {
let opt = Opt::parse();

// TODO:
println!("=======VARS=======");
for (k, v) in std::env::vars() {
println!("{}={}", k, v);
}
println!("=======VARS=======");

match &opt.action {
Action::Build(build_opt) => build(build_opt),
Action::Clippy(clippy_opt) => clippy(clippy_opt),
Expand Down