Unverified Commit 62febaa1 authored by Jacob Richman's avatar Jacob Richman Committed by GitHub

Add support for --track-widget-creation back to ios build rules. (#18046)

parent b921fdc5
...@@ -109,6 +109,11 @@ BuildApp() { ...@@ -109,6 +109,11 @@ BuildApp() {
preview_dart_2_flag="--no-preview-dart-2" preview_dart_2_flag="--no-preview-dart-2"
fi fi
local track_widget_creation_flag=""
if [[ -n "$TRACK_WIDGET_CREATION" ]]; then
track_widget_creation_flag="--track-widget-creation"
fi
if [[ "${build_mode}" != "debug" ]]; then if [[ "${build_mode}" != "debug" ]]; then
StreamOutput " ├─Building Dart code..." StreamOutput " ├─Building Dart code..."
# Transform ARCHS to comma-separated list of target architectures. # Transform ARCHS to comma-separated list of target architectures.
...@@ -122,7 +127,8 @@ BuildApp() { ...@@ -122,7 +127,8 @@ BuildApp() {
--${build_mode} \ --${build_mode} \
--ios-arch="${archs}" \ --ios-arch="${archs}" \
${local_engine_flag} \ ${local_engine_flag} \
${preview_dart_2_flag} ${preview_dart_2_flag} \
${track_widget_creation_flag}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
EchoError "Failed to build ${project_path}." EchoError "Failed to build ${project_path}."
...@@ -166,7 +172,8 @@ BuildApp() { ...@@ -166,7 +172,8 @@ BuildApp() {
--asset-dir="${derived_dir}/flutter_assets" \ --asset-dir="${derived_dir}/flutter_assets" \
${precompilation_flag} \ ${precompilation_flag} \
${local_engine_flag} \ ${local_engine_flag} \
${preview_dart_2_flag} ${preview_dart_2_flag} \
${track_widget_creation_flag}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
EchoError "Failed to package ${project_path}." EchoError "Failed to package ${project_path}."
......
...@@ -12,7 +12,7 @@ import 'globals.dart'; ...@@ -12,7 +12,7 @@ import 'globals.dart';
class BuildInfo { class BuildInfo {
const BuildInfo(this.mode, this.flavor, { const BuildInfo(this.mode, this.flavor, {
this.previewDart2: false, this.previewDart2: false,
this.trackWidgetCreation, this.trackWidgetCreation: false,
this.extraFrontEndOptions, this.extraFrontEndOptions,
this.extraGenSnapshotOptions, this.extraGenSnapshotOptions,
this.preferSharedLibrary, this.preferSharedLibrary,
......
...@@ -363,6 +363,7 @@ class IOSSimulator extends Device { ...@@ -363,6 +363,7 @@ class IOSSimulator extends Device {
final BuildInfo debugBuildInfo = new BuildInfo(BuildMode.debug, buildInfo.flavor, final BuildInfo debugBuildInfo = new BuildInfo(BuildMode.debug, buildInfo.flavor,
previewDart2: buildInfo.previewDart2, previewDart2: buildInfo.previewDart2,
trackWidgetCreation: buildInfo.trackWidgetCreation,
extraFrontEndOptions: buildInfo.extraFrontEndOptions, extraFrontEndOptions: buildInfo.extraFrontEndOptions,
extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions, extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions,
preferSharedLibrary: buildInfo.preferSharedLibrary); preferSharedLibrary: buildInfo.preferSharedLibrary);
......
...@@ -117,6 +117,10 @@ Future<void> updateGeneratedXcodeProperties({ ...@@ -117,6 +117,10 @@ Future<void> updateGeneratedXcodeProperties({
localsBuffer.writeln('PREVIEW_DART_2=true'); localsBuffer.writeln('PREVIEW_DART_2=true');
} }
if (buildInfo.trackWidgetCreation) {
localsBuffer.writeln('TRACK_WIDGET_CREATION=true');
}
final File localsFile = fs.file(_generatedXcodePropertiesPath(projectPath)); final File localsFile = fs.file(_generatedXcodePropertiesPath(projectPath));
localsFile.createSync(recursive: true); localsFile.createSync(recursive: true);
localsFile.writeAsStringSync(localsBuffer.toString()); localsFile.writeAsStringSync(localsBuffer.toString());
......
...@@ -301,6 +301,47 @@ Information about project "Runner": ...@@ -301,6 +301,47 @@ Information about project "Runner":
expect(contents.contains('ARCHS=armv7'), isTrue); expect(contents.contains('ARCHS=armv7'), isTrue);
}); });
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
trackWidgetCreation: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isTrue);
});
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isFalse);
});
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment