Skip to content

Commit 34656f7

Browse files
committed
feat: optionally ignore prerelease info from tss version, could be git-dirty, the rest of the version still has to match
1 parent e86099b commit 34656f7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tss-esapi/build.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright 2021 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3-
use semver::{Version, VersionReq};
3+
use semver::{Version, VersionReq, Prerelease};
44

55
const TPM2_TSS_MINIMUM_VERSION: Version = Version::new(4, 1, 3);
6+
const TPM2_TSS_VERSION_IGNORE_PRERELEASE: &str = "TPM2_TSS_VERSION_IGNORE_PRERELEASE";
67

78
fn main() {
89
println!("cargo:rustc-check-cfg=cfg(hierarchy_is_esys_tr)");
@@ -20,15 +21,22 @@ fn main() {
2021
.expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string");
2122

2223
Version::parse(&tss_version_string)
23-
.expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version")
24+
.map(|mut v| {
25+
if std::env::var(TPM2_TSS_VERSION_IGNORE_PRERELEASE).is_ok() {
26+
v.pre = Prerelease::EMPTY;
27+
}
28+
v
29+
})
30+
.expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable {tss_version_string} as a semver version")
2431
};
2532

2633
let supported_tss_version =
2734
VersionReq::parse("<5.0.0, >=2.3.3").expect("Failed to parse supported TSS version");
2835

36+
//eprintln!("tss version: {} / {:?}", supported_tss_version, tss_version);
2937
assert!(
3038
supported_tss_version.matches(&tss_version),
31-
"Unsupported TSS version {tss_version}"
39+
"Unsupported TSS version {tss_version}, maybe try {TPM2_TSS_VERSION_IGNORE_PRERELEASE}=true"
3240
);
3341

3442
let hierarchy_is_esys_tr_req = VersionReq::parse(">=3.0.0").unwrap();

0 commit comments

Comments
 (0)