From 636146f6af0f90f8847830038155695e522fe651 Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Tue, 26 May 2026 16:44:54 +0200 Subject: [PATCH 1/5] Add a justfile --- justfile | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 justfile diff --git a/justfile b/justfile new file mode 100644 index 00000000..07a682ac --- /dev/null +++ b/justfile @@ -0,0 +1,104 @@ +set unstable + + +default: + just --list + + +## Run +[group('run')] +[doc('Run program on any platform (rebuilds)')] +run platform program: + stage {{program}} + build {{platform}} + flash {{platform}} + + +## Stage + +[group('stage')] +[doc('Stage program as .wasm')] +stage program: (wat program) + + +[group('stage')] +[doc('Compile target .wat file to .wasm')] +wat program: + wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o upload.wasm {{program}} + + +## Build + +has(flags, flag) := if flags =~ ('(^| )' + flag + '($| )') { "true" } else { "false" } + +extract(flags) := trim( + (if has(flags, "debug") == "true" { "-DDEBUG" } else { "" }) + " " + + (if has(flags, "trace") == "true" { "-DTRACE" } else { "" }) +) + +cmake(flags) := ( + if extract(flags) == "" { + "" + } else { + '-DCMAKE_CXX_FLAGS="' + extract(flags) + '"' + } +) + +[group('build')] +[doc('Build runtime for any platform (flags: debug, trace)')] +build platform *flags: (emulator flags) + +[group('build')] +[working-directory: 'build-emu'] +[doc('Platform: emulator')] +emulator *flags: _mkdir + cmake .. -D BUILD_EMULATOR=ON {{cmake(flags)}} + make + +[group('build')] +[working-directory: 'platforms/zephyr'] +[doc('Platform: zephir')] +zephir *flags: _zephir + ls + + +## Flash +[group('exec')] +[doc('Flash/execute platform')] +flash platform: cli + + +[group('exec')] +[doc('Run command-line interface')] +cli: + ./build-emu/wdcli + + +## Setup + +[group('setup')] +[doc('Setup toolchains & platforms')] +setup platform: _setup-emulator + +[group('setup')] +[doc('Setup: emulator')] +_setup-emulator: + git submodule update --init --recursive + +[group('lint')] +[doc('Lint src folder')] +lint: + clang-format -i src/**/* + + +## Private recipes + +# make build folder +_mkdir: + mkdir -p build-emu + +# activate zephyr environment +_zephir: + source ~/zephyrproject/.venv/bin/activate + source ~/zephyrproject/zephyr/zephyr-env.sh + From 0a1f3692b7ab104de737864b946dd6f5ab603499 Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Thu, 9 Jul 2026 07:26:54 +0200 Subject: [PATCH 2/5] Fix justfile for emulator and zephyr --- justfile | 58 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/justfile b/justfile index 07a682ac..54746b07 100644 --- a/justfile +++ b/justfile @@ -1,17 +1,17 @@ set unstable - default: just --list ## Run + [group('run')] [doc('Run program on any platform (rebuilds)')] run platform program: - stage {{program}} - build {{platform}} - flash {{platform}} + just stage {{program}} + just build {{platform}} + just flash {{platform}} upload.wasm ## Stage @@ -46,32 +46,38 @@ cmake(flags) := ( [group('build')] [doc('Build runtime for any platform (flags: debug, trace)')] -build platform *flags: (emulator flags) +build platform *flags: + just {{platform}} {{flags}} [group('build')] [working-directory: 'build-emu'] [doc('Platform: emulator')] -emulator *flags: _mkdir +emulator *flags: _mkdir-emu cmake .. -D BUILD_EMULATOR=ON {{cmake(flags)}} make [group('build')] -[working-directory: 'platforms/zephyr'] -[doc('Platform: zephir')] -zephir *flags: _zephir - ls +[doc('Platform: zephyr')] +zephyr *flags='-b esp32_devkitc_wroom/esp32/procpu': + just _zephyr "west build {{flags}}" ## Flash + [group('exec')] [doc('Flash/execute platform')] -flash platform: cli +flash platform program *flags: + just _flash_{{platform}} {{program}} {{flags}} + +_flash_zephyr program *flags: + just _zephyr "west flash {{flags}}" +_flash_emulator program *flags: (cli program flags) [group('exec')] [doc('Run command-line interface')] -cli: - ./build-emu/wdcli +cli program *flags: + ./build-emu/wdcli {{program}} {{flags}} ## Setup @@ -90,15 +96,33 @@ _setup-emulator: lint: clang-format -i src/**/* +## Tests + +[group('test')] +[doc('Run unit tests')] +test: _mkdir-doctest _build-doctest + ctest --test-dir ./build-doctest --output-on-failure + ## Private recipes # make build folder -_mkdir: +_mkdir-emu: mkdir -p build-emu -# activate zephyr environment -_zephir: +# make build folder +_mkdir-doctest: + mkdir -p build-doctest + +_build-doctest: + cmake -B ./build-doctest -D BUILD_UNITTEST=ON + cmake --build ./build-doctest 2>/dev/null + +# activate zephyr environment and run a command in it +[working-directory: 'platforms/Zephyr'] +[script("bash")] +_zephyr +cmd: + set -euo pipefail source ~/zephyrproject/.venv/bin/activate source ~/zephyrproject/zephyr/zephyr-env.sh - + {{cmd}} From 2dc84aa80a8ff2a826ed422c76eef1a81ab3aa2b Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Thu, 9 Jul 2026 10:17:37 +0200 Subject: [PATCH 3/5] Add latch tests to justfile --- justfile | 37 +++++++++++++++++++++++++++++++++---- tests/latch/package.json | 10 ++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/justfile b/justfile index 54746b07..d4e211b5 100644 --- a/justfile +++ b/justfile @@ -27,6 +27,13 @@ wat program: wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o upload.wasm {{program}} +## Clean + +[group('clean')] +[doc('Clean build folders')] +clean: + rm -rf build-emu build-doctest build + ## Build has(flags, flag) := if flags =~ ('(^| )' + flag + '($| )') { "true" } else { "false" } @@ -53,8 +60,8 @@ build platform *flags: [working-directory: 'build-emu'] [doc('Platform: emulator')] emulator *flags: _mkdir-emu - cmake .. -D BUILD_EMULATOR=ON {{cmake(flags)}} - make + cmake .. -D BUILD_EMULATOR=ON {{cmake(flags)}} -G Ninja + ninja [group('build')] [doc('Platform: zephyr')] @@ -98,11 +105,33 @@ lint: ## Tests +[group('test')] +[doc('Run tests')] +test level='all': + just {{level}} + [group('test')] [doc('Run unit tests')] -test: _mkdir-doctest _build-doctest +unit: _mkdir-doctest _build-doctest ctest --test-dir ./build-doctest --output-on-failure +[group('test')] +[doc('Run spec tests')] +[working-directory: 'tests/latch/'] +spec: + WABT="../../lib/wabt/build/" npm run tests:spec + +[group('test')] +[doc('Run integration tests')] +[working-directory: 'tests/latch/'] +integration: + WABT="../../lib/wabt/build/" npm run tests:integration + +[group('test')] +[doc('Run integration tests')] +[working-directory: 'tests/latch/'] +all: + WABT="../../lib/wabt/build/" npm run tests:all ## Private recipes @@ -115,7 +144,7 @@ _mkdir-doctest: mkdir -p build-doctest _build-doctest: - cmake -B ./build-doctest -D BUILD_UNITTEST=ON + cmake -B ./build-doctest -D BUILD_UNITTEST=ON -G Ninja cmake --build ./build-doctest 2>/dev/null # activate zephyr environment and run a command in it diff --git a/tests/latch/package.json b/tests/latch/package.json index 42c2a6db..88548ae4 100644 --- a/tests/latch/package.json +++ b/tests/latch/package.json @@ -2,10 +2,12 @@ "name": "warduino-testsuite", "version": "1.0.0", "scripts": { - "debugtest": "npx ts-node ./src/debugger.test.ts", - "primtest": "npx ts-node ./src/primitives.test.ts", - "spectest": "npx ts-node ./src/spec.test.ts", - "comptest": "npx ts-node ./src/comp.test.ts" + "tests:debug": "npx ts-node ./src/debugger.test.ts", + "tests:prim": "npx ts-node ./src/primitives.test.ts", + "tests:spec": "npx ts-node ./src/spec.test.ts", + "tests:comp": "npx ts-node ./src/comp.test.ts", + "tests:integration": "npm run tests:debug ; npm run tests:prim", + "tests:all": "npm run tests:spec ; npm run tests:integration" }, "devDependencies": { "latch": "file:./latch-0.6.0.tgz", From 8300ac6171e7a3ac096665e264fe9384f8f5a075 Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Thu, 9 Jul 2026 11:23:59 +0200 Subject: [PATCH 4/5] Fix GitHub test actions --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 248b914f..8994a650 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,7 +80,7 @@ jobs: working-directory: tests/latch/ - name: Run Latch - run: npm run spectest + run: npm run tests:spec working-directory: tests/latch/ # Stage 3: end-to-end testing of primitives and debugger @@ -135,7 +135,7 @@ jobs: working-directory: tests/latch/ - name: Run Latch - run: npm run primtest + run: npm run tests:prim working-directory: tests/latch/ debugtests: @@ -188,6 +188,6 @@ jobs: working-directory: tests/latch/ - name: Run Latch - run: npm run debugtest + run: npm run tests:debug working-directory: tests/latch/ From ef6f160454a8af22285000bb8c477331cbfeaed8 Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Thu, 9 Jul 2026 14:36:25 +0200 Subject: [PATCH 5/5] Add quickstart to README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 24e675d9..9eb4a854 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,15 @@ This project is released under the Mozilla Public License 2.0, and is being deve > [!WARNING] > WARDuino is not 1.0, since this is an active research project. Expect possible bugs or performance issues. +## Quick start + +If you use just, the most common project commands are collected in the justfile. +To run the virtual machine locally (emulator) for the first time, use: + +``` +just setup ; just run emulator tutorials/wat/main/fac.wat +``` + ## Build and Development Instructions > [!NOTE]