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
e67f9a3f
Unverified
Commit
e67f9a3f
authored
Oct 18, 2019
by
Jonah Williams
Committed by
GitHub
Oct 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure we can disable --track-widget-creation in debug mode (#43016)
parent
5db53aee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
1 deletion
+66
-1
dart.dart
...ages/flutter_tools/lib/src/build_system/targets/dart.dart
+6
-1
bundle.dart
packages/flutter_tools/lib/src/bundle.dart
+3
-0
build_bundle_test.dart
...ools/test/commands.shard/permeable/build_bundle_test.dart
+33
-0
dart_test.dart
...ls/test/general.shard/build_system/targets/dart_test.dart
+24
-0
No files found.
packages/flutter_tools/lib/src/build_system/targets/dart.dart
View file @
e67f9a3f
...
...
@@ -31,6 +31,9 @@ const String kTargetFile = 'TargetFile';
/// The define to control whether the AOT snapshot is built with bitcode.
const
String
kBitcodeFlag
=
'EnableBitcode'
;
/// Whether to enable or disable track widget creation.
const
String
kTrackWidgetCreation
=
'TrackWidgetCreation'
;
/// The define to control what iOS architectures are built for.
///
/// This is expected to be a comma-separated list of architectures. If not
...
...
@@ -208,12 +211,14 @@ class KernelSnapshot extends Target {
final
String
targetFile
=
environment
.
defines
[
kTargetFile
]
??
fs
.
path
.
join
(
'lib'
,
'main.dart'
);
final
String
packagesPath
=
environment
.
projectDir
.
childFile
(
'.packages'
).
path
;
final
String
targetFileAbsolute
=
fs
.
file
(
targetFile
).
absolute
.
path
;
// everything besides 'false' is considered to be enabled.
final
bool
trackWidgetCreation
=
environment
.
defines
[
kTrackWidgetCreation
]
!=
'false'
;
final
CompilerOutput
output
=
await
compiler
.
compile
(
sdkRoot:
artifacts
.
getArtifactPath
(
Artifact
.
flutterPatchedSdkPath
,
mode:
buildMode
),
aot:
buildMode
!=
BuildMode
.
debug
,
buildMode:
buildMode
,
trackWidgetCreation:
buildMode
==
BuildMode
.
debug
,
trackWidgetCreation:
trackWidgetCreation
&&
buildMode
==
BuildMode
.
debug
,
targetModel:
TargetModel
.
flutter
,
outputFilePath:
environment
.
buildDir
.
childFile
(
'app.dill'
).
path
,
packagesPath:
packagesPath
,
...
...
packages/flutter_tools/lib/src/bundle.dart
View file @
e67f9a3f
...
...
@@ -80,6 +80,7 @@ class BundleBuilder {
outputDir:
assetDirPath
,
depfilePath:
depfilePath
,
precompiled:
precompiledSnapshot
,
trackWidgetCreation:
trackWidgetCreation
,
);
// Work around for flutter_tester placing kernel artifacts in odd places.
if
(
applicationKernelFilePath
!=
null
)
{
...
...
@@ -103,6 +104,7 @@ Future<void> buildWithAssemble({
@required
String
outputDir
,
@required
String
depfilePath
,
@required
bool
precompiled
,
bool
trackWidgetCreation
,
})
async
{
// If the precompiled flag was not passed, force us into debug mode.
buildMode
=
precompiled
?
buildMode
:
BuildMode
.
debug
;
...
...
@@ -114,6 +116,7 @@ Future<void> buildWithAssemble({
kTargetFile:
mainPath
,
kBuildMode:
getNameForBuildMode
(
buildMode
),
kTargetPlatform:
getNameForTargetPlatform
(
targetPlatform
),
kTrackWidgetCreation:
trackWidgetCreation
?.
toString
(),
},
);
final
Target
target
=
buildMode
==
BuildMode
.
debug
...
...
packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
View file @
e67f9a3f
...
...
@@ -6,6 +6,8 @@ import 'package:args/command_runner.dart';
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/build_system/build_system.dart'
;
import
'package:flutter_tools/src/build_system/targets/dart.dart'
;
import
'package:flutter_tools/src/bundle.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_bundle.dart'
;
...
...
@@ -202,6 +204,37 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
(<
FakeCommand
>[]),
FeatureFlags:
()
=>
TestFeatureFlags
(
isMacOSEnabled:
true
),
});
testUsingContext
(
'passes track widget creation through'
,
()
async
{
fs
.
file
(
'lib/main.dart'
).
createSync
(
recursive:
true
);
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
BuildBundleCommand
());
when
(
buildSystem
.
build
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
final
Environment
environment
=
invocation
.
positionalArguments
[
1
];
expect
(
environment
.
defines
,
<
String
,
String
>{
kTargetFile:
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
kBuildMode:
'debug'
,
kTargetPlatform:
'android-arm'
,
kTrackWidgetCreation:
'true'
,
});
return
BuildResult
(
success:
true
);
});
await
runner
.
run
(<
String
>[
'bundle'
,
'--no-pub'
,
'--debug'
,
'--target-platform=android-arm'
,
'--track-widget-creation'
]);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
BuildSystem:
()
=>
MockBuildSystem
(),
ProcessManager:
()
=>
FakeProcessManager
(<
FakeCommand
>[]),
});
}
class
MockBundleBuilder
extends
Mock
implements
BundleBuilder
{}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
View file @
e67f9a3f
...
...
@@ -168,6 +168,30 @@ flutter_tools:lib/''');
KernelCompilerFactory:
()
=>
MockKernelCompilerFactory
(),
}));
test
(
'kernel_snapshot can disable track-widget-creation on debug builds'
,
()
=>
testbed
.
run
(()
async
{
final
MockKernelCompiler
mockKernelCompiler
=
MockKernelCompiler
();
when
(
kernelCompilerFactory
.
create
(
any
)).
thenAnswer
((
Invocation
_
)
async
{
return
mockKernelCompiler
;
});
when
(
mockKernelCompiler
.
compile
(
sdkRoot:
anyNamed
(
'sdkRoot'
),
aot:
anyNamed
(
'aot'
),
buildMode:
anyNamed
(
'buildMode'
),
trackWidgetCreation:
false
,
targetModel:
anyNamed
(
'targetModel'
),
outputFilePath:
anyNamed
(
'outputFilePath'
),
depFilePath:
anyNamed
(
'depFilePath'
),
packagesPath:
anyNamed
(
'packagesPath'
),
mainPath:
anyNamed
(
'mainPath'
),
)).
thenAnswer
((
Invocation
_
)
async
{
return
const
CompilerOutput
(
'example'
,
0
,
<
Uri
>[]);
});
await
const
KernelSnapshot
().
build
(
androidEnvironment
..
defines
[
kTrackWidgetCreation
]
=
'false'
);
},
overrides:
<
Type
,
Generator
>{
KernelCompilerFactory:
()
=>
MockKernelCompilerFactory
(),
}));
test
(
'kernel_snapshot does use track widget creation on debug builds'
,
()
=>
testbed
.
run
(()
async
{
final
MockKernelCompiler
mockKernelCompiler
=
MockKernelCompiler
();
when
(
kernelCompilerFactory
.
create
(
any
)).
thenAnswer
((
Invocation
_
)
async
{
...
...
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