Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
uglyoldbob committed Jun 1, 2024
1 parent a4e61d4 commit 2237588
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tss-esapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 11 additions & 0 deletions tss-esapi-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions tss-esapi-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>> {
cfg_if::cfg_if! {
if #[cfg(windows)] {
let mut clang_args: Vec<String> = 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()));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 2237588

Please sign in to comment.