-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement bundled feature and improve windows support #523
base: main
Are you sure you want to change the base?
Conversation
Excellent work. I will have a look at those errors when I get the time to see if we can get this merged. |
I have a few changes required for bundled on linux remaining. |
Only thing left for you to do is signing the commits. |
282b6eb
to
a4e61d4
Compare
The latest commit on the pull request should have signature on it now. |
[features] | ||
generate-bindings = ["bindgen"] | ||
bundled = ["dep:autotools", "dep:msbuild", "dep:winreg"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't bundled need to imply bindgen too? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought that, but on my Ubuntu installation, bindgen didn't work. I had to do bundled without bindgen there.
On windows I needed bindgen and bundled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bundled does need to imply bindgen. Bundled can use the bindings that are committed in the sys crate and just build the libraries from the specified version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch!
tss-esapi-sys/Cargo.toml
Outdated
pkg-config = "0.3.18" | ||
target-lexicon = "0.12.0" | ||
cfg-if = "1.0.0" | ||
semver = "1.0.7" | ||
|
||
[target.'cfg(windows)'.build-dependencies] | ||
msbuild = { git = "https://github.com/uglyoldbob/msbuild.git", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd strongly prefer if this was published to crates.io and we included it that way. Otherwise I'm not even sure we can publish tss-esapi-sys
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right I forgot about that. I'll check to make sure I published all my code for that crate.
[features] | ||
generate-bindings = ["bindgen"] | ||
bundled = ["dep:autotools", "dep:msbuild", "dep:winreg"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some text in the README file and/or in the code documentation to describe the use of the new feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can add some documentation.
pub fn bundled() -> Self { | ||
use std::io::Write; | ||
let out_path = std::env::var("OUT_DIR").expect("No output directory given"); | ||
let source_path = Self::fetch_source( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth making it explicit in documentation about how this behaves in relationship with the build environment, i.e. that if you don't have a local copy of tpm2-tss
then you need access to the internet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense.
tss-esapi-sys/build.rs
Outdated
source_path.pop(); | ||
source_path.pop(); | ||
source_path.pop(); | ||
println!("Source path is {}", source_path.display()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this here on purpose, or just a debugging remnant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a debugging remnant that was accidentally left in.
tss-esapi-sys/build.rs
Outdated
let build_string = match profile.as_str() { | ||
"debug" => "Debug", | ||
"release" => "Release", | ||
_ => panic!("Unknown cargo profile:"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually print what the profile string was after the ":"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, will need to test it.
tss-esapi-sys/build.rs
Outdated
let hklm = winreg::RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE); | ||
let sdk_entry = hklm.open_subkey("SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0").unwrap(); | ||
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"); | ||
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())); | ||
Some(clang_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance there's some documentation somewhere as to what this is doing? Not in this crate, just generally, seems like a lot of hardcoded things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It finds the windows sdk (specifically version 10.0.17134.0) from the registry, and adds the relevant paths for clang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that stands out to me is the version of the SDK. Is it possible to have something less specific? Like "latest" or "10.0"?
@ionut-arm @Superhepper Should we re-review this? This will assist me with MacOS development. |
Just FYI I'm not opposed to merging this but I've been unable to successfully test it in a reasonable time, both on a Windows machine locally and via CI (#524). |
I've been trying to test it on macos, but there are issue in the tpm2-tss side, I need to double check it on linux. |
My branch on top of this tests on linux and has it working :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have liked for the SDK version to be more flexible
but I am ok this as it is now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the changes as well, what do we do about the CI?
This needs to be rebased on the latest main. |
@uglyoldbob It would be greate if you could rebase this on lastest from main so we could get it merged. |
@Superhepper Ok I applied my changes to the latest on main, even with gpg signatures on the two commits. I couldn't figure out how to squash them into a single commit. |
I usually squash commits using interactive rebase and remove all the signing thing from the comment. Then I sign the commit using amend. |
Just for the record when you do |
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
I saw that there were some interest in trying to run the crate under windows using TBS so i moved the TCTI part of this PR into #545 and added you as co-author. I hope that is ok. |
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-author: Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-authored-by: Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-authored-by: Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-authored-by: Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
This pull request adds a feature bundled. It builds the tpm2-tss library from source after fetching with git.
The normal requirements for build the software apply.
The linux build needs all of the normal requirements for building tpm2-tss as described in their repository.
Windows builds require visual studio 2017, with the c2 clang option, visual studio build tools 10.0.17134.0. Openssl should be installed to C:\OpenSSL-v11-Win64