Conversation
bitwalker
left a comment
There was a problem hiding this comment.
I was imagining the handling of arguments would work more like so:
- Add options we want to recognize as build options for
cargoto the set ofmidencoptions, e.g.--release. Thusmidenc's options are a superset of thecargooptions we want to support. - Capture all arguments after
cargo miden buildas aVec<OsString>/Vec<String>, and useCompiler::try_parse(&args)to parse those arguments into themidenccompiler options (IIRCtry_parseis the correct method ofclap::Parser, but I'd have to check the docs to know, in any case, you get the gist). - Override any of the
Compileroptions directly, as you see fit/as needed bycargo miden build, rather than trying to parse/modify the raw argument vector. - Extract any
cargo-specific options we want to forward tocargofrom theCompileroptions when invokingcargo
That will be far simpler than the approach here IMO.
NOTE: With my PR that switches to miden-vm v0.18, I've also simplified the midenc-driver interface significantly (i.e. the subcommand handling is gone, and midenc is equivalent to the previous midenc compile). That has made instantiating the driver significantly simpler as well, so we could base this PR on that branch instead to take advantage of that, since we should be able to merge the v0.18 upgrade this week.
I did not think about this. I like the idea. Besides
Sure. Do you mean this one - #681? It looks stale. |
|
@bitwalker In our discussion elsewhere I mentioned the |
|
@greenhat I think that's fine, let's make them first-class options then, perhaps just decorated with |
c81da7e to
78e5faa
Compare
…ough the `midenc` compiler's `Compiler` struct instead of using a separate custom argument parser. This adds hidden cargo-specific options (`--release`, `--manifest-path`, `--workspace`, `--package`) to the `Compiler` struct in `midenc-compile`, which are recognized by `cargo miden build` and forwarded to the underlying `cargo build` invocation. The midenc options (currently only `--emit`) are passed to the compilation stage.
8c54950 to
b1ca983
Compare
|
Done. Ready for review. |
Close #320
This PR refactors
cargo miden buildto parse all command-line arguments through themidenccompiler'sCompilerstruct instead of using a separate custom argument parser. This adds hidden cargo-specific options (--release,--manifest-path,--workspace,--package) to theCompilerstruct inmidenc-compile, which are recognized bycargo miden buildand forwarded to the underlyingcargo buildinvocation. The midenc options (currently only--emit) are passed to the compilation stage.Note: When the
--emitoption is passed it is ignored sincecargo-midenuses the-ooption for the Miden package file and it overrides the--emit. See created #724 for details. I'd like to tackle it separately since this PR is about options passthrough.