Skip to content

Commit

Permalink
Support custom profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
VladasZ authored and TimNN committed May 27, 2024
1 parent d91325e commit 866fa7a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.test-profile]
debug = true
inherits = "release"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target/
.idea
2 changes: 1 addition & 1 deletion Cargo.lock

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

5 changes: 5 additions & 0 deletions integration.bats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
}

Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ struct Invocation {
#[structopt(long)]
release: bool,

/// Build artifacts with custom profile
#[structopt(long)]
#[structopt(conflicts_with = "release")]
profile: Option<String>,

/// Require Cargo.lock and cache are up to date
#[structopt(long)]
frozen: bool,
Expand Down

0 comments on commit 866fa7a

Please sign in to comment.