#!/bin/sh # Where to find the sources (only used to copy zstd.h) ZSTD_SRC_ROOT="../../lib" # Temporary compiled binary OUT_FILE="tempbin" RUST_TARGET_DIR="../../rust/target/single-file-library" RUST_ARCHIVE="$RUST_TARGET_DIR/release/libzstd_rs.a" # Amalgamate the sources ./create_single_file_library.sh # Did combining work? if [ $? -ne 0 ]; then echo "Single file library creation script: FAILED" exit 1 fi echo "Single file library creation script: PASSED" # Copy the header to here (for the tests) cp "$ZSTD_SRC_ROOT/zstd.h" examples/zstd.h cp "$ZSTD_SRC_ROOT/zstd_errors.h" examples/zstd_errors.h # Build the Rust implementation referenced by the amalgamated C shims. ${CARGO:-cargo} build --manifest-path ../../rust/Cargo.toml --release \ --target-dir "$RUST_TARGET_DIR" if [ $? -ne 0 ]; then echo "Building Rust library archive: FAILED" exit 1 fi # Compile the generated output cc -Wall -Wextra -Werror -Wshadow \ -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable \ -pthread -I. -Os -g0 -o $OUT_FILE zstd.c examples/roundtrip.c "$RUST_ARCHIVE" # Did compilation work? if [ $? -ne 0 ]; then echo "Compiling roundtrip.c: FAILED" exit 1 fi echo "Compiling roundtrip.c: PASSED" # Run then delete the compiled output ./$OUT_FILE retVal=$? rm -f $OUT_FILE # Did the test work? if [ $retVal -ne 0 ]; then echo "Running roundtrip.c: FAILED" exit 1 fi echo "Running roundtrip.c: PASSED" # The generated C now calls Rust, so it is no longer a standalone Emscripten input. echo "(Skipping Emscripten test for Rust-backed amalgamation)" exit 0