Re-reland Xcode backend refactor (#23762)

* Use Xcode build configurations to drive Flutter build mode

* Proper check wrt local_engine, print error if profile mode misisng

* Remove unused code, update tests, fix template problem, update warning

* fix up warning

* add explanatory dev comment

* fix whitespace

* missing words, change lambda arrow to function body

* error indentation

* Test early exits for xcode_backend.sh

* only on macOS, use right test

* Update error messages

* case insensitive compare for build config

* Update gallery podfile

* update projects to add profile configuration

* make compatible with flavors

* add missing plist files

* add FLUTTER_FRAMEWORK_DIR back, set swift version for profile, tell Podfile about profile
This commit is contained in:
Dan Field
2018-10-31 16:37:53 -07:00
committed by GitHub
parent fab109cef5
commit fd6b2e198c
59 changed files with 1930 additions and 77 deletions

View File

@@ -481,7 +481,6 @@ void main() {
final String xcodeConfig = xcodeConfigFile.readAsStringSync();
expect(xcodeConfig, contains('FLUTTER_ROOT='));
expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH='));
expect(xcodeConfig, contains('FLUTTER_FRAMEWORK_DIR='));
// App identification
final String xcodeProjectPath = fs.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj');
expectExists(xcodeProjectPath);

View File

@@ -0,0 +1,68 @@
// Copyright 2018 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart';
import '../src/common.dart';
const String xcodeBackendPath = 'bin/xcode_backend.sh';
const String xcodeBackendErrorHeader = '========================================================================';
// Acceptable $CONFIGURATION/$FLUTTER_BUILD_MODE values should be debug, profile, or release
const Map<String, String> unknownConfiguration = <String, String>{
'CONFIGURATION': 'Custom',
};
// $FLUTTER_BUILD_MODE will override $CONFIGURATION
const Map<String, String> unknownFlutterBuildMode = <String, String>{
'FLUTTER_BUILD_MODE': 'Custom',
'CONFIGURATION': 'Debug',
};
// Can't archive a non-release build.
const Map<String, String> installWithoutRelease = <String, String>{
'CONFIGURATION': 'Debug',
'ACTION': 'install',
};
// Can't use a debug engine build with a release build.
const Map<String, String> localEngineDebugBuildModeRelease = <String, String>{
'SOURCE_ROOT': '../../examples/hello_world',
'FLUTTER_ROOT': '../..',
'LOCAL_ENGINE': '/engine/src/out/ios_debug_unopt',
'CONFIGURATION': 'Release'
};
// Can't use a debug build with a profile engine.
const Map<String, String> localEngineProfileBuildeModeRelease =
<String, String>{
'SOURCE_ROOT': '../../examples/hello_world',
'FLUTTER_ROOT': '../..',
'LOCAL_ENGINE': '/engine/src/out/ios_profile',
'CONFIGURATION': 'Debug',
'FLUTTER_BUILD_MODE': 'Debug',
};
void main() {
Future<void> expectXcodeBackendFails(Map<String, String> environment) async {
final ProcessResult result = await Process.run(
xcodeBackendPath,
<String>['build'],
environment: environment,
);
expect(result.stderr, startsWith(xcodeBackendErrorHeader));
expect(result.exitCode, isNot(0));
}
test('Xcode backend fails for on unsupported configuration combinations', () async {
await expectXcodeBackendFails(unknownConfiguration);
await expectXcodeBackendFails(unknownFlutterBuildMode);
await expectXcodeBackendFails(installWithoutRelease);
await expectXcodeBackendFails(localEngineDebugBuildModeRelease);
await expectXcodeBackendFails(localEngineProfileBuildeModeRelease);
}, skip: !platform.isMacOS);
}

View File

@@ -197,7 +197,7 @@ Information about project "Runner":
});
test('expected build configuration for non-flavored build is derived from BuildMode', () {
expect(XcodeProjectInfo.expectedBuildConfigurationFor(BuildInfo.debug, 'Runner'), 'Debug');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(BuildInfo.profile, 'Runner'), 'Release');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(BuildInfo.profile, 'Runner'), 'Profile');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(BuildInfo.release, 'Runner'), 'Release');
});
test('expected scheme for flavored build is the title-cased flavor', () {
@@ -207,7 +207,7 @@ Information about project "Runner":
});
test('expected build configuration for flavored build is Mode-Flavor', () {
expect(XcodeProjectInfo.expectedBuildConfigurationFor(const BuildInfo(BuildMode.debug, 'hello'), 'Hello'), 'Debug-Hello');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(const BuildInfo(BuildMode.profile, 'HELLO'), 'Hello'), 'Release-Hello');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(const BuildInfo(BuildMode.profile, 'HELLO'), 'Hello'), 'Profile-Hello');
expect(XcodeProjectInfo.expectedBuildConfigurationFor(const BuildInfo(BuildMode.release, 'Hello'), 'Hello'), 'Release-Hello');
});
test('scheme for default project is Runner', () {
@@ -218,9 +218,9 @@ Information about project "Runner":
expect(info.schemeFor(const BuildInfo(BuildMode.debug, 'unknown')), isNull);
});
test('build configuration for default project is matched against BuildMode', () {
final XcodeProjectInfo info = XcodeProjectInfo(<String>['Runner'], <String>['Debug', 'Release'], <String>['Runner']);
final XcodeProjectInfo info = XcodeProjectInfo(<String>['Runner'], <String>['Debug', 'Profile', 'Release'], <String>['Runner']);
expect(info.buildConfigurationFor(BuildInfo.debug, 'Runner'), 'Debug');
expect(info.buildConfigurationFor(BuildInfo.profile, 'Runner'), 'Release');
expect(info.buildConfigurationFor(BuildInfo.profile, 'Runner'), 'Profile');
expect(info.buildConfigurationFor(BuildInfo.release, 'Runner'), 'Release');
});
test('scheme for project with custom schemes is matched against flavor', () {
@@ -238,12 +238,12 @@ Information about project "Runner":
test('build configuration for project with custom schemes is matched against BuildMode and flavor', () {
final XcodeProjectInfo info = XcodeProjectInfo(
<String>['Runner'],
<String>['debug (free)', 'Debug paid', 'release - Free', 'Release-Paid'],
<String>['debug (free)', 'Debug paid', 'profile - Free', 'Profile-Paid', 'release - Free', 'Release-Paid'],
<String>['Free', 'Paid'],
);
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.debug, 'free'), 'Free'), 'debug (free)');
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.debug, 'Paid'), 'Paid'), 'Debug paid');
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.profile, 'FREE'), 'Free'), 'release - Free');
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.profile, 'FREE'), 'Free'), 'profile - Free');
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'paid'), 'Paid'), 'Release-Paid');
});
test('build configuration for project with inconsistent naming is null', () {