import "wasm.just" import "fail.just" BUILD_DIR := "build" # Load environment variables set by "nix develop"-shell FAIL_SHARE := env("FAIL_SHARE") WASI_ROOT := env("WASI_ROOT") WAMR_ROOT := env("WAMR_ROOT") LIBIWASM_DEBUG := env("LIBIWASM_DEBUG") LIBIWASM_RELEASE := env("LIBIWASM_RELEASE") LIBIWASM_LINUX_DEBUG := env("LIBIWASM_LINUX_DEBUG") LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE") CROSS_CC := env("CROSS_CC") LINUX_CC := env("LINUX_CC") # FAIL* variables FAIL_SERVER_PORT := "1111" RESULTBROWSER_PORT := "5000" BOCHS_RUNNER := "bochs-experiment-runner.py" FAIL_TRACE := "fail-x86-tracing" FAIL_DUMP := "dump-trace" FAIL_IMPORT := "import-trace" FAIL_PRUNE := "prune-trace" FAIL_SERVER := "generic-experiment-server" FAIL_INJECT := "generic-experiment-client" RESULT_BROWSER := "resultbrowser.py" # =================================================================================================================== # # Helper recipes # =================================================================================================================== # [default] [private] list: @just --list [private] create-build-dir module: mkdir -p {{ BUILD_DIR }}-{{ module }} [doc("Delete the build directory")] clean module: rm -rf {{ BUILD_DIR }}-{{ module }} # =================================================================================================================== # # MySQL recipes # =================================================================================================================== # [doc("Start MySQL container to receive FAIL* trace/campaign results")] [group("3: fail db")] start-db: docker run -d \ --name fail-db \ -e MYSQL_ROOT_PASSWORD=fail \ -e MYSQL_USER=fail \ -e MYSQL_PASSWORD=fail \ -e MYSQL_DATABASE=fail \ -p 3306:3306 \ mysql [doc("Connect to MySQL database using DBeaver")] [group("3: fail db")] connect-db: dbeaver -con "name=fail|driver=mysql|host=localhost|port=3306|database=fail|user=fail|password=fail" [doc("Stop MySQL container")] [group("3: fail db")] stop-db: docker stop fail-db [doc("Remove MySQL container")] [group("3: fail db")] remove-db: docker container rm fail-db # =================================================================================================================== # # Debugging recipes # =================================================================================================================== # [doc("Launch gdb")] [group("debug")] gdb module: gdb --tui {{ BUILD_DIR }}-{{ module }}/system.elf [doc("Launch radare2 at os_main")] [group("debug")] radare module: radare2 -AA -c "s dbg.os_main; pdf" {{ BUILD_DIR }}-{{ module }}/system.elf # =================================================================================================================== # # Just do it # =================================================================================================================== # [private] build-common-post module target="fail": [doc("Perform all steps for a fail/linux/linux-bm build with aot/interp WASM")] [group("5: just do it")] build module target="fail" mode="aot": #!/usr/bin/env sh just clean {{ module }} just create-build-dir {{ module }} if [ "{{ mode }}" = "aot" ]; then just build-wasm-module {{ module }} just build-wasm-aot {{ module }} just build-wasm-aot-array {{ module }} just prepare-aot-host {{ module }} {{ target }} just build-wasm-host {{ module }} {{ target }} just build-system-startup {{ module }} {{ target }} just build-system-syscalls {{ module }} {{ target }} just link-system {{ module }} {{ target }} elif [ "{{ mode }}" = "interp" ]; then just build-wasm-module {{ module }} just build-wasm-interp-array {{ module }} just prepare-interp-host {{ module }} {{ target }} just build-wasm-host {{ module }} {{ target }} just build-system-startup {{ module }} {{ target }} just build-system-syscalls {{ module }} {{ target }} just link-system {{ module }} {{ target }} elif [ "{{ mode }}" = "c" ]; then just build-c-module {{ module }} {{ target }} just build-c-host {{ module }} {{ target }} just build-system-startup {{ module }} {{ target }} just link-c-system {{ module }} {{ target }} else echo "unknown mode: {{ mode }}" >&2 exit 1 fi just build-iso {{ module }} [doc("Run binary")] [group("5: just do it")] run module: {{ BUILD_DIR }}-{{ module }}/system.elf [doc("Send binaries to mars")] [group("5: just do it")] upload module: scp -r {{ BUILD_DIR }}-{{ module }} mars:~/Documents/failnix/{{ BUILD_DIR }}-{{ module }} [doc("Perform all steps for a FAIL* campaign")] [group("5: just do it")] inject module: just start-db @echo "Waiting for database..." sleep 20 just trace {{ module }} just import {{ module }} just server {{ module }} just client {{ module }} just result {{ module }} just resultbrowser