Skip to content

feat(cargo-codspeed): allow custom build profile selection #49

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

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