|
5 | 5 | [tools] |
6 | 6 | uv = "latest" |
7 | 7 | "pipx:reuse" = "latest" |
8 | | -protoc = "33.4" |
9 | | -protoc-gen-go = "1.36.11" |
10 | 8 | "aqua:tinygo-org/tinygo" = "0.40.1" |
11 | 9 | "github:firefly-zero/firefly-cli"= { version = "0.15.8", rename_exe = "ff" } |
12 | 10 | "github:firefly-zero/firefly-emulator" = "0.9.8" |
13 | | - |
14 | | -[tasks."install:tools"] |
15 | | -description = "Install protoc plugins" |
16 | | -run = "go install tool" |
17 | | - |
18 | | -[tasks."build:generate"] |
19 | | -# using https://github.com/aperturerobotics/protobuf-go-lite |
20 | | -description = "Generate protobuf files" |
21 | | -run = """ |
22 | | - : "${GOBIN:="$(go env GOBIN)"}" |
23 | | - : "${GOBIN:="$(go env GOPATH)/bin"}" |
24 | | - protoc \ |
25 | | - --go-lite_out=proto --plugin protoc-gen-go-lite="${GOBIN}/protoc-gen-go-lite" \ |
26 | | - --go-lite_opt=features=size+marshal+unmarshal \ |
27 | | - proto/game/v1/gamestate.proto |
28 | | -""" |
29 | | -sources = ['proto/game/v1/*.proto'] |
30 | | -outputs = ['proto/game/v1/*.go'] |
31 | | -depends = ['install:tools'] |
| 11 | +"github:wwwg/wasmdec" = "latest" |
| 12 | +golangci-lint = "2.8.0" |
32 | 13 |
|
33 | 14 | [tasks.build] |
34 | 15 | description = "Build the game using firefly CLI" |
35 | 16 | run = "ff build" |
36 | | -depends = ['build:generate'] |
37 | 17 |
|
38 | | -[tasks."build:print-allocs"] |
| 18 | +[tasks."debug:print-allocs"] |
39 | 19 | description = "Build with tinygo and print allocations" |
40 | 20 | run = """ |
41 | | - tinygo build -print-allocs "$(basename "$PWD")|firefly-go" -buildmode c-shared -target target.json -o /dev/null \ |
| 21 | + tinygo build -print-allocs "$(basename "$PWD")|firefly-go|.*" -buildmode c-shared -target target.json -o /dev/null \ |
42 | 22 | 2>&1 | sed "s|^$PWD/|./|; s|^$HOME/|~/|" |
43 | 23 | """ |
44 | 24 |
|
| 25 | +[tasks."debug:build:tinygo"] |
| 26 | +description = "Build with tinygo" |
| 27 | +run = """ |
| 28 | + tinygo build -target target.json -buildmode c-shared -o dist/ewfg.wasm . |
| 29 | +""" |
| 30 | +sources = ['**/*.go', 'go.mod', 'go.sum', 'assets/**'] |
| 31 | +outputs = ['dist/ewfg.wasm'] |
| 32 | + |
| 33 | +[tasks."debug:build:opt"] |
| 34 | +description = """ |
| 35 | + Optimize the debug binary with wasm-opt |
| 36 | +
|
| 37 | + Basically the same command used by firefly-cli, but with extra `--debuginfo`. |
| 38 | + https://github.com/firefly-zero/firefly-cli/blob/6bfc4b02369577d5073145ea0c53a6168771907a/src/wasm.rs#L79-L99 |
| 39 | +""" |
| 40 | +run = """ |
| 41 | + wasm-opt \ |
| 42 | + -Oz \ |
| 43 | + --disable-exception-handling \ |
| 44 | + --disable-gc \ |
| 45 | + --disable-typed-function-references \ |
| 46 | + --enable-bulk-memory \ |
| 47 | + --enable-extended-const \ |
| 48 | + --enable-memory64 \ |
| 49 | + --enable-multivalue \ |
| 50 | + --enable-mutable-globals \ |
| 51 | + --enable-nontrapping-float-to-int \ |
| 52 | + --enable-reference-types \ |
| 53 | + --enable-relaxed-simd \ |
| 54 | + --enable-sign-ext \ |
| 55 | + --enable-simd \ |
| 56 | + --enable-tail-call \ |
| 57 | + -o dist/ewfg-opt.wasm \ |
| 58 | + --debuginfo \ |
| 59 | + dist/ewfg.wasm |
| 60 | +""" |
| 61 | +wait_for = ['debug:build:tinygo'] |
| 62 | +sources = ['dist/ewfg.wasm'] |
| 63 | +outputs = ['dist/ewfg-opt.wasm'] |
| 64 | + |
| 65 | +[tasks."debug:build"] |
| 66 | +description = "Build and optimize the game using wasm-opt (with debug symbols on)" |
| 67 | +depends = ['debug:build:tinygo', 'debug:build:opt'] |
| 68 | + |
| 69 | +[tasks."debug:wasm2wat"] |
| 70 | +description = "Build the game and output the WAT" |
| 71 | +run = """ |
| 72 | + wasm2wat dist/ewfg.wasm --output=dist/ewfg.wat |
| 73 | + wasm2wat dist/ewfg-opt.wasm --output=dist/ewfg-opt.wat |
| 74 | +""" |
| 75 | +depends = ['debug:build'] |
| 76 | +sources = ['dist/ewfg.wasm', 'dist/ewfg-opt.wasm'] |
| 77 | +outputs = ['dist/ewfg.wat', 'dist/ewfg-opt.wat'] |
| 78 | + |
| 79 | +[tasks."debug:wasm-decompile"] |
| 80 | +description = "Build the game and decompile into the .dcmp pseudo-language" |
| 81 | +run = """ |
| 82 | + wasm-decompile dist/ewfg.wasm --output=dist/ewfg.dcmp |
| 83 | + wasm-decompile dist/ewfg-opt.wasm --output=dist/ewfg-opt.dcmp |
| 84 | +""" |
| 85 | +depends = ['debug:build'] |
| 86 | +sources = ['dist/ewfg.wasm', 'dist/ewfg-opt.wasm'] |
| 87 | +outputs = ['dist/ewfg.dcmp', 'dist/ewfg-opt.dcmp'] |
| 88 | + |
45 | 89 | [tasks.start] |
46 | 90 | description = "Run the game using firefly emulator" |
47 | 91 | run = "firefly-emulator --id applejag.ewfg" |
|
0 commit comments