[flutter_tool] Remove the synchronous -showBuildSettings (#40435)

This commit is contained in:
Zachary Anderson
2019-09-16 07:51:50 -07:00
committed by GitHub
parent ef1269546c
commit 8a33d2446d
18 changed files with 110 additions and 104 deletions

View File

@@ -328,7 +328,7 @@ abstract class IOSApp extends ApplicationPackage {
);
}
factory IOSApp.fromIosProject(IosProject project) {
static Future<IOSApp> fromIosProject(IosProject project) {
if (getCurrentHostPlatform() != HostPlatform.darwin_x64) {
return null;
}
@@ -345,7 +345,7 @@ abstract class IOSApp extends ApplicationPackage {
printError('Expected ios/Runner.xcodeproj/project.pbxproj but this file is missing.');
return null;
}
return BuildableIOSApp(project);
return BuildableIOSApp.fromProject(project);
}
@override
@@ -357,7 +357,13 @@ abstract class IOSApp extends ApplicationPackage {
}
class BuildableIOSApp extends IOSApp {
BuildableIOSApp(this.project) : super(projectBundleId: project.productBundleIdentifier);
BuildableIOSApp(this.project, String projectBundleId)
: super(projectBundleId: projectBundleId);
static Future<BuildableIOSApp> fromProject(IosProject project) async {
final String projectBundleId = await project.productBundleIdentifier;
return BuildableIOSApp(project, projectBundleId);
}
final IosProject project;
@@ -416,7 +422,7 @@ class ApplicationPackageStore {
android ??= await AndroidApk.fromAndroidProject(FlutterProject.current().android);
return android;
case TargetPlatform.ios:
iOS ??= IOSApp.fromIosProject(FlutterProject.current().ios);
iOS ??= await IOSApp.fromIosProject(FlutterProject.current().ios);
return iOS;
case TargetPlatform.fuchsia:
fuchsia ??= FuchsiaApp.fromFuchsiaProject(FlutterProject.current().fuchsia);

View File

@@ -352,7 +352,7 @@ class CreateCommand extends FlutterCommand {
String organization = argResults['org'];
if (!argResults.wasParsed('org')) {
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
final Set<String> existingOrganizations = project.organizationNames;
final Set<String> existingOrganizations = await project.organizationNames;
if (existingOrganizations.length == 1) {
organization = existingOrganizations.first;
} else if (1 < existingOrganizations.length) {

View File

@@ -231,7 +231,7 @@ class RunCommand extends RunCommandBase {
hostLanguage.add(androidProject.isKotlin ? 'kotlin' : 'java');
}
if (iosProject != null && iosProject.exists) {
hostLanguage.add(iosProject.isSwift ? 'swift' : 'objc');
hostLanguage.add(await iosProject.isSwift ? 'swift' : 'objc');
}
return <CustomDimensions, String>{

View File

@@ -95,7 +95,7 @@ final RegExp _certificateOrganizationalUnitExtractionPattern = RegExp(r'OU=([a-z
Future<Map<String, String>> getCodeSigningIdentityDevelopmentTeam({
BuildableIOSApp iosApp,
}) async {
final Map<String, String> buildSettings = iosApp.project.buildSettings;
final Map<String, String> buildSettings = await iosApp.project.buildSettings;
if (buildSettings == null) {
return null;
}

View File

@@ -258,32 +258,9 @@ class XcodeProjectInterpreter {
return _minorVersion;
}
/// Synchronously retrieve xcode build settings. Prefer using the async
/// version below.
Map<String, String> getBuildSettings(String projectPath, String target) {
try {
final String out = processUtils.runSync(
<String>[
_executable,
'-project',
fs.path.absolute(projectPath),
'-target',
target,
'-showBuildSettings',
],
throwOnError: true,
workingDirectory: projectPath,
).stdout.trim();
return parseXcodeBuildSettings(out);
} on ProcessException catch (error) {
printTrace('Unexpected failure to get the build settings: $error.');
return const <String, String>{};
}
}
/// Asynchronously retrieve xcode build settings. This one is preferred for
/// new call-sites.
Future<Map<String, String>> getBuildSettingsAsync(
Future<Map<String, String>> getBuildSettings(
String projectPath, String target, {
Duration timeout = const Duration(minutes: 1),
}) async {

View File

@@ -37,7 +37,7 @@ Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject,
final bool didPodInstall = await cocoaPods.processPods(
xcodeProject: xcodeProject,
engineDir: flutterFrameworkDir(buildMode),
isSwift: xcodeProject.isSwift,
isSwift: await xcodeProject.isSwift,
dependenciesChanged: !fingerprinter.doesFingerprintMatch(),
);
if (didPodInstall) {

View File

@@ -213,7 +213,7 @@ class CocoaPods {
if (xcodeProject is MacOSProject) {
podfileTemplateName = 'Podfile-macos';
} else {
final bool isSwift = (await xcodeProjectInterpreter.getBuildSettingsAsync(
final bool isSwift = (await xcodeProjectInterpreter.getBuildSettings(
runnerProject.path,
'Runner',
)).containsKey('SWIFT_VERSION');

View File

@@ -88,13 +88,13 @@ class FlutterProject {
/// The set of organization names found in this project as
/// part of iOS product bundle identifier, Android application ID, or
/// Gradle group ID.
Set<String> get organizationNames {
Future<Set<String>> get organizationNames async {
final List<String> candidates = <String>[
ios.productBundleIdentifier,
await ios.productBundleIdentifier,
android.applicationId,
android.group,
example.android.applicationId,
example.ios.productBundleIdentifier,
await example.ios.productBundleIdentifier,
];
return Set<String>.from(candidates
.map<String>(_organizationNameFromPackageName)
@@ -280,7 +280,7 @@ abstract class XcodeBasedProject {
File get podManifestLock;
/// True if the host app project is using Swift.
bool get isSwift;
Future<bool> get isSwift;
}
/// Represents the iOS sub-project of a Flutter project.
@@ -365,7 +365,7 @@ class IosProject implements XcodeBasedProject {
/// The product bundle identifier of the host app, or null if not set or if
/// iOS tooling needed to read it is not installed.
String get productBundleIdentifier {
Future<String> get productBundleIdentifier async {
String fromPlist;
try {
fromPlist = PlistParser.instance.getValueFromFile(
@@ -386,24 +386,26 @@ class IosProject implements XcodeBasedProject {
}
if (fromPlist != null && xcode.xcodeProjectInterpreter.isInstalled) {
// General case: perform variable substitution using build settings.
return xcode.substituteXcodeVariables(fromPlist, buildSettings);
return xcode.substituteXcodeVariables(fromPlist, await buildSettings);
}
return null;
}
@override
bool get isSwift => buildSettings?.containsKey('SWIFT_VERSION') ?? false;
Future<bool> get isSwift async =>
(await buildSettings)?.containsKey('SWIFT_VERSION') ?? false;
/// The build settings for the host app of this project, as a detached map.
///
/// Returns null, if iOS tooling is unavailable.
Map<String, String> get buildSettings {
Future<Map<String, String>> get buildSettings async {
if (!xcode.xcodeProjectInterpreter.isInstalled) {
return null;
}
_buildSettings ??=
xcode.xcodeProjectInterpreter.getBuildSettings(xcodeProject.path,
_hostAppBundleName);
_buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings(
xcodeProject.path,
_hostAppBundleName,
);
return _buildSettings;
}
@@ -726,7 +728,7 @@ class MacOSProject implements XcodeBasedProject {
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppBundleName.xcworkspace');
@override
bool get isSwift => true;
Future<bool> get isSwift async => true;
/// The file where the Xcode build will write the name of the built app.
///