From 83b7a57ef3b3282a477c5a856d4fe8507def7f3d Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Thu, 1 Feb 2024 15:30:39 +0000 Subject: [PATCH] [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 Commit-Queue: Martin Kustermann --- pkg/dartdev/lib/src/commands/compile.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/dartdev/lib/src/commands/compile.dart b/pkg/dartdev/lib/src/commands/compile.dart index a084e497714..14ecd6bb9e4 100644 --- a/pkg/dartdev/lib/src/commands/compile.dart +++ b/pkg/dartdev/lib/src/commands/compile.dart @@ -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; + final extraCompilerOptions = args['extra-compiler-option'] as List; 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,