mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add engine build mode to Flutter and FlutterMacOS framework Info.plist (#168024)
This PR adds the build mode (debug, profile, release) to the Flutter.framework, FlutterMacOS.framework, and FlutterEmbedder.framework Info.plist. It also adds the engine version to the FlutterMacOS.framework Info.plist. The engine version is already in the Flutter.framework one. Fixes https://github.com/flutter/flutter/issues/168028. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
59537e1f66
commit
071f62d937
@ -10,6 +10,7 @@ engine.
|
||||
|
||||
usage: copy_info_plist.py --source <src_path> --destination <dest_path>
|
||||
--minversion=<deployment_target>
|
||||
--buildmode=<build_mode>
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@ -44,6 +45,7 @@ def main():
|
||||
'--destination', help='Path to destination Info.plist', type=str, required=True
|
||||
)
|
||||
parser.add_argument('--minversion', help='Minimum device OS version like "9.0"', type=str)
|
||||
parser.add_argument('--buildmode', help='Build Mode like Debug, Profile, Release', type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -51,7 +53,12 @@ def main():
|
||||
engine_path = os.path.join(_src_root_dir, 'flutter')
|
||||
revision = git_revision.get_repository_version(engine_path)
|
||||
clang_version = get_clang_version()
|
||||
text = text.format(revision=revision, clang_version=clang_version, min_version=args.minversion)
|
||||
text = text.format(
|
||||
revision=revision,
|
||||
clang_version=clang_version,
|
||||
min_version=args.minversion,
|
||||
build_mode=args.buildmode
|
||||
)
|
||||
|
||||
with open(args.destination, 'w') as outfile:
|
||||
outfile.write(text)
|
||||
|
||||
@ -367,6 +367,8 @@ action("copy_framework_info_plist") {
|
||||
rebase_path(outputs[0]),
|
||||
"--minversion",
|
||||
ios_deployment_target,
|
||||
"--buildmode",
|
||||
flutter_runtime_mode,
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
<string>{min_version}</string>
|
||||
<key>FlutterEngine</key>
|
||||
<string>{revision}</string>
|
||||
<key>BuildMode</key>
|
||||
<string>{build_mode}</string>
|
||||
<key>ClangVersion</key>
|
||||
<string>{clang_version}</string>
|
||||
</dict>
|
||||
|
||||
@ -237,10 +237,19 @@ copy("copy_dylib") {
|
||||
deps = [ ":flutter_framework_dylib" ]
|
||||
}
|
||||
|
||||
copy("copy_framework_info_plist") {
|
||||
action("copy_framework_info_plist") {
|
||||
script = "//flutter/build/copy_info_plist.py"
|
||||
visibility = [ ":*" ]
|
||||
sources = [ "framework/Info.plist" ]
|
||||
outputs = [ "$_flutter_framework_dir/Versions/A/Resources/Info.plist" ]
|
||||
args = [
|
||||
"--source",
|
||||
rebase_path(sources[0]),
|
||||
"--destination",
|
||||
rebase_path(outputs[0]),
|
||||
"--buildmode",
|
||||
flutter_runtime_mode,
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_framework_module_map") {
|
||||
|
||||
@ -20,5 +20,9 @@
|
||||
<string>1.0</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
<key>FlutterEngine</key>
|
||||
<string>{revision}</string>
|
||||
<key>BuildMode</key>
|
||||
<string>{build_mode}</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -497,6 +497,8 @@ if (is_mac && !embedder_for_target) {
|
||||
rebase_path(sources[0]),
|
||||
"--destination",
|
||||
rebase_path(outputs[0]),
|
||||
"--buildmode",
|
||||
flutter_runtime_mode,
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
<string>Copyright 2013 The Flutter Authors. All rights reserved.</string>
|
||||
<key>FlutterEngine</key>
|
||||
<string>{revision}</string>
|
||||
<key>BuildMode</key>
|
||||
<string>{build_mode}</string>
|
||||
<key>ClangVersion</key>
|
||||
<string>{clang_version}</string>
|
||||
</dict>
|
||||
|
||||
@ -298,6 +298,58 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
for (final BuildMode buildMode in <BuildMode>[
|
||||
BuildMode.debug,
|
||||
BuildMode.profile,
|
||||
BuildMode.release,
|
||||
]) {
|
||||
for (final String arch in <String>['ios-arm64', 'ios-arm64_x86_64-simulator']) {
|
||||
test('verify ${buildMode.cliName} $arch Flutter.framework Info.plist', () {
|
||||
final String artifactDir;
|
||||
switch (buildMode) {
|
||||
case BuildMode.debug:
|
||||
case BuildMode.jitRelease:
|
||||
artifactDir = 'ios';
|
||||
case BuildMode.profile:
|
||||
artifactDir = 'ios-profile';
|
||||
case BuildMode.release:
|
||||
artifactDir = 'ios-release';
|
||||
}
|
||||
final Directory xcframeworkArtifact = fileSystem.directory(
|
||||
fileSystem.path.join(
|
||||
flutterRoot,
|
||||
'bin',
|
||||
'cache',
|
||||
'artifacts',
|
||||
'engine',
|
||||
artifactDir,
|
||||
'Flutter.xcframework',
|
||||
),
|
||||
);
|
||||
// Verify Info.plist has correct engine version and build mode
|
||||
final File engineStamp = fileSystem.file(
|
||||
fileSystem.path.join(flutterRoot, 'bin', 'cache', 'engine.stamp'),
|
||||
);
|
||||
expect(engineStamp, exists);
|
||||
final String engineVersion = engineStamp.readAsStringSync().trim();
|
||||
|
||||
final File infoPlist = fileSystem.file(
|
||||
fileSystem.path.joinAll(<String>[
|
||||
xcframeworkArtifact.path,
|
||||
'ios-arm64',
|
||||
'Flutter.framework',
|
||||
'Info.plist',
|
||||
]),
|
||||
);
|
||||
expect(infoPlist, exists);
|
||||
|
||||
final String infoPlistContents = infoPlist.readAsStringSync();
|
||||
expect(infoPlistContents, contains(engineVersion));
|
||||
expect(infoPlistContents, contains(buildMode.cliName));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
testWithoutContext('builds all plugin architectures for simulator', () {
|
||||
final ProcessResult buildSimulator = processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
|
||||
import '../integration.shard/test_utils.dart';
|
||||
@ -31,11 +32,24 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
for (final String buildMode in <String>['Debug', 'Release']) {
|
||||
test('verify $buildMode FlutterMacOS.xcframework artifact', () {
|
||||
for (final BuildMode buildMode in <BuildMode>[
|
||||
BuildMode.debug,
|
||||
BuildMode.profile,
|
||||
BuildMode.release,
|
||||
]) {
|
||||
test('verify ${buildMode.cliName} FlutterMacOS.xcframework artifact', () {
|
||||
final String flutterRoot = getFlutterRoot();
|
||||
|
||||
final String artifactDir = (buildMode == 'Debug') ? 'darwin-x64' : 'darwin-x64-release';
|
||||
final String artifactDir;
|
||||
switch (buildMode) {
|
||||
case BuildMode.debug:
|
||||
case BuildMode.jitRelease:
|
||||
artifactDir = 'darwin-x64';
|
||||
case BuildMode.profile:
|
||||
artifactDir = 'darwin-x64-profile';
|
||||
case BuildMode.release:
|
||||
artifactDir = 'darwin-x64-release';
|
||||
}
|
||||
final Directory xcframeworkArtifact = fileSystem.directory(
|
||||
fileSystem.path.join(
|
||||
flutterRoot,
|
||||
@ -72,7 +86,31 @@ void main() {
|
||||
final String artifactStat = frameworkArtifact.statSync().mode.toRadixString(8);
|
||||
expect(artifactStat, '40755');
|
||||
|
||||
if (buildMode == 'Release') {
|
||||
// Verify Info.plist has correct engine version and build mode
|
||||
final File engineStamp = fileSystem.file(
|
||||
fileSystem.path.join(flutterRoot, 'bin', 'cache', 'engine.stamp'),
|
||||
);
|
||||
expect(engineStamp, exists);
|
||||
final String engineVersion = engineStamp.readAsStringSync().trim();
|
||||
|
||||
final File infoPlist = fileSystem.file(
|
||||
fileSystem.path.joinAll(<String>[
|
||||
xcframeworkArtifact.path,
|
||||
'macos-arm64_x86_64',
|
||||
'FlutterMacOS.framework',
|
||||
'Versions',
|
||||
'A',
|
||||
'Resources',
|
||||
'Info.plist',
|
||||
]),
|
||||
);
|
||||
expect(infoPlist, exists);
|
||||
|
||||
final String infoPlistContents = infoPlist.readAsStringSync();
|
||||
expect(infoPlistContents, contains(engineVersion));
|
||||
expect(infoPlistContents, contains(buildMode.cliName));
|
||||
|
||||
if (buildMode == BuildMode.release) {
|
||||
final Directory dsymArtifact = fileSystem.directory(
|
||||
fileSystem.path.joinAll(<String>[
|
||||
xcframeworkArtifact.path,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user