Move Xcode context fetch to global.dart (#49458)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
2042c7d589
commit
91f7902aad
@@ -244,12 +244,12 @@ class AOTSnapshotter {
|
||||
final String assemblyO = globals.fs.path.join(outputPath, 'snapshot_assembly.o');
|
||||
List<String> isysrootArgs;
|
||||
if (isIOS) {
|
||||
final String iPhoneSDKLocation = await xcode.sdkLocation(SdkType.iPhone);
|
||||
final String iPhoneSDKLocation = await globals.xcode.sdkLocation(SdkType.iPhone);
|
||||
if (iPhoneSDKLocation != null) {
|
||||
isysrootArgs = <String>['-isysroot', iPhoneSDKLocation];
|
||||
}
|
||||
}
|
||||
final RunResult compileResult = await xcode.cc(<String>[
|
||||
final RunResult compileResult = await globals.xcode.cc(<String>[
|
||||
'-arch', targetArch,
|
||||
if (isysrootArgs != null) ...isysrootArgs,
|
||||
if (bitcode) embedBitcodeArg,
|
||||
@@ -277,7 +277,7 @@ class AOTSnapshotter {
|
||||
'-o', appLib,
|
||||
assemblyO,
|
||||
];
|
||||
final RunResult linkResult = await xcode.clang(linkArgs);
|
||||
final RunResult linkResult = await globals.xcode.clang(linkArgs);
|
||||
if (linkResult.exitCode != 0) {
|
||||
globals.printError('Failed to link AOT snapshot. Linker terminated with exit code ${compileResult.exitCode}');
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async {
|
||||
];
|
||||
}
|
||||
|
||||
return await xcode.clang(<String>[
|
||||
return await globals.xcode.clang(<String>[
|
||||
'-x',
|
||||
'c',
|
||||
...archFlags,
|
||||
@@ -189,7 +189,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk) async {
|
||||
'-Xlinker', '-rpath', '-Xlinker', '@executable_path/Frameworks',
|
||||
'-Xlinker', '-rpath', '-Xlinker', '@loader_path/Frameworks',
|
||||
'-install_name', '@rpath/App.framework/App',
|
||||
'-isysroot', await xcode.sdkLocation(sdk),
|
||||
'-isysroot', await globals.xcode.sdkLocation(sdk),
|
||||
'-o', outputFile.path,
|
||||
]);
|
||||
} finally {
|
||||
|
||||
@@ -9,7 +9,6 @@ import '../../base/io.dart';
|
||||
import '../../base/process.dart';
|
||||
import '../../build_info.dart';
|
||||
import '../../globals.dart' as globals;
|
||||
import '../../macos/xcode.dart';
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
@@ -155,7 +154,7 @@ class DebugMacOSFramework extends Target {
|
||||
..writeAsStringSync(r'''
|
||||
static const int Moo = 88;
|
||||
''');
|
||||
final RunResult result = await xcode.clang(<String>[
|
||||
final RunResult result = await globals.xcode.clang(<String>[
|
||||
'-x',
|
||||
'c',
|
||||
debugApp.path,
|
||||
|
||||
@@ -127,7 +127,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
if (!boolArg('universal') && !boolArg('xcframework')) {
|
||||
throwToolExit('--universal or --xcframework is required.');
|
||||
}
|
||||
if (boolArg('xcframework') && xcode.majorVersion < 11) {
|
||||
if (boolArg('xcframework') && globals.xcode.majorVersion < 11) {
|
||||
throwToolExit('--xcframework requires Xcode 11.');
|
||||
}
|
||||
if (buildModes.isEmpty) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import '../base/logger.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../ios/xcodeproj.dart';
|
||||
import '../macos/xcode.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -34,7 +33,7 @@ class CleanCommand extends FlutterCommand {
|
||||
// Clean Xcode to remove intermediate DerivedData artifacts.
|
||||
// Do this before removing ephemeral directory, which would delete the xcworkspace.
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
if (xcode.isInstalledAndMeetsVersionCheck) {
|
||||
if (globals.xcode.isInstalledAndMeetsVersionCheck) {
|
||||
await _cleanXcode(flutterProject.ios);
|
||||
await _cleanXcode(flutterProject.macos);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'base/io.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'cache.dart';
|
||||
import 'macos/xcode.dart';
|
||||
|
||||
Logger get logger => context.get<Logger>();
|
||||
Cache get cache => context.get<Cache>();
|
||||
@@ -40,6 +41,7 @@ const Platform _kLocalPlatform = LocalPlatform();
|
||||
|
||||
Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
|
||||
|
||||
Xcode get xcode => context.get<Xcode>();
|
||||
|
||||
/// Display an error level message to the user. Commands should use this if they
|
||||
/// fail in some way.
|
||||
|
||||
@@ -8,7 +8,6 @@ import '../base/process.dart';
|
||||
import '../device.dart';
|
||||
import '../emulator.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../macos/xcode.dart';
|
||||
import 'ios_workflow.dart';
|
||||
import 'simulators.dart';
|
||||
|
||||
@@ -45,7 +44,7 @@ class IOSEmulator extends Emulator {
|
||||
'open',
|
||||
...additionalArgs,
|
||||
'-a',
|
||||
xcode.getSimulatorPath(),
|
||||
globals.xcode.getSimulatorPath(),
|
||||
];
|
||||
|
||||
final RunResult launchResult = await processUtils.run(args);
|
||||
@@ -69,7 +68,7 @@ class IOSEmulator extends Emulator {
|
||||
|
||||
/// Return the list of iOS Simulators (there can only be zero or one).
|
||||
List<IOSEmulator> getEmulators() {
|
||||
final String simulatorPath = xcode.getSimulatorPath();
|
||||
final String simulatorPath = globals.xcode.getSimulatorPath();
|
||||
if (simulatorPath == null) {
|
||||
return <IOSEmulator>[];
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import '../base/context.dart';
|
||||
import '../doctor.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../macos/xcode.dart';
|
||||
|
||||
IOSWorkflow get iosWorkflow => context.get<IOSWorkflow>();
|
||||
|
||||
@@ -17,12 +16,12 @@ class IOSWorkflow implements Workflow {
|
||||
|
||||
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
|
||||
@override
|
||||
bool get canListDevices => xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled;
|
||||
bool get canListDevices => globals.xcode.isInstalledAndMeetsVersionCheck && globals.xcode.isSimctlInstalled;
|
||||
|
||||
// We need xcode to launch simulator devices, and ideviceinstaller and ios-deploy
|
||||
// for real devices.
|
||||
@override
|
||||
bool get canLaunchDevices => xcode.isInstalledAndMeetsVersionCheck;
|
||||
bool get canLaunchDevices => globals.xcode.isInstalledAndMeetsVersionCheck;
|
||||
|
||||
@override
|
||||
bool get canListEmulators => false;
|
||||
|
||||
@@ -717,7 +717,7 @@ bool _checkXcodeVersion() {
|
||||
globals.printError('Cannot find "xcodebuild". $_xcodeRequirement');
|
||||
return false;
|
||||
}
|
||||
if (!xcode.isVersionSatisfactory) {
|
||||
if (!globals.xcode.isVersionSatisfactory) {
|
||||
globals.printError('Found "${xcodeProjectInterpreter.versionText}". $_xcodeRequirement');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import '../bundle.dart';
|
||||
import '../convert.dart';
|
||||
import '../device.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../macos/xcode.dart';
|
||||
import '../project.dart';
|
||||
import '../protocol_discovery.dart';
|
||||
import 'ios_workflow.dart';
|
||||
@@ -47,7 +46,7 @@ class IOSSimulatorUtils {
|
||||
static IOSSimulatorUtils get instance => context.get<IOSSimulatorUtils>();
|
||||
|
||||
Future<List<IOSSimulator>> getAttachedDevices() async {
|
||||
if (!xcode.isInstalledAndMeetsVersionCheck) {
|
||||
if (!globals.xcode.isInstalledAndMeetsVersionCheck) {
|
||||
return <IOSSimulator>[];
|
||||
}
|
||||
|
||||
@@ -519,7 +518,7 @@ class IOSSimulator extends Device {
|
||||
}
|
||||
|
||||
bool get _xcodeVersionSupportsScreenshot {
|
||||
return xcode.majorVersion > 8 || (xcode.majorVersion == 8 && xcode.minorVersion >= 2);
|
||||
return globals.xcode.majorVersion > 8 || (globals.xcode.majorVersion == 8 && globals.xcode.minorVersion >= 2);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:platform/platform.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
@@ -19,8 +18,6 @@ import '../ios/xcodeproj.dart';
|
||||
const int kXcodeRequiredVersionMajor = 10;
|
||||
const int kXcodeRequiredVersionMinor = 2;
|
||||
|
||||
Xcode get xcode => context.get<Xcode>();
|
||||
|
||||
enum SdkType {
|
||||
iPhone,
|
||||
iPhoneSimulator,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import '../base/context.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../doctor.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import 'xcode.dart';
|
||||
|
||||
XcodeValidator get xcodeValidator => context.get<XcodeValidator>();
|
||||
@@ -18,36 +19,36 @@ class XcodeValidator extends DoctorValidator {
|
||||
ValidationType xcodeStatus = ValidationType.missing;
|
||||
String xcodeVersionInfo;
|
||||
|
||||
if (xcode.isInstalled) {
|
||||
if (globals.xcode.isInstalled) {
|
||||
xcodeStatus = ValidationType.installed;
|
||||
|
||||
messages.add(ValidationMessage(userMessages.xcodeLocation(xcode.xcodeSelectPath)));
|
||||
messages.add(ValidationMessage(userMessages.xcodeLocation(globals.xcode.xcodeSelectPath)));
|
||||
|
||||
xcodeVersionInfo = xcode.versionText;
|
||||
xcodeVersionInfo = globals.xcode.versionText;
|
||||
if (xcodeVersionInfo.contains(',')) {
|
||||
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
|
||||
}
|
||||
messages.add(ValidationMessage(xcode.versionText));
|
||||
messages.add(ValidationMessage(globals.xcode.versionText));
|
||||
|
||||
if (!xcode.isInstalledAndMeetsVersionCheck) {
|
||||
if (!globals.xcode.isInstalledAndMeetsVersionCheck) {
|
||||
xcodeStatus = ValidationType.partial;
|
||||
messages.add(ValidationMessage.error(
|
||||
userMessages.xcodeOutdated(kXcodeRequiredVersionMajor, kXcodeRequiredVersionMinor)
|
||||
));
|
||||
}
|
||||
|
||||
if (!xcode.eulaSigned) {
|
||||
if (!globals.xcode.eulaSigned) {
|
||||
xcodeStatus = ValidationType.partial;
|
||||
messages.add(ValidationMessage.error(userMessages.xcodeEula));
|
||||
}
|
||||
if (!xcode.isSimctlInstalled) {
|
||||
if (!globals.xcode.isSimctlInstalled) {
|
||||
xcodeStatus = ValidationType.partial;
|
||||
messages.add(ValidationMessage.error(userMessages.xcodeMissingSimct));
|
||||
}
|
||||
|
||||
} else {
|
||||
xcodeStatus = ValidationType.missing;
|
||||
if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) {
|
||||
if (globals.xcode.xcodeSelectPath == null || globals.xcode.xcodeSelectPath.isEmpty) {
|
||||
messages.add(ValidationMessage.error(userMessages.xcodeMissing));
|
||||
} else {
|
||||
messages.add(ValidationMessage.error(userMessages.xcodeIncomplete));
|
||||
|
||||
Reference in New Issue
Block a user