The non-json compile functions exposed by VVM do not expose an interface for passing additional compiler flags to vyper when invoked.
This functinality, along with conversion of flags like "foo_bar" into "--foo-bar", is already implemented in vvm's wrapper module.
this PR simply passes along any uncaptured kwargs passed to compile or compile_files to enable specific use-cases.
because flags may be inconsistent across vyper versions, validation is left out of scope here. we're not offering options to the user, just letting them pass along ones they determine will be correct.
This currently does not support every case. There are some flags which we can pass that result in invalid json being output, which vvm will fail to parse. However this unblocks cases that do work (namely, building just the AST, for vyper-lsp performance)
How I did it
added kwargs to compile and compile_files, and passed that arg to the call to vyper.vyper_wrapper(..)
if the f kwarg is present, we handle it specially, since we were hardcoding that to combined_json
There are some values for f that result in invalid JSON output from the compiler. This is currently as designed, but maybe should change. Perhaps if you want json you need to use vyper-json, but currently some output formats from plain vyper are valid JSON and others are not.
I added error handling for whenever a user specifies an output format that is not valid JSON. This will catch errors from any flags that result in non-JSON output.
Whether we should only use vyper-json when we need JSON output (therefore all of VVM should switch to only using vyper-json is another question to be discussed, but this enables AST construction with the fewest changes while we determine the best way forward.
What I did
The non-json compile functions exposed by VVM do not expose an interface for passing additional compiler flags to
vyper
when invoked.This functinality, along with conversion of flags like "foo_bar" into "--foo-bar", is already implemented in vvm's wrapper module.
this PR simply passes along any uncaptured kwargs passed to
compile
orcompile_files
to enable specific use-cases.because flags may be inconsistent across vyper versions, validation is left out of scope here. we're not offering options to the user, just letting them pass along ones they determine will be correct.
This currently does not support every case. There are some flags which we can pass that result in invalid json being output, which vvm will fail to parse. However this unblocks cases that do work (namely, building just the AST, for vyper-lsp performance)
How I did it
added kwargs to
compile
andcompile_files
, and passed that arg to the call tovyper.vyper_wrapper(..)
if the
f
kwarg is present, we handle it specially, since we were hardcoding that tocombined_json
There are some values for
f
that result in invalid JSON output from the compiler. This is currently as designed, but maybe should change. Perhaps if you want json you need to usevyper-json
, but currently some output formats from plainvyper
are valid JSON and others are not.I added error handling for whenever a user specifies an output format that is not valid JSON. This will catch errors from any flags that result in non-JSON output.
Whether we should only use
vyper-json
when we need JSON output (therefore all of VVM should switch to only usingvyper-json
is another question to be discussed, but this enables AST construction with the fewest changes while we determine the best way forward.How to verify it
pip install git+https://github.com/z80dev/vvm@pass-flags
Checklist