Skip to content
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

Allow specifying a path to xtask-downloader via env var #6214

Merged
merged 1 commit into from
Aug 2, 2024
Merged
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
4 changes: 4 additions & 0 deletions dev-tools/xtask/src/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl External {
self
}

pub fn trailing_args(&self) -> &[OsString] {
&self.args
}

pub fn exec_example(self, example_target: impl AsRef<OsStr>) -> Result<()> {
self.exec_common("--example", example_target.as_ref())
}
Expand Down
18 changes: 17 additions & 1 deletion dev-tools/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use anyhow::{Context, Result};
use cargo_metadata::Metadata;
use clap::{Parser, Subcommand};
use std::env;
use std::os::unix::process::CommandExt;
use std::process::Command;

mod check_features;
mod check_workspace_deps;
Expand Down Expand Up @@ -94,7 +97,20 @@ fn main() -> Result<()> {
Cmds::Clippy(args) => clippy::run_cmd(args),
Cmds::CheckFeatures(args) => check_features::run_cmd(args),
Cmds::CheckWorkspaceDeps => check_workspace_deps::run_cmd(),
Cmds::Download(external) => external.exec_bin("xtask-downloader"),
Cmds::Download(external) => {
// Allow specialized environments (e.g., testbed/a4x2) that can't
// `cargo run ...` to specify a path to `xtask-downloader` via an
// environment variable.
if let Ok(bin_path) = env::var("XTASK_DOWNLOADER_BIN") {
let error = Command::new(&bin_path)
.args(external.trailing_args())
.exec();
Err(error)
.with_context(|| format!("failed to exec `{bin_path}`"))
} else {
external.exec_bin("xtask-downloader")
}
}
Cmds::Openapi(external) => external.exec_bin("openapi-manager"),
#[cfg(target_os = "illumos")]
Cmds::Releng(external) => {
Expand Down
Loading