diff --git a/nac3standalone/demo/check_demo.sh b/nac3standalone/demo/check_demo.sh index 85e5e99b..d481af85 100755 --- a/nac3standalone/demo/check_demo.sh +++ b/nac3standalone/demo/check_demo.sh @@ -16,8 +16,8 @@ demo="$1" echo -n "Checking $demo... " ./interpret_demo.py "$demo" > interpreted.log -./run_demo.sh "${nac3args[@]}" "$demo" > run.log -./run_demo_lli.sh "${nac3args[@]}" "$demo" > run_lli.log +./run_demo.sh --out run.log "${nac3args[@]}" "$demo" +./run_demo.sh --lli --out run_lli.log "${nac3args[@]}" "$demo" diff -Nau interpreted.log run.log diff -Nau interpreted.log run_lli.log echo "ok" diff --git a/nac3standalone/demo/run_demo.sh b/nac3standalone/demo/run_demo.sh index 8ba1095c..a4f5b086 100755 --- a/nac3standalone/demo/run_demo.sh +++ b/nac3standalone/demo/run_demo.sh @@ -7,6 +7,23 @@ if [ -z "$1" ]; then exit 1 fi +declare -a nac3args +while [ $# -ge 1 ]; do + case "$1" in + --out) + shift + outfile="$1" + ;; + --lli) + use_lli=1 + ;; + *) + nac3args+=("$1") + ;; + esac + shift +done + if [ -e ../../target/release/nac3standalone ]; then nac3standalone=../../target/release/nac3standalone else @@ -14,9 +31,29 @@ else nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone fi -rm -f "*.o" demo +if [ -z "$use_lli" ]; then + rm -f "*.o" demo -$nac3standalone "$@" -clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c -clang -lm -o demo module.o demo.o -./demo + $nac3standalone "${nac3args[@]}" + + clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c + clang -lm -o demo module.o demo.o + + if [ -z "$outfile" ]; then + ./demo + else + ./demo > "$outfile" + fi +else + rm -f "*.o" "*.bc" demo + + $nac3standalone --emit-llvm "${nac3args[@]}" + + clang -c -std=gnu11 -Wall -Wextra -O3 -emit-llvm -o demo.bc demo.c + + if [ -z "$outfile" ]; then + lli --extra-module demo.bc --extra-module irrt.bc main.bc + else + lli --extra-module demo.bc --extra-module irrt.bc main.bc > "$outfile" + fi +fi diff --git a/nac3standalone/demo/run_demo_lli.sh b/nac3standalone/demo/run_demo_lli.sh deleted file mode 100755 index 6efd4f5c..00000000 --- a/nac3standalone/demo/run_demo_lli.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ -z "$1" ]; then - echo "No argument supplied" - exit 1 -fi - -if [ -e ../../target/release/nac3standalone ]; then - nac3standalone=../../target/release/nac3standalone -else - # used by Nix builds - nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone -fi - -rm -f "*.o" "*.bc" demo - -$nac3standalone --emit-llvm "$@" -clang -c -std=gnu11 -Wall -Wextra -O3 -emit-llvm -o demo.bc demo.c -lli --extra-module demo.bc --extra-module irrt.bc main.bc