Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: convert musl static .a to .so #388

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading