-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tinygo: revise and simplify wasmtime argument handling #4555
Conversation
- Use wasmtime run subcommand instead of bare wasmtime. This enables use of wasmtime serve or other subcommands. - Simplify buildAndRun, condensing wasmtime handling into a single section handling env vars and dir args. - Only set PWD to the package dir if running tests, but not with tinygo run.
@@ -925,7 +927,7 @@ func buildAndRun(pkgName string, config *compileopts.Config, stdout io.Writer, c | |||
|
|||
// Run binary. | |||
if config.Options.PrintCommands != nil { | |||
config.Options.PrintCommands(cmd.Path, cmd.Args...) | |||
config.Options.PrintCommands(cmd.Path, cmd.Args[1:]...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running tinygo run -x ...
repeated the full path to wasmtime
and wasmtime
.
The |
Yes that still works. The equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.