Closed ydnar closed 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.
Yes that still works.
The equivalent tinygo run ./cmd/foo
also works now (without specifying main.go
).
This PR implements 3 related changes to how TinyGo processes arguments for the
wasmtime
emulator. I ran across the issue related to trying to usewasmtime serve
in a custom target file for my WasmCon talk next month.It adds support for alternative
wasmtime
subcommands likeserve
, simplifies the Wasmtime-specific code paths, and fixes PWD handling fortinygo run
when not running tests. I recommend reviewing by commit to see the individual changes.Detailed changes:
buildAndRun
, condensingwasmtime
handling into a single section handling--env
and--dir
args.wasmtime run
subcommand instead of barewasmtime
. This enables use ofwasmtime serve
or other subcommands. The key change is that emulator arguments are inserted after the subcommand, e.g.run
.PWD
to the package dir only when running tests, which allowstinygo run --target wasip1
to run withPWD=.
.-x
(PrintCommands
) where it repeated the full path and name of the command.