Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ecf6a663
Unverified
Commit
ecf6a663
authored
Apr 11, 2023
by
Kevin Moore
Committed by
GitHub
Apr 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add omit-type-checks flag for wasm builds (#124341)
Add omit-type-checks flag for wasm builds
parent
da767d99
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
15 deletions
+78
-15
web.dart
packages/flutter_tools/lib/src/build_system/targets/web.dart
+1
-0
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+15
-12
compiler_config.dart
packages/flutter_tools/lib/src/web/compiler_config.dart
+25
-2
web_test.dart
...ols/test/general.shard/build_system/targets/web_test.dart
+35
-0
compile_web_test.dart
...lutter_tools/test/general.shard/web/compile_web_test.dart
+2
-1
No files found.
packages/flutter_tools/lib/src/build_system/targets/web.dart
View file @
ecf6a663
...
...
@@ -274,6 +274,7 @@ class Dart2WasmTarget extends Dart2WebTarget {
...
decodeCommaSeparated
(
environment
.
defines
,
kExtraFrontEndOptions
),
for
(
final
String
dartDefine
in
decodeDartDefines
(
environment
.
defines
,
kDartDefines
))
'-D
$dartDefine
'
,
...
WasmCompilerConfig
.
fromBuildSystemEnvironment
(
environment
.
defines
).
toCommandOptions
(),
'--packages=.dart_tool/package_config.json'
,
'--dart-sdk=
$dartSdkPath
'
,
'--multi-root-scheme'
,
...
...
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
ecf6a663
...
...
@@ -97,18 +97,19 @@ class BuildWebCommand extends BuildSubCommand {
//
if
(
featureFlags
.
isFlutterWebWasmEnabled
)
{
argParser
.
addSeparator
(
'Experimental options'
);
argParser
.
addFlag
(
FlutterOptions
.
kWebWasmFlag
,
help:
'Compile to WebAssembly rather than JavaScript.
\n
See
$kWasmPreviewUri
for more information.'
,
negatable:
false
,
);
}
else
{
// Add the flag as hidden. Will give a helpful error message in [runCommand] below.
argParser
.
addFlag
(
FlutterOptions
.
kWebWasmFlag
,
hide:
true
,
);
}
argParser
.
addFlag
(
FlutterOptions
.
kWebWasmFlag
,
help:
'Compile to WebAssembly rather than JavaScript.
\n
See
$kWasmPreviewUri
for more information.'
,
negatable:
false
,
hide:
!
featureFlags
.
isFlutterWebWasmEnabled
,
);
argParser
.
addFlag
(
'omit-type-checks'
,
help:
'Omit type checks in Wasm output.'
,
negatable:
false
,
hide:
!
featureFlags
.
isFlutterWebWasmEnabled
,
);
}
final
FileSystem
_fileSystem
;
...
...
@@ -139,7 +140,9 @@ class BuildWebCommand extends BuildSubCommand {
if
(!
featureFlags
.
isFlutterWebWasmEnabled
)
{
throwToolExit
(
'Compiling to WebAssembly (wasm) is only available on the master channel.'
);
}
compilerConfig
=
const
WasmCompilerConfig
();
compilerConfig
=
WasmCompilerConfig
(
omitTypeChecks:
boolArg
(
'omit-type-checks'
),
);
}
else
{
compilerConfig
=
JsCompilerConfig
(
csp:
boolArg
(
'csp'
),
...
...
packages/flutter_tools/lib/src/web/compiler_config.dart
View file @
ecf6a663
...
...
@@ -128,11 +128,34 @@ class JsCompilerConfig extends WebCompilerConfig {
/// Configuration for the Wasm compiler.
class
WasmCompilerConfig
extends
WebCompilerConfig
{
const
WasmCompilerConfig
();
const
WasmCompilerConfig
({
required
this
.
omitTypeChecks
,
});
/// Creates a new [WasmCompilerConfig] from build system environment values.
///
/// Should correspond exactly with [toBuildSystemEnvironment].
factory
WasmCompilerConfig
.
fromBuildSystemEnvironment
(
Map
<
String
,
String
>
defines
)
=>
WasmCompilerConfig
(
omitTypeChecks:
defines
[
kOmitTypeChecks
]
==
'true'
,
);
/// Build environment for [omitTypeChecks];
static
const
String
kOmitTypeChecks
=
'WasmOmitTypeChecks'
;
/// If `omit-type-checks` should be passed to `dart2wasm`.
final
bool
omitTypeChecks
;
@override
bool
get
isWasm
=>
true
;
@override
Map
<
String
,
String
>
toBuildSystemEnvironment
()
=>
const
<
String
,
String
>{};
Map
<
String
,
String
>
toBuildSystemEnvironment
()
=>
<
String
,
String
>{
kOmitTypeChecks:
omitTypeChecks
.
toString
(),
};
List
<
String
>
toCommandOptions
()
=>
<
String
>[
if
(
omitTypeChecks
)
'--omit-type-checks'
,
];
}
packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
View file @
ecf6a663
...
...
@@ -810,6 +810,41 @@ void main() {
ProcessManager:
()
=>
processManager
,
}));
test
(
'Dart2WasmTarget invokes dart2wasm with omit checks'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
WasmCompilerConfig
.
kOmitTypeChecks
]
=
'true'
;
final
File
depFile
=
environment
.
buildDir
.
childFile
(
'dart2wasm.d'
);
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
'bin/cache/dart-sdk/bin/dartaotruntime'
,
'--disable-dart-dev'
,
'bin/cache/dart-sdk/bin/snapshots/dart2wasm_product.snapshot'
,
'-Ddart.vm.product=true'
,
'--omit-type-checks'
,
'--packages=.dart_tool/package_config.json'
,
'--dart-sdk=bin/cache/dart-sdk'
,
'--multi-root-scheme'
,
'org-dartlang-sdk'
,
'--multi-root'
,
'bin/cache/flutter_web_sdk'
,
'--multi-root'
,
'bin/cache'
,
'--libraries-spec'
,
'bin/cache/flutter_web_sdk/libraries.json'
,
'--depfile=
${depFile.absolute.path}
'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'main.dart.wasm'
).
absolute
.
path
,
])
);
await
Dart2WasmTarget
(
WebRendererMode
.
canvaskit
).
build
(
environment
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
}));
test
(
'Dart2WasmTarget with skwasm renderer adds extra flags'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
final
File
depFile
=
environment
.
buildDir
.
childFile
(
'dart2wasm.d'
);
...
...
packages/flutter_tools/test/general.shard/web/compile_web_test.dart
View file @
ecf6a663
...
...
@@ -45,6 +45,7 @@ void main() {
'TargetFile'
:
'target'
,
'HasWebPlugins'
:
'false'
,
'ServiceWorkerStrategy'
:
'serviceWorkerStrategy'
,
'WasmOmitTypeChecks'
:
'false'
,
'BuildMode'
:
'debug'
,
'DartObfuscation'
:
'false'
,
'TrackWidgetCreation'
:
'true'
,
...
...
@@ -68,7 +69,7 @@ void main() {
'target'
,
BuildInfo
.
debug
,
'serviceWorkerStrategy'
,
compilerConfig:
const
WasmCompilerConfig
(),
compilerConfig:
const
WasmCompilerConfig
(
omitTypeChecks:
false
),
);
expect
(
logger
.
statusText
,
contains
(
'Compiling target for the Web...'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment