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

fix bincode versioning #105

Merged
merged 3 commits into from
Mar 9, 2025
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum-iterator = "0.8"
fixed-map = { version = "0.9", default-features = false }
regex = "1.11"
schema = { path = "tools/schema" }
semver = "1.0.26"
serde = "1.0"
serde_json = "1.0"
stylist = { version = "0.12", default-features = false }
Expand Down
16 changes: 8 additions & 8 deletions tools/bencher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {

let metadata_path = NamedTempFile::new().unwrap().into_temp_path();
let metadata = Command::new("cargo")
.args(["metadata"])
.args(["metadata", "--format-version", "1"])
.output()
.unwrap()
.stdout;
Expand All @@ -32,13 +32,13 @@ fn main() {

let mut bench_path = PathBuf::from("benchmark_results");
bench_path.push(format!(
"{}-{}-{}_{}-{}-{}",
now.year(),
now.month() as usize,
now.day(),
now.hour(),
now.minute(),
now.second(),
"{yr}-{mon:02}-{day:02}_{hr:02}-{min:02}-{sec:02}",
yr = now.year(),
mon = now.month() as usize,
day = now.day(),
hr = now.hour(),
min = now.minute(),
sec = now.second(),
));

let mut log_path = bench_path.clone();
Expand Down
4 changes: 2 additions & 2 deletions tools/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"features": {
"bincode1": {
"name": "bincode",
"version": "1.3.3"
"version": "1"
},
"bincode": {
"name": "bincode",
"version": "2.0.0-rc"
"version": "2"
Comment on lines +22 to +26
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are actually semver specifications now

}
}
}
1 change: 1 addition & 0 deletions tools/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ cargo_metadata.workspace = true
clap = { workspace = true, features = ["derive"] }
regex.workspace = true
schema.workspace = true
semver.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
29 changes: 25 additions & 4 deletions tools/parser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,41 @@ fn main() {

fn find_package_id(feature: &str, config: &Config, metadata: &Metadata) -> PackageId {
if let Some(package_id) = config.features.get(feature) {
package_id.clone()
PackageId {
name: package_id.name.clone(),
version: find_package_version(
&package_id.name,
Some(
package_id
.version
.parse()
.expect("invalid version spec in config"),
),
metadata,
),
}
} else {
PackageId {
name: feature.to_string(),
version: find_package_version(feature, metadata),
version: find_package_version(feature, None, metadata),
}
}
}

fn find_package_version(name: &str, metadata: &Metadata) -> String {
fn find_package_version(
name: &str,
version_req: Option<semver::VersionReq>,
metadata: &Metadata,
) -> String {
metadata
.packages
.iter()
.find(|pkg| pkg.name == name)
.find(|pkg| {
pkg.name == name
&& version_req
.as_ref()
.map_or(true, |req| req.matches(&pkg.version))
})
.unwrap()
.version
.to_string()
Expand Down
Loading