Skip to content

Commit 862a8f7

Browse files
committed
Fix Docs.rs build problem.
Building the Docs.rs documentation failed due to a version environmental variable not being set. This commit addresses the problem by defaulting to the minimum supported tpm2-tss version when building for the Docs.rs build. Signed-off-by: Jesper Brynolf <[email protected]>
1 parent 2df045f commit 862a8f7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tss-esapi/build.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@
22
// SPDX-License-Identifier: Apache-2.0
33
use semver::{Version, VersionReq};
44

5+
const TPM2_TSS_MINIMUM_VERSION: Version = Version::new(4, 1, 3);
6+
57
fn main() {
68
println!("cargo:rustc-check-cfg=cfg(hierarchy_is_esys_tr)");
79
println!("cargo:rustc-check-cfg=cfg(has_tss_base_rc_values_28_to_51)");
810
println!("cargo:rustc-check-cfg=cfg(has_tss_base_rc_values_52_to_53)");
911
println!("cargo:rustc-check-cfg=cfg(has_tpmu_sensitive_create)");
1012
println!("cargo:rustc-check-cfg=cfg(has_esys_tr_get_tpm_handle)");
1113

12-
let tss_version_string = std::env::var("DEP_TSS2_ESYS_VERSION")
13-
.expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string");
14-
15-
let tss_version = Version::parse(&tss_version_string)
16-
.expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version");
14+
// If documentation for Docs.rs is being built then the version is set
15+
// to the minimum supported tpm2-tss version.
16+
let tss_version = if std::env::var("DOCS_RS").is_ok() {
17+
TPM2_TSS_MINIMUM_VERSION
18+
} else {
19+
let tss_version_string = std::env::var("DEP_TSS2_ESYS_VERSION")
20+
.expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string");
21+
22+
Version::parse(&tss_version_string)
23+
.expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version")
24+
};
1725

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

0 commit comments

Comments
 (0)