Skip to content

Commit 7b91f5f

Browse files
SuperhepperFirstyearuglyoldbob
committed
Adds the bundled feature.
The bundled feature is ment to make the process of building and managing the tpm2-tss depedency of the tss-esapi-sys crate much easier by downloading the source code and compiling it automatically. This feature was originally developed in \parallaxsecond#523 and then updated in \parallaxsecond#531. Co-authored-by: William Brown <[email protected]> Co-authored-by: Thomas Epperson <[email protected]> Signed-off-by: Jesper Brynolf <[email protected]>
1 parent 40899e5 commit 7b91f5f

File tree

6 files changed

+548
-81
lines changed

6 files changed

+548
-81
lines changed

tss-esapi-sys/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ pkg-config = "0.3.18"
1919
target-lexicon = "0.12.0"
2020
cfg-if = "1.0.0"
2121
semver = "1.0.7"
22+
autotools = { version = "0.2.6", optional = true }
23+
24+
[target.'cfg(windows)'.build-dependencies]
25+
msbuild = { git = "https://github.com/uglyoldbob/msbuild", optional = true }
2226

2327
[features]
2428
generate-bindings = ["bindgen"]
29+
bundled = ["dep:autotools", "dep:msbuild"]

tss-esapi-sys/README.md

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ interface to Rust to [TSS](https://github.com/tpm2-software/tpm2-tss).
1313

1414
This crate exposes an interface for the TSS Enhanced System API and thus
1515
links to libraries that expose this interface. In order to allow proper use
16-
of the ESAPI, this FFI layer includes bindings to TCTI and MU headers, and
16+
of the ESAPI, this FFI layer includes bindings to TCTI and MU headers, and
1717
must therefore link to all of them at build time.
1818

1919
The paths to the libraries are discovered using `pkg-config` - make sure they
20-
are discoverable in this way on your system. Our build script looks for
21-
`tss2-esys`, `tss2-tctildr` and `tss2-mu`. A minimum version of `4.0.1` is
20+
are discoverable in this way on your system. Our build script looks for
21+
`tss2-esys`, `tss2-tctildr` and `tss2-mu`. A minimum version of `4.0.1` is
2222
required for all of them.
2323

2424
Having installed the open-source implementation libraries at `/usr/local/lib` (by default), it
@@ -41,9 +41,70 @@ available, feel free to raise a Pull Request to add it or to use build-time
4141
generation of bindings. All the committed bindings **MUST** be generated from
4242
the library version found under the `vendor` submodule.
4343

44+
## Bundling TPM-TSS
45+
46+
tpm-tss is used by this library to communicate with TPMs. If this library
47+
is not available on your system you may optionally bundle (vendor) tpm-tss
48+
during builds. tpm-tss can be provided from a local source path with the
49+
environment variable `TPM_TSS_SOURCE_PATH` or it will be retrieved from
50+
github during the build. The version to retrieve can be controlled by setting
51+
the `TPM2_TSS_SOURCE_VERSION` environment variable.
52+
N.B. On windows it might be necessary to manually create the VERSION file
53+
when a local source is being used.
54+
55+
To enable this feature:
56+
57+
```bash
58+
cargo build --features=bundled
59+
```
60+
61+
```bash
62+
TPM2_TSS_VERSION="4.1.3" cargo build --features=bundled
63+
```
64+
65+
```bash
66+
TPM_TSS_SOURCE_PATH=/path/to/tpm-tss cargo build --features=bundled
67+
```
68+
69+
If using this feature from an external project
70+
71+
```
72+
tss-esapi-sys = { version = "...", features = "bundled" }
73+
```
74+
75+
### Windows
76+
77+
Compiling for windows requires a bit of setup to work with the bundled feature.
78+
79+
* Openssl must be installed to a non-standard location at C:\OpenSSL-v11-Win64
80+
* Visual studio 2019 must be installed with the Clang/C2 experimental component,
81+
and windows sdk 10.0 (Other versions of Visual Studio may work but are untested
82+
at this point).
83+
84+
### MacOS
85+
86+
Compiling on MacOS requires the bundling feature. This requires dependencies
87+
from brew.
88+
89+
```bashbre
90+
brew install autoconf autoconf-archive automake json-c libtool m4 pkg-config
91+
```
92+
93+
Optionally you may require these libraries for certain classes of TPM transport
94+
95+
```
96+
brew install libftdi
97+
```
98+
99+
### OpenSUSE / SUSE
100+
101+
```
102+
sudo zypper in autoconf autoconf-archive automake libjson-c-devel libtool libtpms-devel gawk make
103+
```
104+
44105
## Cross compiling
45106

46-
Cross-compilation can be done as long as you have on your build system the TSS
107+
Cross-compilation can be done as long as you have on your build system the TSS
47108
libraries compiled for your target system of choice. We rely on `pkg-config` to
48109
identify the libraries which we link against. Installing `tpm2-tss` does yield
49110
`.pc` files which can be used for this purpose, but depending on the exact build

0 commit comments

Comments
 (0)