mirror of
https://github.com/flutter/flutter
synced 2024-09-13 05:11:45 +00:00
[web] Make flutter web profile builds always keep wasm symbols (#144130)
So far `flutter build web --wasm` was always stripping wasm symbols except if `--no-strip-wasm` is passed. => Ensure that in profile mode we also keep the symbols
This commit is contained in:
parent
871d59221c
commit
616a0260fe
|
@ -196,8 +196,7 @@ class Dart2JSTarget extends Dart2WebTarget {
|
||||||
throwOnError: true,
|
throwOnError: true,
|
||||||
<String>[
|
<String>[
|
||||||
...sharedCommandOptions,
|
...sharedCommandOptions,
|
||||||
if (buildMode == BuildMode.profile) '--no-minify',
|
...compilerConfig.toCommandOptions(buildMode),
|
||||||
...compilerConfig.toCommandOptions(),
|
|
||||||
'-o',
|
'-o',
|
||||||
outputJSFile.path,
|
outputJSFile.path,
|
||||||
environment.buildDir.childFile('app.dill').path, // dartfile
|
environment.buildDir.childFile('app.dill').path, // dartfile
|
||||||
|
@ -279,7 +278,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
|
||||||
'-D$dartDefine',
|
'-D$dartDefine',
|
||||||
'--extra-compiler-option=--depfile=${depFile.path}',
|
'--extra-compiler-option=--depfile=${depFile.path}',
|
||||||
|
|
||||||
...compilerConfig.toCommandOptions(),
|
...compilerConfig.toCommandOptions(buildMode),
|
||||||
'-o',
|
'-o',
|
||||||
outputWasmFile.path,
|
outputWasmFile.path,
|
||||||
environment.buildDir.childFile('main.dart').path, // dartfile
|
environment.buildDir.childFile('main.dart').path, // dartfile
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import '../build_info.dart' show BuildMode;
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
import 'compile.dart';
|
import 'compile.dart';
|
||||||
|
|
||||||
|
@ -106,7 +107,8 @@ class JsCompilerConfig extends WebCompilerConfig {
|
||||||
/// Arguments to use in the full JS compile, but not CFE-only.
|
/// Arguments to use in the full JS compile, but not CFE-only.
|
||||||
///
|
///
|
||||||
/// Includes the contents of [toSharedCommandOptions].
|
/// Includes the contents of [toSharedCommandOptions].
|
||||||
List<String> toCommandOptions() => <String>[
|
List<String> toCommandOptions(BuildMode buildMode) => <String>[
|
||||||
|
if (buildMode == BuildMode.profile) '--no-minify',
|
||||||
...toSharedCommandOptions(),
|
...toSharedCommandOptions(),
|
||||||
'-O$optimizationLevel',
|
'-O$optimizationLevel',
|
||||||
if (dumpInfo) '--dump-info',
|
if (dumpInfo) '--dump-info',
|
||||||
|
@ -145,10 +147,11 @@ class WasmCompilerConfig extends WebCompilerConfig {
|
||||||
@override
|
@override
|
||||||
CompileTarget get compileTarget => CompileTarget.wasm;
|
CompileTarget get compileTarget => CompileTarget.wasm;
|
||||||
|
|
||||||
List<String> toCommandOptions() {
|
List<String> toCommandOptions(BuildMode buildMode) {
|
||||||
|
final bool stripSymbols = buildMode == BuildMode.release && stripWasm;
|
||||||
return <String>[
|
return <String>[
|
||||||
'-O$optimizationLevel',
|
'-O$optimizationLevel',
|
||||||
'--${stripWasm? 'no-' : ''}name-section',
|
'--${stripSymbols ? 'no-' : ''}name-section',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -904,8 +904,9 @@ void main() {
|
||||||
for (int level = 1; level <= 4; level++) {
|
for (int level = 1; level <= 4; level++) {
|
||||||
for (final bool strip in <bool>[true, false]) {
|
for (final bool strip in <bool>[true, false]) {
|
||||||
for (final List<String> defines in const <List<String>>[<String>[], <String>['FOO=bar', 'BAZ=qux']]) {
|
for (final List<String> defines in const <List<String>>[<String>[], <String>['FOO=bar', 'BAZ=qux']]) {
|
||||||
test('Dart2WasmTarget invokes dart2wasm with renderer=$renderer, -O$level, stripping=$strip, defines=$defines', () => testbed.run(() async {
|
for (final String buildMode in const <String>['profile', 'release']) {
|
||||||
environment.defines[kBuildMode] = 'release';
|
test('Dart2WasmTarget invokes dart2wasm with renderer=$renderer, -O$level, stripping=$strip, defines=$defines, modeMode=$buildMode', () => testbed.run(() async {
|
||||||
|
environment.defines[kBuildMode] = buildMode;
|
||||||
environment.defines[kDartDefines] = encodeDartDefines(defines);
|
environment.defines[kDartDefines] = encodeDartDefines(defines);
|
||||||
|
|
||||||
final File depFile = environment.buildDir.childFile('dart2wasm.d');
|
final File depFile = environment.buildDir.childFile('dart2wasm.d');
|
||||||
|
@ -918,7 +919,7 @@ void main() {
|
||||||
'--extra-compiler-option=--import-shared-memory',
|
'--extra-compiler-option=--import-shared-memory',
|
||||||
'--extra-compiler-option=--shared-memory-max-pages=32768',
|
'--extra-compiler-option=--shared-memory-max-pages=32768',
|
||||||
],
|
],
|
||||||
'-Ddart.vm.product=true',
|
'-Ddart.vm.${buildMode == 'release' ? 'product' : 'profile' }=true',
|
||||||
...defines.map((String define) => '-D$define'),
|
...defines.map((String define) => '-D$define'),
|
||||||
if (renderer == WebRendererMode.skwasm) ...<String>[
|
if (renderer == WebRendererMode.skwasm) ...<String>[
|
||||||
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
'-DFLUTTER_WEB_AUTO_DETECT=false',
|
||||||
|
@ -931,7 +932,7 @@ void main() {
|
||||||
],
|
],
|
||||||
'--extra-compiler-option=--depfile=${depFile.absolute.path}',
|
'--extra-compiler-option=--depfile=${depFile.absolute.path}',
|
||||||
'-O$level',
|
'-O$level',
|
||||||
if (strip) '--no-name-section' else '--name-section',
|
if (strip && buildMode == 'release') '--no-name-section' else '--name-section',
|
||||||
'-o',
|
'-o',
|
||||||
environment.buildDir.childFile('main.dart.wasm').absolute.path,
|
environment.buildDir.childFile('main.dart.wasm').absolute.path,
|
||||||
environment.buildDir.childFile('main.dart').absolute.path,
|
environment.buildDir.childFile('main.dart').absolute.path,
|
||||||
|
@ -955,6 +956,7 @@ void main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test('Generated service worker is empty with none-strategy', () => testbed.run(() {
|
test('Generated service worker is empty with none-strategy', () => testbed.run(() {
|
||||||
final String fileGeneratorsPath =
|
final String fileGeneratorsPath =
|
||||||
|
|
Loading…
Reference in a new issue