[dart2wasm] Add --extra-compiler-option to dart compile wasm command

By allowing a pass-through of arbitrary arguments to the dart2wasm
compiler we allow flutter to use options which

* aren't relevant for end-users of `dart compile wasm`
  (e.g. such as providing different platform dill file)

* we may break at any point in time (though in coordination with
  flutter)

Issue https://github.com/dart-lang/sdk/issues/54675

Change-Id: I7da2b69a8c642f8bfaa6546bf9c1a6c3833d55fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349720
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2024-02-01 15:30:39 +00:00 committed by Commit Queue
parent 24eb977761
commit 83b7a57ef3

View file

@ -516,6 +516,12 @@ class CompileWasmCommand extends CompileSubcommandCommand {
valueHelp: 'page count',
hide: !verbose,
)
..addMultiOption(
'extra-compiler-option',
abbr: 'E',
help: 'An extra option to pass to the dart2wasm compiler.',
hide: !verbose,
)
..addOption(
'optimization-level',
abbr: 'O',
@ -590,6 +596,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
final sdkPath = path.absolute(sdk.sdkPath);
final packages = args[packagesOption.flag];
final defines = args[defineOption.flag] as List<String>;
final extraCompilerOptions = args['extra-compiler-option'] as List<String>;
int? maxPages;
if (args['shared-memory'] != null) {
@ -632,6 +639,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
// Then we pass flags that were opted into explicitly.
if (args['name-section']) '--name-section',
if (args['minify']) '--minify',
...extraCompilerOptions,
path.absolute(sourcePath),
outputFile,