tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.51k stars 914 forks source link

tinygo: revise and simplify wasmtime argument handling #4555

Closed ydnar closed 4 weeks ago

ydnar commented 4 weeks ago

This PR implements 3 related changes to how TinyGo processes arguments for the wasmtime emulator. I ran across the issue related to trying to use wasmtime serve in a custom target file for my WasmCon talk next month.

It adds support for alternative wasmtime subcommands like serve, simplifies the Wasmtime-specific code paths, and fixes PWD handling for tinygo run when not running tests. I recommend reviewing by commit to see the individual changes.

Detailed changes:

dgryski commented 4 weeks ago

The isSingleFile logic was for cases where we did tinygo run some/dir/file.go to make sure the directories were set correctly. If that still works then these cleanups LGTM.

ydnar commented 4 weeks ago

Yes that still works.

The equivalent tinygo run ./cmd/foo also works now (without specifying main.go).