Allow passing args directly to Scala Native CLI
Is your feature request related to a problem? Please describe.
- Scala Native compilation pipeline delegates most of the work to scala-native-cli
- Invoking scala-native-cli manually is a pain
- scala-native-cli supports a much richer set of flags than Scala CLI's wrapper (e.g. dump flag is useful: https://github.com/scala-native/scala-native-cli/blob/main/cli/src/main/scala/scala/scalanative/cli/options/NativeConfigOptions.scala#L98-L102, and stuff around optimisations and source level debugging)
- Painstakingly porting and maintaing every single flag in Scala CLI is a slow process
Describe the solution you'd like
I propose adding a --native-cli-opt <flag-value> repeated option that allows passing <flag-value> directly to scala-native-cli.
The option can be marked as hidden as it's considered advanced usage.
Describe alternatives you've considered
Porting flags one by one – requires keeping CLIs in sync and slows down everyone.
Additional context
N/A
Thanks for reporting! @Gedochao will have most background here, but he is out this week.
We could support it similar to how we do Scala compiler options with -O, sure... but similar to that, it would require the same amount of extra fluff to detect duplicates with the existing options. Doable, but requires a bit of effort to both implement and maintain.
Alternatively, we could maybe depend on scala-native-cli somehow, if the command line options were exposed as an API (or perhaps via a common dependency), so that new options are immediately supported when we bump Scala Native? @WojciechMazur is that something worth considering?
AFAIK the scala-cli does not use scala-native-cli API but instead uses it as command line so that there is no issues with binary compatibility. The scala-native-cli itself has no other dependencies beside the Scala Native toolchain itself. So the API approach might not be trivial
However, becouse currently it's used a command line, we can add command lines that would be available since next sn-cli. Currently we're using scopt which I belive does not have builtin option to do it (beside using --help and parsing the stdout) but we might consider adjusting the code to automatically register available settings names and make them available as command output, eg. in JSON format. This can be consumed if available (when using SN 0.5.7+) or ignored by scala-cli otherwise