Skip to content

Commit 9dac753

Browse files
authored
Merge pull request #392 from ionut-arm/update-bindgen
Update bindgen
2 parents ce608d4 + 81b539a commit 9dac753

File tree

9 files changed

+5676
-4957
lines changed

9 files changed

+5676
-4957
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Build the container
3333
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
3434
- name: Run the container
35-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.56.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
35+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.57.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
3636
# All in one job as I think it is a big overhead to build and run the Docker
3737
# container?
3838
tests-ubuntu:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ At the moment we test (via CI) and support the following Rust compiler versions:
99

1010
* On Ubuntu we test with:
1111
- The latest stable compiler version, as accessible through `rustup`.
12-
- The 1.56 compiler version.
12+
- The 1.57 compiler version.
1313
* On Fedora we test with the compiler version included with the Fedora 35 release.
1414

1515
If you need support for other versions of the compiler, get in touch with us to see what we can do!

tss-esapi-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ documentation = "https://docs.rs/crate/tss-esapi-sys"
1313
links = "tss2-esys"
1414

1515
[build-dependencies]
16-
bindgen = { version = "0.59.1", optional = true }
16+
bindgen = { version = "0.63.0", optional = true }
1717
pkg-config = "0.3.18"
1818
target-lexicon = "0.12.0"
1919

