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
55const TPM2_TSS_MINIMUM_VERSION : Version = Version :: new ( 4 , 1 , 3 ) ;
6+ const TPM2_TSS_VERSION_IGNORE_PRERELEASE : & str = "TPM2_TSS_VERSION_IGNORE_PRERELEASE" ;
67
78fn 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