diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..85d20cc --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[profile.test-profile] +debug = true +inherits = "release" diff --git a/.gitignore b/.gitignore index b83d222..bef0727 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target/ +.idea diff --git a/Cargo.lock b/Cargo.lock index 1e30d4c..b62c9ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,7 +74,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cargo-lipo" -version = "3.2.0" +version = "3.3.0" dependencies = [ "cargo_metadata", "clap", diff --git a/integration.bats.sh b/integration.bats.sh index da57788..9f12861 100755 --- a/integration.bats.sh +++ b/integration.bats.sh @@ -72,6 +72,11 @@ setup() { check_archs arm64,x86_64 simple/target/universal/release/libsimple.a } +@test "build simple with --profile=test-profile" { + ${CARGO_LIPO} --profile=test-profile --manifest-path simple/Cargo.toml + check_archs arm64,x86_64 simple/target/universal/test-profile/libsimple.a +} + @test "build simple with --targets" { ${CARGO_LIPO} --targets aarch64-apple-ios --manifest-path simple/Cargo.toml check_archs arm64 simple/target/universal/debug/libsimple.a diff --git a/src/cargo.rs b/src/cargo.rs index 382ca23..697f66a 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -18,7 +18,9 @@ impl<'a> Cargo<'a> { } pub(crate) fn profile(&self) -> &str { - if self.invocation.release { + if let Some(profile) = &self.invocation.profile { + profile + } else if self.invocation.release { "release" } else { "debug" @@ -59,7 +61,9 @@ impl<'a> Cargo<'a> { cmd.arg("-p").arg(name).arg("--target").arg(target); - if self.invocation.release { + if let Some(profile) = &self.invocation.profile { + cmd.arg(format!("--profile={profile}")); + } else if self.invocation.release { cmd.arg("--release"); } diff --git a/src/main.rs b/src/main.rs index 2462084..6cf0003 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,11 @@ struct Invocation { #[structopt(long)] release: bool, + /// Build artifacts with custom profile + #[structopt(long)] + #[structopt(conflicts_with = "release")] + profile: Option, + /// Require Cargo.lock and cache are up to date #[structopt(long)] frozen: bool,