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
8872d1d8
Unverified
Commit
8872d1d8
authored
Mar 06, 2020
by
Jonah Williams
Committed by
GitHub
Mar 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Reland: supports tree-shake-icons for web builds (#52054)
parent
6ad807e3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
203 additions
and
147 deletions
+203
-147
.cirrus.yml
.cirrus.yml
+9
-1
icon_tree_shaker.dart
..._tools/lib/src/build_system/targets/icon_tree_shaker.dart
+2
-2
web.dart
packages/flutter_tools/lib/src/build_system/targets/web.dart
+29
-13
compile.dart
packages/flutter_tools/lib/src/web/compile.dart
+2
-2
web_test.dart
...ols/test/general.shard/build_system/targets/web_test.dart
+161
-129
No files found.
.cirrus.yml
View file @
8872d1d8
...
...
@@ -184,7 +184,15 @@ task:
-
bash <(curl -s https://codecov.io/bash) -c -f packages/flutter_tools/coverage/lcov.info -F flutter_tool
-
name
:
web_integration_tests
<<
:
*WEB_SHARD_TEMPLATE
only_if
:
"
changesInclude('.cirrus.yml',
'dev/**',
'packages/flutter/**',
'packages/flutter_test/**',
'packages/flutter_tools/**',
'packages/flutter_web_plugins/**',
'bin/internal/**')
||
$CIRRUS_PR
==
''"
environment
:
# As of October 2019, the Web shards needed more than 6G of RAM.
CPU
:
2
MEMORY
:
8G
CHROME_NO_SANDBOX
:
true
GOLD_SERVICE_ACCOUNT
:
ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
script
:
-
dart --enable-asserts ./dev/bots/test.dart
-
name
:
web_tests-0-linux
<<
:
*WEB_SHARD_TEMPLATE
...
...
packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart
View file @
8872d1d8
...
...
@@ -289,7 +289,7 @@ class IconTreeShaker {
for
(
final
Map
<
String
,
dynamic
>
iconDataMap
in
consts
.
constantInstances
)
{
if
((
iconDataMap
[
'fontPackage'
]
??
''
)
is
!
String
||
// Null is ok here.
iconDataMap
[
'fontFamily'
]
is
!
String
||
iconDataMap
[
'codePoint'
]
is
!
int
)
{
iconDataMap
[
'codePoint'
]
is
!
num
)
{
throw
IconTreeShakerException
.
_
(
'Invalid ConstFinder result. Expected "fontPackage" to be a String, '
'"fontFamily" to be a String, and "codePoint" to be an int, '
...
...
@@ -301,7 +301,7 @@ class IconTreeShaker {
?
family
:
'packages/
$package
/
$family
'
;
result
[
key
]
??=
<
int
>[];
result
[
key
].
add
(
iconDataMap
[
'codePoint'
]
as
int
);
result
[
key
].
add
(
(
iconDataMap
[
'codePoint'
]
as
num
).
round
()
);
}
return
result
;
}
...
...
packages/flutter_tools/lib/src/build_system/targets/web.dart
View file @
8872d1d8
...
...
@@ -156,9 +156,26 @@ class Dart2JSTarget extends Target {
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
String
specPath
=
globals
.
fs
.
path
.
join
(
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
),
'libraries.json'
);
final
String
packageFile
=
PackageMap
.
globalPackagesPath
;
final
File
outputKernel
=
environment
.
buildDir
.
childFile
(
'app.dill'
);
final
File
outputFile
=
environment
.
buildDir
.
childFile
(
'main.dart.js'
);
final
List
<
String
>
dartDefines
=
parseDartDefines
(
environment
);
final
ProcessResult
result
=
await
globals
.
processManager
.
run
(<
String
>[
// Run the dart2js compilation in two stages, so that icon tree shaking can
// parse the kernel file for web builds.
final
ProcessResult
kernelResult
=
await
globals
.
processManager
.
run
(<
String
>[
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
dart2jsSnapshot
),
'--libraries-spec=
$specPath
'
,
'-o'
,
outputKernel
.
path
,
'--packages=
$packageFile
'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
path
,
]);
if
(
kernelResult
.
exitCode
!=
0
)
{
throw
Exception
(
kernelResult
.
stdout
+
kernelResult
.
stderr
);
}
final
ProcessResult
javaScriptResult
=
await
globals
.
processManager
.
run
(<
String
>[
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
dart2jsSnapshot
),
'--libraries-spec=
$specPath
'
,
...
...
@@ -166,26 +183,25 @@ class Dart2JSTarget extends Target {
'-
$dart2jsOptimization
'
else
'-O4'
,
if
(
buildMode
==
BuildMode
.
profile
)
'--no-minify'
,
'-o'
,
outputFile
.
path
,
'--packages=
$packageFile
'
,
if
(
buildMode
==
BuildMode
.
profile
)
'-Ddart.vm.profile=true'
else
'-Ddart.vm.product=true'
,
for
(
final
String
dartDefine
in
dartDefines
)
'-D
$dartDefine
'
,
if
(
buildMode
==
BuildMode
.
profile
)
'--no-minify'
,
if
(
csp
)
'--csp'
,
for
(
final
String
dartDefine
in
parseDartDefines
(
environment
))
'-D
$dartDefine
'
,
environment
.
buildDir
.
childFile
(
'
main.dart
'
).
path
,
'-o'
,
outputFile
.
path
,
environment
.
buildDir
.
childFile
(
'
app.dill
'
).
path
,
]);
if
(
r
esult
.
exitCode
!=
0
)
{
throw
Exception
(
result
.
stdout
+
r
esult
.
stderr
);
if
(
javaScriptR
esult
.
exitCode
!=
0
)
{
throw
Exception
(
javaScriptResult
.
stdout
+
javaScriptR
esult
.
stderr
);
}
final
File
dart2jsDeps
=
environment
.
buildDir
.
childFile
(
'
main.dart.js
.deps'
);
.
childFile
(
'
app.dill
.deps'
);
if
(!
dart2jsDeps
.
existsSync
())
{
globals
.
printError
(
'Warning: dart2js did not produced expected deps list at '
'
${dart2jsDeps.path}
'
);
...
...
@@ -197,7 +213,7 @@ class Dart2JSTarget extends Target {
platform:
globals
.
platform
,
);
final
Depfile
depfile
=
depfileService
.
parseDart2js
(
environment
.
buildDir
.
childFile
(
'
main.dart.js
.deps'
),
environment
.
buildDir
.
childFile
(
'
app.dill
.deps'
),
outputFile
,
);
depfileService
.
writeToFile
(
...
...
packages/flutter_tools/lib/src/web/compile.dart
View file @
8872d1d8
...
...
@@ -11,6 +11,7 @@ import '../base/logger.dart';
import
'../build_info.dart'
;
import
'../build_system/build_system.dart'
;
import
'../build_system/targets/dart.dart'
;
import
'../build_system/targets/icon_tree_shaker.dart'
;
import
'../build_system/targets/web.dart'
;
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
...
...
@@ -52,8 +53,7 @@ Future<void> buildWeb(
kHasWebPlugins:
hasWebPlugins
.
toString
(),
kDartDefines:
jsonEncode
(
dartDefines
),
kCspMode:
csp
.
toString
(),
// TODO(dnfield): Enable font subset. We need to get a kernel file to do
// that. https://github.com/flutter/flutter/issues/49730
kIconTreeShakerFlag:
buildInfo
.
treeShakeIcons
.
toString
(),
},
));
if
(!
result
.
success
)
{
...
...
packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
View file @
8872d1d8
This diff is collapsed.
Click to expand it.
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