From 2d890a407f094d46d4d0a4f8052dc5c37ca53614 Mon Sep 17 00:00:00 2001 From: Kenzie Davisson <43759233+kenzieschmoll@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:19:41 +0000 Subject: [PATCH] Add `--no-strip-wasm` flag support to build and serve commands. --- tool/lib/commands/build.dart | 11 +++++++---- tool/lib/commands/serve.dart | 4 ++++ tool/lib/commands/shared.dart | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tool/lib/commands/build.dart b/tool/lib/commands/build.dart index ec0c8c82b5e..8668ee2b2d3 100644 --- a/tool/lib/commands/build.dart +++ b/tool/lib/commands/build.dart @@ -44,7 +44,8 @@ class BuildCommand extends Command { ..addUpdatePerfettoFlag() ..addPubGetFlag() ..addBulidModeOption() - ..addWasmFlag(); + ..addWasmFlag() + ..addNoStripWasmFlag(); } @override @@ -65,6 +66,7 @@ class BuildCommand extends Command { final runPubGet = results[BuildCommandArgs.pubGet.flagName] as bool; final buildMode = results[BuildCommandArgs.buildMode.flagName] as String; final useWasm = results[BuildCommandArgs.wasm.flagName] as bool; + final noStripWasm = results[BuildCommandArgs.noStripWasm.flagName] as bool; final webBuildDir = Directory(path.join(repo.devtoolsAppDirectoryPath, 'build', 'web')); @@ -99,9 +101,10 @@ class BuildCommand extends Command { [ 'build', 'web', - if (useWasm) - '--wasm' - else ...[ + if (useWasm) ...[ + BuildCommandArgs.wasm.asArg(), + if (noStripWasm) BuildCommandArgs.noStripWasm.asArg(), + ] else ...[ '--web-renderer', 'canvaskit', // Do not minify stack traces in debug mode. diff --git a/tool/lib/commands/serve.dart b/tool/lib/commands/serve.dart index 15a7f9e6280..aedb948717e 100644 --- a/tool/lib/commands/serve.dart +++ b/tool/lib/commands/serve.dart @@ -80,6 +80,7 @@ class ServeCommand extends Command { ..addPubGetFlag() ..addBulidModeOption() ..addWasmFlag() + ..addNoStripWasmFlag() // Flags defined in the server in DDS. ..addFlag( _machineFlag, @@ -129,6 +130,7 @@ class ServeCommand extends Command { final updatePerfetto = results[BuildCommandArgs.updatePerfetto.flagName] as bool; final useWasm = results[BuildCommandArgs.wasm.flagName] as bool; + final noStripWasm = results[BuildCommandArgs.noStripWasm.flagName] as bool; final runPubGet = results[BuildCommandArgs.pubGet.flagName] as bool; final devToolsAppBuildMode = results[BuildCommandArgs.buildMode.flagName] as String; @@ -140,6 +142,7 @@ class ServeCommand extends Command { ..remove(BuildCommandArgs.updateFlutter.asArg(negated: true)) ..remove(BuildCommandArgs.updatePerfetto.asArg()) ..remove(BuildCommandArgs.wasm.asArg()) + ..remove(BuildCommandArgs.noStripWasm.asArg()) ..remove(valueAsArg(_buildAppFlag)) ..remove(valueAsArg(_buildAppFlag, negated: true)) ..remove(valueAsArg(_debugServerFlag)) @@ -179,6 +182,7 @@ class ServeCommand extends Command { BuildCommandArgs.updateFlutter.asArg(negated: !updateFlutter), if (updatePerfetto) BuildCommandArgs.updatePerfetto.asArg(), if (useWasm) BuildCommandArgs.wasm.asArg(), + if (noStripWasm) BuildCommandArgs.noStripWasm.asArg(), '${BuildCommandArgs.buildMode.asArg()}=$devToolsAppBuildMode', BuildCommandArgs.pubGet.asArg(negated: !runPubGet), ]), diff --git a/tool/lib/commands/shared.dart b/tool/lib/commands/shared.dart index 117fda56fe3..4be852ba3e3 100644 --- a/tool/lib/commands/shared.dart +++ b/tool/lib/commands/shared.dart @@ -58,12 +58,24 @@ extension BuildCommandArgsExtension on ArgParser { help: 'Whether to build DevTools with dart2wasm instead of dart2js.', ); } + + void addNoStripWasmFlag() { + addFlag( + BuildCommandArgs.noStripWasm.flagName, + defaultsTo: false, + help: + 'When this flag is present, static symbol names will be included in ' + 'the resulting wasm file. This flag is ignored if the --wasm flag is ' + 'not present.', + ); + } } enum BuildCommandArgs { buildMode('build-mode'), pubGet('pub-get'), wasm('wasm'), + noStripWasm('no-strip-wasm'), updateFlutter('update-flutter'), updatePerfetto('update-perfetto');