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
c411f588
Unverified
Commit
c411f588
authored
Mar 05, 2020
by
Jonah Williams
Committed by
GitHub
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "[flutter_tools] supports tree-shake-icons for web builds (#51808)" (#52045)
This reverts commit
aed96199
.
parent
ee476a7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
194 deletions
+147
-194
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
+14
-29
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
+129
-161
No files found.
packages/flutter_tools/lib/src/build_system/targets/icon_tree_shaker.dart
View file @
c411f588
...
@@ -289,7 +289,7 @@ class IconTreeShaker {
...
@@ -289,7 +289,7 @@ class IconTreeShaker {
for
(
final
Map
<
String
,
dynamic
>
iconDataMap
in
consts
.
constantInstances
)
{
for
(
final
Map
<
String
,
dynamic
>
iconDataMap
in
consts
.
constantInstances
)
{
if
((
iconDataMap
[
'fontPackage'
]
??
''
)
is
!
String
||
// Null is ok here.
if
((
iconDataMap
[
'fontPackage'
]
??
''
)
is
!
String
||
// Null is ok here.
iconDataMap
[
'fontFamily'
]
is
!
String
||
iconDataMap
[
'fontFamily'
]
is
!
String
||
iconDataMap
[
'codePoint'
]
is
!
num
)
{
iconDataMap
[
'codePoint'
]
is
!
int
)
{
throw
IconTreeShakerException
.
_
(
throw
IconTreeShakerException
.
_
(
'Invalid ConstFinder result. Expected "fontPackage" to be a String, '
'Invalid ConstFinder result. Expected "fontPackage" to be a String, '
'"fontFamily" to be a String, and "codePoint" to be an int, '
'"fontFamily" to be a String, and "codePoint" to be an int, '
...
@@ -301,7 +301,7 @@ class IconTreeShaker {
...
@@ -301,7 +301,7 @@ class IconTreeShaker {
?
family
?
family
:
'packages/
$package
/
$family
'
;
:
'packages/
$package
/
$family
'
;
result
[
key
]
??=
<
int
>[];
result
[
key
]
??=
<
int
>[];
result
[
key
].
add
(
(
iconDataMap
[
'codePoint'
]
as
num
).
round
()
);
result
[
key
].
add
(
iconDataMap
[
'codePoint'
]
as
int
);
}
}
return
result
;
return
result
;
}
}
...
...
packages/flutter_tools/lib/src/build_system/targets/web.dart
View file @
c411f588
...
@@ -156,51 +156,36 @@ class Dart2JSTarget extends Target {
...
@@ -156,51 +156,36 @@ class Dart2JSTarget extends Target {
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
BuildMode
buildMode
=
getBuildModeForName
(
environment
.
defines
[
kBuildMode
]);
final
String
specPath
=
globals
.
fs
.
path
.
join
(
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
),
'libraries.json'
);
final
String
specPath
=
globals
.
fs
.
path
.
join
(
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
),
'libraries.json'
);
final
String
packageFile
=
PackageMap
.
globalPackagesPath
;
final
String
packageFile
=
PackageMap
.
globalPackagesPath
;
final
File
outputKernel
=
environment
.
buildDir
.
childFile
(
'app.dill'
);
final
File
outputFile
=
environment
.
buildDir
.
childFile
(
'main.dart.js'
);
final
File
outputFile
=
environment
.
buildDir
.
childFile
(
'main.dart.js'
);
// Run the dart2js compilation in two stages, so that icon tree shaking can
final
ProcessResult
result
=
await
globals
.
processManager
.
run
(<
String
>[
// parse the kernel file for web builds.
final
ProcessResult
kernelResult
=
await
globals
.
processManager
.
run
(<
String
>[
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
dart2jsSnapshot
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
dart2jsSnapshot
),
'--libraries-spec=
$specPath
'
,
'--libraries-spec=
$specPath
'
,
if
(
dart2jsOptimization
!=
null
)
'-
$dart2jsOptimization
'
else
'-O4'
,
if
(
buildMode
==
BuildMode
.
profile
)
'--no-minify'
,
'-o'
,
'-o'
,
output
Kernel
.
path
,
output
File
.
path
,
'--packages=
$packageFile
'
,
'--packages=
$packageFile
'
,
if
(
buildMode
==
BuildMode
.
profile
)
if
(
buildMode
==
BuildMode
.
profile
)
'-Ddart.vm.profile=true'
'-Ddart.vm.profile=true'
else
else
'-Ddart.vm.product=true'
,
'-Ddart.vm.product=true'
,
if
(
csp
)
'--csp'
,
for
(
final
String
dartDefine
in
parseDartDefines
(
environment
))
for
(
final
String
dartDefine
in
parseDartDefines
(
environment
))
'-D
$dartDefine
'
,
'-D
$dartDefine
'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
path
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
path
,
]);
]);
if
(
kernelResult
.
exitCode
!=
0
)
{
if
(
result
.
exitCode
!=
0
)
{
throw
Exception
(
kernelResult
.
stdout
+
kernelResult
.
stderr
);
throw
Exception
(
result
.
stdout
+
result
.
stderr
);
}
final
ProcessResult
javaScriptResult
=
await
globals
.
processManager
.
run
(<
String
>[
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
),
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
dart2jsSnapshot
),
'--libraries-spec=
$specPath
'
,
if
(
dart2jsOptimization
!=
null
)
'-
$dart2jsOptimization
'
else
'-O4'
,
if
(
buildMode
==
BuildMode
.
profile
)
'--no-minify'
,
if
(
csp
)
'--csp'
,
'-o'
,
outputFile
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
path
,
]);
if
(
javaScriptResult
.
exitCode
!=
0
)
{
throw
Exception
(
javaScriptResult
.
stdout
+
javaScriptResult
.
stderr
);
}
}
final
File
dart2jsDeps
=
environment
.
buildDir
final
File
dart2jsDeps
=
environment
.
buildDir
.
childFile
(
'
app.dill
.deps'
);
.
childFile
(
'
main.dart.js
.deps'
);
if
(!
dart2jsDeps
.
existsSync
())
{
if
(!
dart2jsDeps
.
existsSync
())
{
globals
.
printError
(
'Warning: dart2js did not produced expected deps list at '
globals
.
printError
(
'Warning: dart2js did not produced expected deps list at '
'
${dart2jsDeps.path}
'
);
'
${dart2jsDeps.path}
'
);
...
@@ -212,7 +197,7 @@ class Dart2JSTarget extends Target {
...
@@ -212,7 +197,7 @@ class Dart2JSTarget extends Target {
platform:
globals
.
platform
,
platform:
globals
.
platform
,
);
);
final
Depfile
depfile
=
depfileService
.
parseDart2js
(
final
Depfile
depfile
=
depfileService
.
parseDart2js
(
environment
.
buildDir
.
childFile
(
'
app.dill
.deps'
),
environment
.
buildDir
.
childFile
(
'
main.dart.js
.deps'
),
outputFile
,
outputFile
,
);
);
depfileService
.
writeToFile
(
depfileService
.
writeToFile
(
...
...
packages/flutter_tools/lib/src/web/compile.dart
View file @
c411f588
...
@@ -11,7 +11,6 @@ import '../base/logger.dart';
...
@@ -11,7 +11,6 @@ import '../base/logger.dart';
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../build_system/build_system.dart'
;
import
'../build_system/build_system.dart'
;
import
'../build_system/targets/dart.dart'
;
import
'../build_system/targets/dart.dart'
;
import
'../build_system/targets/icon_tree_shaker.dart'
;
import
'../build_system/targets/web.dart'
;
import
'../build_system/targets/web.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
...
@@ -53,7 +52,8 @@ Future<void> buildWeb(
...
@@ -53,7 +52,8 @@ Future<void> buildWeb(
kHasWebPlugins:
hasWebPlugins
.
toString
(),
kHasWebPlugins:
hasWebPlugins
.
toString
(),
kDartDefines:
jsonEncode
(
dartDefines
),
kDartDefines:
jsonEncode
(
dartDefines
),
kCspMode:
csp
.
toString
(),
kCspMode:
csp
.
toString
(),
kIconTreeShakerFlag:
buildInfo
.
treeShakeIcons
.
toString
(),
// TODO(dnfield): Enable font subset. We need to get a kernel file to do
// that. https://github.com/flutter/flutter/issues/49730
},
},
));
));
if
(!
result
.
success
)
{
if
(!
result
.
success
)
{
...
...
packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
View file @
c411f588
...
@@ -16,38 +16,35 @@ import 'package:process/process.dart';
...
@@ -16,38 +16,35 @@ import 'package:process/process.dart';
import
'package:platform/platform.dart'
;
import
'package:platform/platform.dart'
;
import
'../../../src/common.dart'
;
import
'../../../src/common.dart'
;
import
'../../../src/context.dart'
;
import
'../../../src/mocks.dart'
;
import
'../../../src/mocks.dart'
;
import
'../../../src/testbed.dart'
;
import
'../../../src/testbed.dart'
;
const
List
<
String
>
kDart2jsLinuxArgs
=
<
String
>[
'bin/cache/dart-sdk/bin/dart'
,
'bin/cache/dart-sdk/bin/snapshots/dart2js.dart.snapshot'
,
'--libraries-spec=bin/cache/flutter_web_sdk/libraries.json'
,
];
void
main
(
)
{
void
main
(
)
{
Testbed
testbed
;
Testbed
testbed
;
Environment
environment
;
Environment
environment
;
FakeProcessManager
processManager
;
MockPlatform
mockPlatform
;
final
Platform
linux
=
FakePlatform
(
MockPlatform
mockWindowsPlatform
;
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{},
);
final
Platform
windows
=
FakePlatform
(
operatingSystem:
'windows'
,
environment:
<
String
,
String
>{},
);
DepfileService
depfileService
;
DepfileService
depfileService
;
setUp
(()
{
setUp
(()
{
mockPlatform
=
MockPlatform
();
mockWindowsPlatform
=
MockPlatform
();
when
(
mockPlatform
.
isWindows
).
thenReturn
(
false
);
when
(
mockPlatform
.
isMacOS
).
thenReturn
(
true
);
when
(
mockPlatform
.
isLinux
).
thenReturn
(
false
);
when
(
mockPlatform
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
when
(
mockWindowsPlatform
.
isWindows
).
thenReturn
(
true
);
when
(
mockWindowsPlatform
.
isMacOS
).
thenReturn
(
false
);
when
(
mockWindowsPlatform
.
isLinux
).
thenReturn
(
false
);
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
final
File
packagesFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'foo'
,
'.packages'
))
final
File
packagesFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'foo'
,
'.packages'
))
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'foo:lib/
\n
'
);
..
writeAsStringSync
(
'foo:lib/
\n
'
);
PackageMap
.
globalPackagesPath
=
packagesFile
.
path
;
PackageMap
.
globalPackagesPath
=
packagesFile
.
path
;
globals
.
fs
.
currentDirectory
.
childDirectory
(
'bar'
).
createSync
();
globals
.
fs
.
currentDirectory
.
childDirectory
(
'bar'
).
createSync
();
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
environment
=
Environment
.
test
(
environment
=
Environment
.
test
(
globals
.
fs
.
currentDirectory
,
globals
.
fs
.
currentDirectory
,
...
@@ -64,7 +61,7 @@ void main() {
...
@@ -64,7 +61,7 @@ void main() {
);
);
environment
.
buildDir
.
createSync
(
recursive:
true
);
environment
.
buildDir
.
createSync
(
recursive:
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
linux
,
Platform:
()
=>
mockPlatform
,
});
});
});
});
...
@@ -159,7 +156,7 @@ void main() {
...
@@ -159,7 +156,7 @@ void main() {
// Import.
// Import.
expect
(
generated
,
contains
(
"import 'package:foo/main.dart' as entrypoint;"
));
expect
(
generated
,
contains
(
"import 'package:foo/main.dart' as entrypoint;"
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
Platform:
()
=>
mockWindowsPlatform
,
}));
}));
test
(
'WebEntrypointTarget generates an entrypoint without plugins and init platform'
,
()
=>
testbed
.
run
(()
async
{
test
(
'WebEntrypointTarget generates an entrypoint without plugins and init platform'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -219,131 +216,111 @@ void main() {
...
@@ -219,131 +216,111 @@ void main() {
test
(
'Dart2JSTarget calls dart2js with expected args with csp'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with expected args with csp'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'profile'
;
environment
.
defines
[
kBuildMode
]
=
'profile'
;
environment
.
defines
[
kCspMode
]
=
'true'
;
environment
.
defines
[
kCspMode
]
=
'true'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O4'
,
'--no-minify'
,
'--csp'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O4'
,
// highest optimizations
'--no-minify'
,
// but uses unminified names for debugging
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
'--csp'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget calls dart2js with expected args in profile mode'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with expected args in profile mode'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'profile'
;
environment
.
defines
[
kBuildMode
]
=
'profile'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O4'
,
'--no-minify'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O4'
,
// highest optimizations
'--no-minify'
,
// but uses unminified names for debugging
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget calls dart2js with expected args in release mode'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with expected args in release mode'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kBuildMode
]
=
'release'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O4'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O4'
,
// highest optimizations.
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget calls dart2js with expected args in release with dart2js optimization override'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with expected args in release with dart2js optimization override'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kDart2jsOptimization
]
=
'O3'
;
environment
.
defines
[
kDart2jsOptimization
]
=
'O3'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O3'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O3'
,
// configured optimizations.
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget produces expected depfile'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget produces expected depfile'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kBuildMode
]
=
'release'
;
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
environment
.
buildDir
.
childFile
(
'
app.dill
.deps'
)
environment
.
buildDir
.
childFile
(
'
main.dart.js
.deps'
)
.
writeAsStringSync
(
'file:///a.dart'
);
.
writeAsStringSync
(
'file:///a.dart'
);
return
FakeProcessResult
(
exitCode:
0
);
return
FakeProcessResult
(
exitCode:
0
);
});
});
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
expect
(
environment
.
buildDir
.
childFile
(
'dart2js.d'
)
,
exists
);
expect
(
environment
.
buildDir
.
childFile
(
'dart2js.d'
)
.
existsSync
(),
true
);
final
Depfile
depfile
=
depfileService
.
parse
(
environment
.
buildDir
.
childFile
(
'dart2js.d'
));
final
Depfile
depfile
=
depfileService
.
parse
(
environment
.
buildDir
.
childFile
(
'dart2js.d'
));
expect
(
depfile
.
inputs
.
single
.
path
,
globals
.
fs
.
path
.
absolute
(
'a.dart'
));
expect
(
depfile
.
inputs
.
single
.
path
,
globals
.
fs
.
path
.
absolute
(
'a.dart'
));
...
@@ -356,64 +333,54 @@ void main() {
...
@@ -356,64 +333,54 @@ void main() {
test
(
'Dart2JSTarget calls dart2js with Dart defines in release mode'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with Dart defines in release mode'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kBuildMode
]
=
'release'
;
environment
.
defines
[
kDartDefines
]
=
'["FOO=bar","BAZ=qux"]'
;
environment
.
defines
[
kDartDefines
]
=
'["FOO=bar","BAZ=qux"]'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
'-DFOO=bar'
,
'-DBAZ=qux'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O4'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O4'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.product=true'
,
'-DFOO=bar'
,
'-DBAZ=qux'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget calls dart2js with Dart defines in profile mode'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget calls dart2js with Dart defines in profile mode'
,
()
=>
testbed
.
run
(()
async
{
environment
.
defines
[
kBuildMode
]
=
'profile'
;
environment
.
defines
[
kBuildMode
]
=
'profile'
;
environment
.
defines
[
kDartDefines
]
=
'["FOO=bar","BAZ=qux"]'
;
environment
.
defines
[
kDartDefines
]
=
'["FOO=bar","BAZ=qux"]'
;
processManager
.
addCommand
(
FakeCommand
(
when
(
globals
.
processManager
.
run
(
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
command:
<
String
>[
return
FakeProcessResult
(
exitCode:
0
);
...
kDart2jsLinuxArgs
,
});
'-o'
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
'-DFOO=bar'
,
'-DBAZ=qux'
,
'--cfe-only'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
]
));
processManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
...
kDart2jsLinuxArgs
,
'-O4'
,
'--no-minify'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
environment
.
buildDir
.
childFile
(
'app.dill'
).
absolute
.
path
,
]
));
await
const
Dart2JSTarget
().
build
(
environment
);
await
const
Dart2JSTarget
().
build
(
environment
);
final
List
<
String
>
expected
=
<
String
>[
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
'--libraries-spec='
+
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
,
'libraries.json'
),
'-O4'
,
'--no-minify'
,
'-o'
,
environment
.
buildDir
.
childFile
(
'main.dart.js'
).
absolute
.
path
,
'--packages=
${globals.fs.path.join('foo', '.packages')}
'
,
'-Ddart.vm.profile=true'
,
'-DFOO=bar'
,
'-DBAZ=qux'
,
environment
.
buildDir
.
childFile
(
'main.dart'
).
absolute
.
path
,
];
verify
(
globals
.
processManager
.
run
(
expected
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
MockProcessManager
()
,
}));
}));
test
(
'Dart2JSTarget throws developer-friendly exception on misformatted DartDefines'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Dart2JSTarget throws developer-friendly exception on misformatted DartDefines'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -460,3 +427,4 @@ void main() {
...
@@ -460,3 +427,4 @@ void main() {
}
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
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