tss-esapi-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub fn generate_from_system(esapi_out: PathBuf) {
9797
.expect("Error converting OsString to String.");
9898

9999
bindgen::Builder::default()
100+
.size_t_is_usize(false)
100101
.clang_arg(format!("-I{}/tss2/", tss2_esys_include_path))
101102
.clang_arg(format!("-I{}/tss2/", tss2_tctildr_include_path))
102103
.clang_arg(format!("-I{}/tss2/", tss2_mu_include_path))

tss-esapi-sys/regenerate-bindings.sh

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,81 @@
88

99
set -euf -o pipefail
1010

11+
OPENSSL_GIT="https://github.com/openssl/openssl.git"
1112
OPENSSL_VERSION="OpenSSL_1_1_1j"
13+
TPM2_TSS_GIT="https://github.com/tpm2-software/tpm2-tss.git"
14+
TPM2_TSS_VERSION="2.3.3"
1215

13-
cross-compile-openssl() {
14-
# Prepare directory for cross-compiled OpenSSL files
15-
mkdir -p /tmp/openssl-$1
16-
export INSTALL_DIR=/tmp/openssl-$1
16+
export SYSROOT="/tmp/sysroot"
17+
18+
git_checkout() {
19+
if [ ! -d "/tmp/$(basename "$1" ".git")" ]; then
20+
pushd /tmp
21+
git clone "$1" --branch "$2"
22+
popd
23+
fi
24+
}
25+
26+
prepare_sysroot() {
27+
# Prepare the SYSROOT
28+
[ -d "$SYSROOT" ] && rm -fr "$SYSROOT"
29+
mkdir -p "$SYSROOT"
30+
31+
# Allow the `pkg-config` crate to cross-compile
32+
export PKG_CONFIG_ALLOW_CROSS=1
33+
export PKG_CONFIG_PATH="$SYSROOT"/lib/pkgconfig:"$SYSROOT"/share/pkgconfig
34+
export PKG_CONFIG_SYSROOT_DIR="$SYSROOT"
35+
}
1736

37+
cross-compile-openssl() {
1838
pushd /tmp/openssl
1939
# Compile and copy files over
20-
./Configure $2 shared --prefix=$INSTALL_DIR --openssldir=$INSTALL_DIR/openssl --cross-compile-prefix=$1-
40+
./Configure $2 shared --prefix="$SYSROOT" --openssldir="$SYSROOT"/openssl --cross-compile-prefix=$1-
2141
make clean
2242
make depend
2343
make -j$(nproc)
24-
make install
44+
make install_sw
2545
popd
26-
27-
export INSTALL_DIR=
2846
}
2947

3048
cross-compile-tpm2-tss() {
31-
# Prepare directory for cross-compiled TSS lib
32-
# `DESTDIR` is used in `make install` below to set the root of the installation paths.
33-
# The `./configure` script accepts a `--prefix` input variable which sets the same root,
34-
# but also adds it to the paths in `.pc` files used by `pkg-config`. This prevents the
35-
# use of `PKG_CONFIG_SYSROOT_DIR`.
36-
mkdir -p /tmp/tpm2-tss-$1
37-
export DESTDIR=/tmp/tpm2-tss-$1
38-
# Set sysroot to be used by the `pkg-config` wrapper
39-
export SYSROOT=/tmp/tpm2-tss-$1
40-
41-
pushd /tpm2-tss
42-
# Compile and copy files over
43-
./configure --build=x86_64-pc-linux-gnu --host=$1 --target=$1 CC=$1-gcc \
44-
LIBCRYPTO_CFLAGS="-I/tmp/openssl-$1/include" LIBCRYPTO_LIBS="-L/tmp/openssl-$1/lib -lcrypto"
49+
pushd /tmp/tpm2-tss
50+
[ ! -f configure ] && ./bootstrap
51+
./configure --enable-fapi=no --prefix=/ --build=x86_64-pc-linux-gnu --host=$1 --target=$1 CC=$1-gcc
4552
make clean
4653
make -j$(nproc)
47-
make install
54+
make DESTDIR="$SYSROOT" install
4855
popd
49-
50-
export DESTDIR=
5156
}
5257

5358
# Download cross-compilers
54-
apt update
55-
apt install -y gcc-multilib
56-
apt install -y gcc-arm-linux-gnueabi
57-
apt install -y gcc-aarch64-linux-gnu
58-
59-
# Download OpenSSL source code
60-
if [ ! -d "/tmp/openssl" ]; then
61-
pushd /tmp
62-
git clone https://github.com/openssl/openssl.git --branch $OPENSSL_VERSION
63-
popd
64-
fi
59+
sudo apt update
60+
sudo apt install -y gcc-multilib
61+
sudo apt install -y gcc-arm-linux-gnueabi
62+
sudo apt install -y gcc-aarch64-linux-gnu
63+
64+
# Download development version for tpm2-tss
65+
sudo apt install -y libtss2-dev
66+
67+
# Download other dependencies
68+
sudo apt install -y autoconf
69+
sudo apt install -y autoconf-archive
70+
sudo apt install -y cmake
71+
sudo apt install -y libclang-dev
72+
sudo apt install -y libtool
73+
sudo apt install -y pkgconf
74+
75+
# Download OpenSSL, tpm2-tss and dependencies source code
76+
git_checkout "$OPENSSL_GIT" "$OPENSSL_VERSION"
77+
git_checkout "$TPM2_TSS_GIT" "$TPM2_TSS_VERSION"
6578

6679
# Regenerate bindings for x86_64-unknown-linux-gnu
6780
cargo clean
6881
cargo build --features generate-bindings
6982
find ../target -name tss_esapi_bindings.rs -exec cp {} ./src/bindings/x86_64-unknown-linux-gnu.rs \;
7083

71-
# Allow the `pkg-config` crate to cross-compile
72-
export PKG_CONFIG_ALLOW_CROSS=1
73-
# Make the `pkg-config` crate use our wrapper
74-
export PKG_CONFIG=$(pwd)/../tss-esapi/tests/pkg-config
84+
# Clean and prepare SYSROOT
85+
prepare_sysroot
7586

7687
# Regenerate bindings for aarch64-unknown-linux-gnu
7788
cross-compile-openssl aarch64-linux-gnu linux-generic64
@@ -82,11 +93,14 @@ cargo clean
8293
cargo build --features generate-bindings --target aarch64-unknown-linux-gnu
8394
find ../target -name tss_esapi_bindings.rs -exec cp {} ./src/bindings/aarch64-unknown-linux-gnu.rs \;
8495

96+
# Clean and prepare SYSROOT
97+
prepare_sysroot
98+
8599
# Regenerate bindings for armv7-unknown-linux-gnueabi
86100
cross-compile-openssl arm-linux-gnueabi linux-generic32
87101
cross-compile-tpm2-tss arm-linux-gnueabi
88102

89103
rustup target add armv7-unknown-linux-gnueabi
90104
cargo clean
91105
cargo build --features generate-bindings --target armv7-unknown-linux-gnueabi
92-
find ../target -name tss_esapi_bindings.rs -exec cp {} ./src/bindings/arm-unknown-linux-gnueabi.rs \;
106+
find ../target -name tss_esapi_bindings.rs -exec cp {} ./src/bindings/arm-unknown-linux-gnueabi.rs \;

0 commit comments

Comments
 (0)