#!/bin/sh # Temporary compiled binary OUT_FILE="tempbin" RUST_TARGET_DIR="../../rust/target/single-file-decompress" RUST_ARCHIVE="$RUST_TARGET_DIR/release/libzstd_rs.a" # Amalgamate the sources ./create_single_file_decoder.sh # Did combining work? if [ $? -ne 0 ]; then echo "Single file decoder creation script: FAILED" exit 1 fi echo "Single file decoder creation script: PASSED" # Build the Rust decoder implementation referenced by the amalgamated C shims. ${CARGO:-cargo} build --manifest-path ../../rust/Cargo.toml --release \ --target-dir "$RUST_TARGET_DIR" --no-default-features --features decompression if [ $? -ne 0 ]; then echo "Building Rust decoder archive: FAILED" exit 1 fi # Compile the generated output cc -Wall -Wextra -Wshadow -Werror -Os -g0 -I../../lib -o $OUT_FILE \ examples/simple.c ../../lib/common/pool.c "$RUST_ARCHIVE" # Did compilation work? if [ $? -ne 0 ]; then echo "Compiling simple.c: FAILED" exit 1 fi echo "Compiling simple.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 simple.c: FAILED" exit 1 fi echo "Running simple.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