Skip to content

Commit

Permalink
Merge pull request #388 from YOU54F/feat/convert_musl_static_to_dynam…
Browse files Browse the repository at this point in the history
…ic_so

feat: convert musl static .a to .so
  • Loading branch information
rholshausen authored Feb 13, 2024
2 parents 41e9c46 + df22043 commit db3c381
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
with:
toolchain: stable
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v3
- if: startsWith(github.ref, 'refs/tags/pact_mock_server_cli') && runner.os == 'Linux'
run: ./release-linux.sh
working-directory: rust/pact_mock_server_cli
Expand Down
32 changes: 28 additions & 4 deletions rust/pact_ffi/release-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,42 @@ rustup run nightly cbindgen \
cp include/*.h ../release_artifacts

echo -- Build the musl release artifacts --
sudo apt install musl-tools
rustup target add x86_64-unknown-linux-musl
cargo build --release --target=x86_64-unknown-linux-musl
cargo install cross@0.2.5
cross build --release --target=x86_64-unknown-linux-musl
gzip -c ../target/x86_64-unknown-linux-musl/release/libpact_ffi.a > ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz > ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz.sha256

cargo install cross@0.2.5
mkdir tmp
cp ../target/x86_64-unknown-linux-musl/release/libpact_ffi.a tmp/
docker run --platform=linux/amd64 --rm -v $PWD/tmp:/scratch alpine /bin/sh -c 'apk add --no-cache musl-dev gcc && \
cd /scratch && \
ar -x libpact_ffi.a && \
gcc -shared *.o -o libpact_ffi.so && \
rm -f *.o'

gzip -c tmp/libpact_ffi.so > ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz > ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz.sha256
rm -rf tmp


echo -- Build the musl aarch64 release artifacts --
cargo clean
cross build --release --target=aarch64-unknown-linux-musl
gzip -c ../target/aarch64-unknown-linux-musl/release/libpact_ffi.a > ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz > ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz.sha256

mkdir tmp
cp ../target/aarch64-unknown-linux-musl/release/libpact_ffi.a tmp/
docker run --platform=linux/arm64 --rm -v $PWD/tmp:/scratch alpine /bin/sh -c 'apk add --no-cache musl-dev gcc && \
cd /scratch && \
ar -x libpact_ffi.a && \
gcc -shared *.o -o libpact_ffi.so && \
rm -f *.o'

gzip -c tmp/libpact_ffi.so > ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz > ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz.sha256
rm -rf tmp

echo -- Build the aarch64 release artifacts --
cargo clean
cross build --target aarch64-unknown-linux-gnu --release
Expand Down

0 comments on commit db3c381

Please sign in to comment.