Skip to content

Commit e82a5aa

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 <william.brown@suse.com> Co-authored-by: Thomas Epperson <thomas.epperson@gmail.com> Signed-off-by: Jesper Brynolf <jesper.brynolf@gmail.com>
1 parent 2dd2308 commit e82a5aa

File tree

5 files changed

+340
-60
lines changed

5 files changed

+340
-60
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 = { path = "../../msbuild", optional = true }
2226

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

tss-esapi-sys/README.md

Lines changed: 58 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,63 @@ 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.
51+
52+
To enable this feature:
53+
54+
```bash
55+
cargo build --features=bundled
56+
```
57+
58+
```bash
59+
TPM_TSS_SOURCE_PATH=/path/to/tpm-tss cargo build --features=bundled
60+
```
61+
62+
If using this feature from an external project
63+
64+
```
65+
tss-esapi-sys = { version = "...", features = "bundled" }
66+
```
67+
68+
### Windows
69+
70+
Compiling for windows requires a bit of setup to work with the bundled feature.
71+
72+
* Openssl must be installed to a non-standard location at C:\OpenSSL-v11-Win64
73+
* Visual studio 2019 must be installed with the Clang/C2 experimental component,
74+
and windows sdk 10.0 (Other versions of Visual Studio may work but are untested
75+
at this point).
76+
77+
### MacOS
78+
79+
Compiling on MacOS requires the bundling feature. This requires dependencies
80+
from brew.
81+
82+
```bashbre
83+
brew install autoconf autoconf-archive automake json-c libtool m4 pkg-config
84+
```
85+
86+
Optionally you may require these libraries for certain classes of TPM transport
87+
88+
```
89+
brew install libftdi
90+
```
91+
92+
### OpenSUSE / SUSE
93+
94+
```
95+
sudo zypper in autoconf autoconf-archive automake libjson-c-devel libtool libtpms-devel gawk make
96+
```
97+
4498
## Cross compiling
4599

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

0 commit comments

Comments
 (0)