Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

uglyoldbob
Copy link
Contributor

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

tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
@Superhepper
Copy link
Collaborator

Excellent work. I will have a look at those errors when I get the time to see if we can get this merged.

@uglyoldbob
Copy link
Contributor Author

I have a few changes required for bundled on linux remaining.

tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
tss-esapi-sys/build.rs Outdated Show resolved Hide resolved
@Superhepper
Copy link
Collaborator

Only thing left for you to do is signing the commits.

@uglyoldbob
Copy link
Contributor Author

The latest commit on the pull request should have signature on it now.

Superhepper
Superhepper previously approved these changes Apr 29, 2024
[features]
generate-bindings = ["bindgen"]
bundled = ["dep:autotools", "dep:msbuild", "dep:winreg"]
Copy link
Contributor

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? 🤔

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Member

@ionut-arm ionut-arm left a 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!

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 }
Copy link
Member

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.

Copy link
Contributor Author

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"]
Copy link
Member

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?

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that makes sense.

source_path.pop();
source_path.pop();
source_path.pop();
println!("Source path is {}", source_path.display());
Copy link
Member

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?

Copy link
Contributor Author

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.

let build_string = match profile.as_str() {
"debug" => "Debug",
"release" => "Release",
_ => panic!("Unknown cargo profile:"),
Copy link
Member

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 ":"?

Copy link
Contributor Author

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.

Comment on lines 84 to 97
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)
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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"?

@Firstyear
Copy link
Contributor

@ionut-arm @Superhepper Should we re-review this? This will assist me with MacOS development.

@wiktor-k
Copy link
Collaborator

@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).

@Firstyear
Copy link
Contributor

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.

@Firstyear
Copy link
Contributor

@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).

#531

My branch on top of this tests on linux and has it working :)

Superhepper
Superhepper previously approved these changes Jul 30, 2024
Copy link
Collaborator

@Superhepper Superhepper left a 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.

ionut-arm
ionut-arm previously approved these changes Aug 2, 2024
Copy link
Member

@ionut-arm ionut-arm left a 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?

@Superhepper
Copy link
Collaborator

This needs to be rebased on the latest main.

@Superhepper
Copy link
Collaborator

@uglyoldbob It would be greate if you could rebase this on lastest from main so we could get it merged.

@uglyoldbob
Copy link
Contributor Author

@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.

@Superhepper
Copy link
Collaborator

@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.

@wiktor-k
Copy link
Collaborator

wiktor-k commented Aug 19, 2024

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.

Just for the record when you do git rebase main (or something like that) you can also do git rebase -i main to start "interactive" rebase which would present you with a list of commits. If you mark the later ones as squash or fixup they'd be melded with previous ones automatically. Just FYI. 👋

Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
@Superhepper
Copy link
Collaborator

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.

Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 13, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Sep 20, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Superhepper added a commit to Superhepper/rust-tss-esapi that referenced this pull request Oct 2, 2024
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 <[email protected]>
Signed-off-by: Jesper Brynolf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants