From 223758866b788aac7f545dc490cb251458c07472 Mon Sep 17 00:00:00 2001 From: Thomas Epperson Date: Fri, 31 May 2024 20:25:33 -0500 Subject: [PATCH] Update documentation. --- tss-esapi-sys/Cargo.toml | 2 +- tss-esapi-sys/README.md | 11 +++++++++++ tss-esapi-sys/build.rs | 10 +++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tss-esapi-sys/Cargo.toml b/tss-esapi-sys/Cargo.toml index 7bbf2e11..5df469f2 100644 --- a/tss-esapi-sys/Cargo.toml +++ b/tss-esapi-sys/Cargo.toml @@ -22,7 +22,7 @@ cfg-if = "1.0.0" semver = "1.0.7" [target.'cfg(windows)'.build-dependencies] -msbuild = { git = "https://github.com/uglyoldbob/msbuild.git", optional = true } +msbuild = { version = "0.1.0", optional = true } winreg = {version = "0.52", optional = true } [features] diff --git a/tss-esapi-sys/README.md b/tss-esapi-sys/README.md index 6f87584f..c19982b6 100644 --- a/tss-esapi-sys/README.md +++ b/tss-esapi-sys/README.md @@ -41,6 +41,17 @@ available, feel free to raise a Pull Request to add it or to use build-time generation of bindings. All the committed bindings **MUST** be generated from the library version found under the `vendor` submodule. +## Bundled feature + +There is a feature called bundled which downloads tpm2-tss source from github and compiles it using visual studio. It will usually be paired with the generate-bindings feature. + +# Windows + +Compiling for windows requires a bit of setup to work with the bundled feature. + +* Openssl must be installed to a non-standard location at C:\OpenSSL-v11-Win64 +* Visual studio 2017 must be installed with the Clang/C2 experimental component, and windows sdk 10.0.17134.0. + ## Cross compiling Cross-compilation can be done as long as you have on your build system the TSS diff --git a/tss-esapi-sys/build.rs b/tss-esapi-sys/build.rs index f3c14520..3d288acf 100644 --- a/tss-esapi-sys/build.rs +++ b/tss-esapi-sys/build.rs @@ -77,15 +77,20 @@ pub mod tpm2_tss { } impl Installation { + /// Return an optional list of clang arguments that are platform specific + #[cfg(feature = "bundled")] fn platform_args() -> Option> { cfg_if::cfg_if! { if #[cfg(windows)] { let mut clang_args: Vec = Vec::new(); let hklm = winreg::RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE); + // Find the windows sdk path from the windows registry let sdk_entry = hklm.open_subkey("SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0").unwrap(); + // add relevant paths to get to the windows 10.0.17134.0 sdk, which tpm2-tss uses on windows. let installation_path: String = sdk_entry.get_value("InstallationFolder").unwrap(); let ip_pb = PathBuf::from(installation_path).join("Include"); let windows_sdk = ip_pb.join("10.0.17134.0"); + // Add paths required for bindgen to find all required headers clang_args.push(format!("-I{}", windows_sdk.join("ucrt").display())); clang_args.push(format!("-I{}", windows_sdk.join("um").display())); clang_args.push(format!("-I{}", windows_sdk.join("shared").display())); @@ -125,7 +130,7 @@ pub mod tpm2_tss { repo_path } - #[cfg(feature = "bundled")] + #[cfg(all(feature = "bundled",not(windows)))] fn compile_with_autotools(p: PathBuf) -> PathBuf { let output1 = std::process::Command::new("./bootstrap") .current_dir(&p) @@ -332,7 +337,7 @@ pub mod tpm2_tss { let build_string = match profile.as_str() { "debug" => "Debug", "release" => "Release", - _ => panic!("Unknown cargo profile:"), + _ => panic!("Unknown cargo profile: {}", profile), }; let mut source_path = self .tss2_esys @@ -342,7 +347,6 @@ pub mod tpm2_tss { source_path.pop(); source_path.pop(); source_path.pop(); - println!("Source path is {}", source_path.display()); println!( "cargo:rustc-link-search=dylib={}", source_path.join("x64").join(build_string).display()