Skip to content

Commit

Permalink
[dart2wasm] Make dart compile wasm understand not to generate sourc…
Browse files Browse the repository at this point in the history
…e maps on --no-source-maps as well as --extra-compiler-option=--no-source-maps

When `flutter build web --wasm` run passed
`--extra-compiler-option=--no-source-maps` it caused the compiler not to
generate source maps, but `dart compile wasm` thought it does and tried
and use the file, which causses an issue.

We can remove this workaround once this CL rolls up to flutter and we
change `--extra-compiler-option=--no-source-maps` to `--no-source-maps`.

Bug: flutter/engine#54487
Change-Id: I82c56ab7d1bc09e53919a6b72b0b1771215d8d25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380000
Reviewed-by: Ömer Ağacan <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
  • Loading branch information
mkustermann authored and Commit Queue committed Aug 12, 2024
1 parent 0d68349 commit 075c443
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/dartdev/lib/src/commands/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@ class CompileWasmCommand extends CompileSubcommandCommand {
hide: !verbose,
)
..addFlag(
'no-source-maps',
help: 'Do not generate a source map file.',
negatable: false,
'source-maps',
help: 'Generate a source map file.',
defaultsTo: true,
)
..addOption(
packagesOption.flag,
Expand Down Expand Up @@ -809,6 +809,13 @@ class CompileWasmCommand extends CompileSubcommandCommand {
handleOverride(optimizationFlags, 'minify',
args.wasParsed('minify') ? args.flag('minify') : null);

bool generateSourceMap = args.flag('source-maps');
// TODO(kustermann): Remive this temporary change when flutter no longer
// uses --extra-compiler-option=--no-source-maps
if (extraCompilerOptions.any((o) => o == '--no-source-maps')) {
generateSourceMap = false;
}

final enabledExperiments = args.enabledExperiments;
final dart2wasmCommand = [
sdk.dartAotRuntime,
Expand All @@ -819,7 +826,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
if (args.flag('print-wasm')) '--print-wasm',
if (args.flag('print-kernel')) '--print-kernel',
if (args.flag('enable-asserts')) '--enable-asserts',
if (args.flag('no-source-maps')) '--no-source-maps',
if (!generateSourceMap) '--no-source-maps',
for (final define in defines) '-D$define',
if (maxPages != null) ...[
'--import-shared-memory',
Expand Down Expand Up @@ -849,7 +856,6 @@ class CompileWasmCommand extends CompileSubcommandCommand {
}

final bool strip = args.flag('strip-wasm');
final bool generateSourceMap = !args.flag('no-source-maps');

if (runWasmOpt) {
final unoptFile = '$outputFileBasename.unopt.wasm';
Expand Down

0 comments on commit 075c443

Please sign in to comment.