-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathjustfile
More file actions
201 lines (145 loc) Β· 4.13 KB
/
Copy pathjustfile
File metadata and controls
201 lines (145 loc) Β· 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
set unstable
set default-list := true
## Run
[group('run')]
[doc('Run program on any platform (rebuilds)')]
run platform program:
just stage {{program}}
just build {{platform}}
just flash {{platform}} upload.wasm
just monitor {{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}}
## Clean
[group('clean')]
[doc('Clean build folders')]
clean:
rm -rf build-emu build-doctest build
[group('clean')]
[doc('Clean tests folders')]
clean-tests:
rm -rf tests/latch/node-modules
[group('clean')]
[doc("Hard reset repository")]
[confirm("Clean all generated files and Git data?")]
reset: clean clean-tests _prune
## 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:
just {{platform}} {{flags}}
[group('build')]
[doc('Platform: emulator')]
emulator *flags:
cmake -S . -B build-emu -D BUILD_EMULATOR=ON {{cmake(flags)}} -G Ninja
cmake --build build-emu
[group('build')]
[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 program="upload.wasm" *flags:
just _flash_{{platform}} {{program}} {{flags}}
_flash_zephyr program *flags:
just _zephyr "west flash {{flags}}"
_flash_emulator program *flags='--socket 8119': (cli program flags)
[group('exec')]
[doc('Run command-line interface')]
cli program *flags:
./build-emu/wdcli {{program}} {{flags}}
## Monitor
[group('monitor')]
monitor platform port='8119':
just _monitor_{{platform}} {{port}}
[no-exit-message]
_monitor_emulator port='8119':
telnet localhost {{port}}
_monitor_zephyr port:
west espressif monitor
## Setup
[group('setup')]
[doc('Setup toolchains & platforms (target: emulator, tests)')]
setup target:
just _setup-{{target}}
[confirm('You are about to install nanopb using Homebrew. Proceed? [y/n]')]
_nanopb:
brew install nanopb
[group('setup')]
[doc('Setup: emulator')]
_setup-emulator: _nanopb
git submodule update --init --recursive
[working-directory: 'tests/latch/']
_setup-tests:
npm i
[group('lint')]
[doc('Lint src folder')]
[no-exit-message]
lint:
clang-format -i src/**/*
## Tests
[group('test')]
[doc('Run tests at level (unit, integration, spec, all)')]
test level='all':
just {{level}}
[group('test')]
unit: _mkdir-doctest _build-doctest
ctest --test-dir ./build-doctest --output-on-failure
[group('test')]
[working-directory: 'tests/latch/']
spec:
WABT="../../lib/wabt/build/" npm run tests:spec
[group('test')]
[working-directory: 'tests/latch/']
integration:
WABT="../../lib/wabt/build/" npm run tests:integration
[group('test')]
[working-directory: 'tests/latch/']
all:
WABT="../../lib/wabt/build/" npm run tests:all
## QoL / Maintenance
[group('maintenance')]
[doc('Run routine Git maintenance')]
maintain:
git maintenance run
[group('maintenance')]
[doc('Aggressively prune Git objects and stale remote refs')]
[confirm("GC git and delete stale files?")]
prune: _prune
_prune:
git maintenance run --task=gc
git remote prune origin
## Private recipes
# make build folder
_mkdir-doctest:
mkdir -p build-doctest
_build-doctest:
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
[working-directory: 'platforms/Zephyr']
[script("bash")]
_zephyr +cmd:
set -euo pipefail
source ~/zephyrproject/.venv/bin/activate
source ~/zephyrproject/zephyr/zephyr-env.sh
{{cmd}}