#!/usr/bin/env bash set -euo pipefail root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) arch=${1:-$(docker info --format '{{.Architecture}}')} case "$arch" in arm64|aarch64) arch=arm64 ;; amd64|x86_64) arch=amd64 ;; *) printf 'Usage: %s [arm64|amd64] [MAKE_ARGUMENT ...]\n' "$0" >&2; exit 2 ;; esac if [ "$#" -gt 0 ]; then shift; fi if [ ! -f "$root/model/model.safetensors" ]; then printf 'Download the model first: python3 %s/download_model.py\n' "$root" >&2 exit 1 fi image="langdet-linux-test:$arch" docker build --platform "linux/$arch" -f "$root/tools/linux.Dockerfile" -t "$image" "$root/tools" args=(run --rm --network none --platform "linux/$arch" --workdir /work) for path in Makefile langdetect.c liblangdet deps tools examples model; do args+=(--mount "type=bind,src=$root/$path,dst=/work/$path,readonly") done docker "${args[@]}" "$image" sh -eu -c ' make -j4 test "$@" cc -Iliblangdet examples/detect.c liblangdet.a $(pkg-config --libs openblas) -lm -pthread -o build/detect-example c++ -Iliblangdet -x c++ examples/detect.c -x none liblangdet.a $(pkg-config --libs openblas) -lm -pthread -o build/detect-example-cpp ./build/detect-example model "This is an English sentence." "Bugün hava çok güzel." ./build/detect-example-cpp model "This is an English sentence." "Bugün hava çok güzel." ' linux-tests "$@"