Skip to content

Commit e7fca91

Browse files
committed
add CI action for cargo cbuild
1 parent 2cf226b commit e7fca91

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

.github/workflows/checks.yaml

+40-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ jobs:
251251
done
252252
253253
link-c-dynamic-library:
254-
name: dynamic library
254+
name: vanilla dynamic library
255255
strategy:
256256
matrix:
257257
include:
@@ -304,6 +304,45 @@ jobs:
304304
cargo build --release --target ${{matrix.target}} --features=custom-prefix
305305
objdump -tT target/${{matrix.target}}/release/deps/libz_rs.so | grep -q "MY_CUSTOM_PREFIX_uncompress" || (echo "symbol not found!" && exit 1)
306306
307+
cargo-c-dynamic-library:
308+
name: cargo-c dynamic library
309+
strategy:
310+
matrix:
311+
include:
312+
- target: x86_64-unknown-linux-gnu
313+
features:
314+
- ''
315+
runs-on: ubuntu-latest
316+
steps:
317+
- name: Checkout sources
318+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
319+
with:
320+
persist-credentials: false
321+
- name: Install rust toolchain
322+
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
323+
with:
324+
toolchain: stable
325+
targets: ${{matrix.target}}
326+
- name: Install cargo-c
327+
env:
328+
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
329+
run: |
330+
curl -L "$LINK/cargo-c-x86_64-unknown-linux-musl.tar.gz" |
331+
tar xz -C $HOME/.cargo/bin
332+
- name: build with and test the result of cargo-c
333+
working-directory: libz-rs-sys-cdylib
334+
run: |
335+
# build using cargo-c this time
336+
cargo cinstall --offline --release --destdir=/tmp/cargo-cbuild-libz-rs
337+
tree /tmp/cargo-cbuild-libz-rs
338+
# verify that the SONAME is set and includes a version
339+
objdump -p target/x86_64-unknown-linux-gnu/release/libz_rs.so | awk '/SONAME/{print $2}' | grep -E 'libz_rs\.so\.[0-9]+\.[0-9]+'
340+
# build zpipe with our library
341+
cc -o zpipe zpipe.c -L/tmp/cargo-cbuild-libz-rs/usr/local/lib/x86_64-linux-gnu -lz_rs
342+
export LD_LIBRARY_PATH=/tmp/cargo-cbuild-libz-rs/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
343+
./zpipe < Cargo.toml | ./zpipe -d > out.txt
344+
cmp -s Cargo.toml out.txt
345+
307346
wasm32:
308347
name: "wasm32"
309348
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)