Skip to content
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ termcolor_output = "1.0.1"
ed25519-dalek = ">= 2.1.1"
http = "1.0.0"
walkdir = "2.5.0"
path-slash = "0.2.1"
toml_edit = "0.22.20"
toml = "0.8.19"
reqwest = { version = "0.12.7", default-features = false, features = ["rustls-tls"] }
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/soroban-test/tests/it/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn build_with_image_selects_package_by_manifest_path() {
.arg("build")
.arg("--image")
.arg("docker.io/stellar/stellar-cli:latest")
.arg(manifest_path_arg(&add_path()))
.arg(format!("--manifest-path={}", add_path()))
Comment thread
fnando marked this conversation as resolved.
.arg("--print-commands-only")
.assert()
.success()
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
serde-aux = { workspace = true }
hex = { workspace = true }
path-slash = { workspace = true }
num-bigint = "0.4"
# Pinned to match the version pulled in by soroban-rpc (jsonrpsee-core) so that
# downcasting RPC errors to `ErrorObjectOwned` resolves to the same type.
Expand Down
24 changes: 14 additions & 10 deletions cmd/soroban-cli/src/commands/contract/build/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::{Path, PathBuf};
use std::process::Stdio;

use cargo_metadata::MetadataCommand;
use path_slash::PathExt as _;
use semver::Version;

use crate::commands::{container::shared, global};
Expand Down Expand Up @@ -282,7 +283,7 @@ fn forwarded_build_args(
.strip_prefix(workspace_root)
.map(Path::to_path_buf)
.unwrap_or(abs);
args.push(format!("--manifest-path={}", rel.display()));
args.push(format!("--manifest-path={}", rel.to_slash_lossy()));
}
if cmd.profile != "release" {
args.push(format!("--profile={}", cmd.profile));
Expand Down Expand Up @@ -767,14 +768,17 @@ mod tests {
use super::*;
use crate::commands::contract::build::BuildArgs;

fn ws() -> &'static Path {
Path::new("/tmp/ws")
fn ws() -> PathBuf {
// Routed through `std::path::absolute` (as `forwarded_build_args` itself does
// for `manifest_path`) so both sides of the `strip_prefix` in
// `forwarded_build_args` agree on drive letter/prefix on Windows.
std::path::absolute(Path::new("/tmp/ws")).unwrap()
}

#[test]
fn forwarded_build_args_defaults() {
let cmd = Cmd::default();
let args = forwarded_build_args(&cmd, ws(), None, true, true, true);
let args = forwarded_build_args(&cmd, &ws(), None, true, true, true);
assert_eq!(args[..2], ["contract".to_string(), "build".to_string()]);
// Default optimize=true → bare `--optimize`; no `--locked` unless asked.
assert!(args.contains(&"--optimize".to_string()));
Expand All @@ -788,7 +792,7 @@ mod tests {
locked: true,
..Cmd::default()
};
let args = forwarded_build_args(&cmd, ws(), Some("contract-a"), true, true, true);
let args = forwarded_build_args(&cmd, &ws(), Some("contract-a"), true, true, true);
assert!(args.contains(&"--locked".to_string()));
assert!(args.contains(&"--package=contract-a".to_string()));
}
Expand All @@ -800,7 +804,7 @@ mod tests {
locked: true,
..Cmd::default()
};
let args = forwarded_build_args(&cmd, ws(), None, false, true, true);
let args = forwarded_build_args(&cmd, &ws(), None, false, true, true);
assert!(!args.iter().any(|a| a == "--locked"));
}

Expand All @@ -810,7 +814,7 @@ mod tests {
// though optimize defaults to true.
let cmd = Cmd::default();
assert!(cmd.build_args.optimize);
let args = forwarded_build_args(&cmd, ws(), None, true, false, false);
let args = forwarded_build_args(&cmd, &ws(), None, true, false, false);
assert!(!args.iter().any(|a| a.starts_with("--optimize")));
}

Expand All @@ -830,7 +834,7 @@ mod tests {
},
..Cmd::default()
};
let args = forwarded_build_args(&cmd, ws(), None, true, true, true);
let args = forwarded_build_args(&cmd, &ws(), None, true, true, true);
assert!(args.contains(&"--profile=dev".to_string()));
assert!(args.contains(&"--features=a,b".to_string()));
assert!(args.contains(&"--all-features".to_string()));
Expand All @@ -851,7 +855,7 @@ mod tests {
},
..Cmd::default()
};
let args = forwarded_build_args(&cmd, ws(), None, true, true, false);
let args = forwarded_build_args(&cmd, &ws(), None, true, true, false);
assert!(!args.iter().any(|a| a.starts_with("--optimize")));
}

Expand All @@ -861,7 +865,7 @@ mod tests {
manifest_path: Some(PathBuf::from("/tmp/ws/contracts/add/Cargo.toml")),
..Cmd::default()
};
let args = forwarded_build_args(&cmd, ws(), None, true, true, true);
let args = forwarded_build_args(&cmd, &ws(), None, true, true, true);
assert!(args.contains(&"--manifest-path=contracts/add/Cargo.toml".to_string()));
}

Expand Down
Loading