Skip to content

Commit e4813fc

Browse files
committed
Add cross-compilation example to nightly
This commit adds cross-compilation to armv7 and aarch64 to the nightly build. This involves modifications to the way `pkg-config` is used as described in #204. Signed-off-by: Ionut Mihalcea <[email protected]>
1 parent d758496 commit e4813fc

File tree

11 files changed

+35483
-51
lines changed

11 files changed

+35483
-51
lines changed

.github/workflows/nightly.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ jobs:
4141
run: cargo audit
4242

4343
coverage:
44-
name: Calculate code coverage
44+
name: Calculate code coverage and cross compile
4545
runs-on: ubuntu-latest
4646
steps:
4747
- uses: actions/checkout@v2
4848
- name: Build the container
4949
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
50-
- name: Run the container
50+
- name: Run the code coverage script
5151
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --security-opt seccomp=unconfined ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/coverage.sh
5252
- name: Collect coverage results
5353
run: bash <(curl -s https://codecov.io/bash)
54+
- name: Run the cross-compilation script
55+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/cross-compile.sh

tss-esapi-sys/.cargo/config

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Cargo seems to expect the -gcc variant instead of -ld
2+
3+
[target.armv7-unknown-linux-gnueabi]
4+
linker = "arm-linux-gnueabihf-gcc"
5+
6+
[target.aarch64-unknown-linux-gnu]
7+
linker = "aarch64-linux-gnu-gcc"

tss-esapi-sys/README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,22 @@ NOTE: Only a limited set of bindings are committed and their target triplet
3838
is included in the name of the file - if the triplet you require is not
3939
available, feel free to raise a Pull Request to add it or to use build-time
4040
generation of bindings. All the committed bindings **MUST** be generated from
41-
the library version found under the `vendor` submodule.
41+
the library version found under the `vendor` submodule.
42+
43+
## Cross compiling
44+
45+
Cross-compilation can be done as long as you have on your build system the TSS
46+
libraries compiled for your target system of choice. We rely on `pkg-config` to
47+
identify the libraries which we link against. Installing `tpm2-tss` yields `.pc`
48+
files which can be used for this purpose, but depending on the exact build
49+
environment setup, you might need to be careful when configuring the `tpm2-tss`
50+
build.
51+
52+
We include cross-compilation builds as a nightly check in Github Actions - you
53+
can find them [here](../tss-esapi/tests/cross-compile.sh) as an example of the
54+
steps needed. You can find more information on using `pkg-config` when cross-compiling
55+
[here](https://github.com/parallaxsecond/rust-tss-esapi/issues/204). Our wrapper
56+
script around `pkg-config` can be seen [here](../tss-esapi/tests/pkg-config).
57+
58+
Be advised that in most cases the linker used might need to be set manually in
59+
`.cargo/config` (some entries already exist there as an example).

0 commit comments

Comments
 (0)