Skip to content

Commit

Permalink
feat(cargo-codspeed): allow custom build profile selection
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Sep 4, 2024
1 parent f91abc7 commit 65aab70
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions crates/cargo-codspeed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ Options:
## Advanced Usage

The `vendored-openssl` feature can be used to statically link with openssl with `cargo install cargo-codspeed --features vendored-openssl`.

## Development

### Troubleshooting

- Build error on MacOS: `ld: library 'git2' not found`

```
brew install libgit2
```
7 changes: 6 additions & 1 deletion crates/cargo-codspeed/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ enum Commands {
/// Space or comma separated list of features to activate
#[arg(short = 'F', long)]
features: Option<String>,

/// Build the benchmarks with the specified profile
#[arg(long, default_value = "release")]
profile: String,
},
/// Run the previously built benchmarks
Run {
Expand Down Expand Up @@ -72,6 +76,7 @@ pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
benches,
package_selection,
features,
profile,
} => {
let features = features.map(|f| {
f.split(|c| c == ' ' || c == ',')
Expand All @@ -83,7 +88,7 @@ pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
package_selection.exclude,
package_selection.package,
)?;
build_benches(&ws, benches, packages, features)
build_benches(&ws, benches, packages, features, profile)
}
Commands::Run {
benches,
Expand Down
5 changes: 4 additions & 1 deletion crates/cargo-codspeed/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use cargo::{
fn get_compile_options(
config: &Config,
features: &Option<Vec<String>>,
profile: &str,
package: &Package,
benches: Vec<&str>,
is_root_package: bool,
Expand All @@ -33,7 +34,7 @@ fn get_compile_options(
.collect::<BTreeSet<FeatureValue>>(),
);
}
compile_opts.build_config.requested_profile = "release".into();
compile_opts.build_config.requested_profile = profile.into();
compile_opts.filter = CompileFilter::from_raw_arguments(
false,
vec![],
Expand All @@ -59,6 +60,7 @@ pub fn build_benches(
selected_benches: Option<Vec<String>>,
packages: Packages,
features: Option<Vec<String>>,
profile: String,
) -> Result<()> {
let packages_to_build = packages.get_packages(ws)?;
let mut benches_to_build = vec![];
Expand Down Expand Up @@ -126,6 +128,7 @@ pub fn build_benches(
let compile_opts = get_compile_options(
config,
&features,
&profile,
bench.package,
benches_names,
is_root_package,
Expand Down

0 comments on commit 65aab70

Please sign in to comment.