Skip to content
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
8 changes: 8 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ pub(crate) struct Cli {
#[arg(short = 'j', long)]
pub jobs: Option<u32>,

/// Cargo profile to use for building
#[arg(long, default_value = "release")]
pub cargo_profile: String,

/// Cargo features to enable for building
#[arg(long)]
pub cargo_features: Option<String>,

/// Install binaries for a specific network (e.g., tempo)
#[arg(short = 'n', long)]
pub network: Option<Network>,
Expand Down
28 changes: 24 additions & 4 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,28 @@ async fn install_from_local(config: &Config, local_path: &Path, args: &Cli) -> R
say!("installing from {}", local_path.display());

let mut cmd = tokio::process::Command::new("cargo");
cmd.arg("build").arg("--bins").arg("--release").current_dir(local_path);
cmd.arg("build")
.arg("--bins")
.arg("--profile")
.arg(&args.cargo_profile)
.current_dir(local_path);
cmd.env("RUSTFLAGS", rustflags());

if let Some(jobs) = args.jobs {
cmd.arg("--jobs").arg(jobs.to_string());
}
if let Some(ref features) = args.cargo_features {
cmd.arg("--features").arg(features);
}

let status = cmd.status().await.wrap_err("failed to run cargo build")?;
if !status.success() {
bail!("cargo build failed");
}

let target_dir = profile_target_dir(&args.cargo_profile);
for bin in config.network.bins {
let src = local_path.join("target/release").join(bin_name(bin));
let src = local_path.join("target").join(target_dir).join(bin_name(bin));
let dest = config.bin_path(bin);

if dest.exists() {
Expand All @@ -104,6 +112,10 @@ async fn install_from_local(config: &Config, local_path: &Path, args: &Cli) -> R
Ok(())
}

fn profile_target_dir(profile: &str) -> &str {
if profile == "dev" { "debug" } else { profile }
}

async fn install_from_source(config: &Config, repo: &str, args: &Cli) -> Result<()> {
let branch = if let Some(pr) = args.pr {
format!("refs/pull/{pr}/head")
Expand Down Expand Up @@ -171,12 +183,19 @@ async fn install_from_source(config: &Config, repo: &str, args: &Cli) -> Result<
say!("installing version {version}");

let mut cmd = tokio::process::Command::new("cargo");
cmd.arg("build").arg("--bins").arg("--release").current_dir(&repo_path);
cmd.arg("build")
.arg("--bins")
.arg("--profile")
.arg(&args.cargo_profile)
.current_dir(&repo_path);
cmd.env("RUSTFLAGS", rustflags());

if let Some(jobs) = args.jobs {
cmd.arg("--jobs").arg(jobs.to_string());
}
if let Some(ref features) = args.cargo_features {
cmd.arg("--features").arg(features);
}

let status = cmd.status().await.wrap_err("failed to run cargo build")?;
if !status.success() {
Expand All @@ -186,8 +205,9 @@ async fn install_from_source(config: &Config, repo: &str, args: &Cli) -> Result<
let version_dir = config.version_dir(repo, &version);
fs::create_dir_all(&version_dir)?;

let target_dir = profile_target_dir(&args.cargo_profile);
for bin in config.network.bins {
let src = repo_path.join("target/release").join(bin_name(bin));
let src = repo_path.join("target").join(target_dir).join(bin_name(bin));
if src.exists() {
fs::rename(&src, version_dir.join(bin_name(bin)))?;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ Options:
-j, --jobs <JOBS>
Number of CPUs to use for building (default: all)

--cargo-profile <CARGO_PROFILE>
Cargo profile to use for building

[default: release]

--cargo-features <CARGO_FEATURES>
Cargo features to enable for building

-n, --network <NETWORK>
Install binaries for a specific network (e.g., tempo)

Expand Down