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

Support custom profiles #64

Merged
merged 1 commit into from
May 27, 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
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
Loading