Skip to content

Commit 65aab70

Browse files
committed
feat(cargo-codspeed): allow custom build profile selection
1 parent f91abc7 commit 65aab70

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

crates/cargo-codspeed/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ Options:
5151
## Advanced Usage
5252

5353
The `vendored-openssl` feature can be used to statically link with openssl with `cargo install cargo-codspeed --features vendored-openssl`.
54+
55+
## Development
56+
57+
### Troubleshooting
58+
59+
- Build error on MacOS: `ld: library 'git2' not found`
60+
61+
```
62+
brew install libgit2
63+
```

crates/cargo-codspeed/src/app.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ enum Commands {
4343
/// Space or comma separated list of features to activate
4444
#[arg(short = 'F', long)]
4545
features: Option<String>,
46+
47+
/// Build the benchmarks with the specified profile
48+
#[arg(long, default_value = "release")]
49+
profile: String,
4650
},
4751
/// Run the previously built benchmarks
4852
Run {
@@ -72,6 +76,7 @@ pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
7276
benches,
7377
package_selection,
7478
features,
79+
profile,
7580
} => {
7681
let features = features.map(|f| {
7782
f.split(|c| c == ' ' || c == ',')
@@ -83,7 +88,7 @@ pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
8388
package_selection.exclude,
8489
package_selection.package,
8590
)?;
86-
build_benches(&ws, benches, packages, features)
91+
build_benches(&ws, benches, packages, features, profile)
8792
}
8893
Commands::Run {
8994
benches,

crates/cargo-codspeed/src/build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use cargo::{
1515
fn get_compile_options(
1616
config: &Config,
1717
features: &Option<Vec<String>>,
18+
profile: &str,
1819
package: &Package,
1920
benches: Vec<&str>,
2021
is_root_package: bool,
@@ -33,7 +34,7 @@ fn get_compile_options(
3334
.collect::<BTreeSet<FeatureValue>>(),
3435
);
3536
}
36-
compile_opts.build_config.requested_profile = "release".into();
37+
compile_opts.build_config.requested_profile = profile.into();
3738
compile_opts.filter = CompileFilter::from_raw_arguments(
3839
false,
3940
vec![],
@@ -59,6 +60,7 @@ pub fn build_benches(
5960
selected_benches: Option<Vec<String>>,
6061
packages: Packages,
6162
features: Option<Vec<String>>,
63+
profile: String,
6264
) -> Result<()> {
6365
let packages_to_build = packages.get_packages(ws)?;
6466
let mut benches_to_build = vec![];
@@ -126,6 +128,7 @@ pub fn build_benches(
126128
let compile_opts = get_compile_options(
127129
config,
128130
&features,
131+
&profile,
129132
bench.package,
130133
benches_names,
131134
is_root_package,

0 commit comments

Comments
 (0)