Revert "Fall back to environment SDKROOT passed from Xcode (#52570)" (#52583)

This reverts commit 8e6e15f915.
This commit is contained in:
Jenn Magder 2020-03-13 18:29:09 -07:00 committed by GitHub
parent 8bff33e497
commit 73ea37eca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 39 deletions

View file

@ -225,7 +225,7 @@ class AOTSnapshotter {
final String assemblyO = globals.fs.path.join(outputPath, 'snapshot_assembly.o');
List<String> isysrootArgs;
if (isIOS) {
final String iPhoneSDKLocation = await globals.xcode.sdkLocation(SdkType.iPhone, globals.platform.environment);
final String iPhoneSDKLocation = await globals.xcode.sdkLocation(SdkType.iPhone);
if (iPhoneSDKLocation != null) {
isysrootArgs = <String>['-isysroot', iPhoneSDKLocation];
}

View file

@ -412,7 +412,7 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk, { bool in
'-Xlinker', '-rpath', '-Xlinker', '@executable_path/Frameworks',
'-Xlinker', '-rpath', '-Xlinker', '@loader_path/Frameworks',
'-install_name', '@rpath/App.framework/App',
'-isysroot', await globals.xcode.sdkLocation(sdk, globals.platform.environment),
'-isysroot', await globals.xcode.sdkLocation(sdk),
'-o', outputFile.path,
]);
} finally {

View file

@ -165,17 +165,14 @@ class Xcode {
);
}
Future<String> sdkLocation(SdkType sdk, Map<String, String> environment) async {
// If this is run an Xcode script build phase, the SDKROOT is already exported.
if (environment.containsKey('SDKROOT')) {
return environment['SDKROOT'];
}
Future<String> sdkLocation(SdkType sdk) async {
assert(sdk != null);
final RunResult runResult = await _processUtils.run(
<String>['xcrun', '--sdk', getNameForSdk(sdk), '--show-sdk-path'],
throwOnError: true,
);
if (runResult.exitCode != 0) {
throwToolExit('Could not find SDK location: ${runResult.stderr}');
throwToolExit('Could not find iPhone SDK location: ${runResult.stderr}');
}
return runResult.stdout.trim();
}

View file

@ -240,7 +240,7 @@ void main() {
mockAndroidSdk = MockAndroidSdk();
mockArtifacts = MockArtifacts();
mockXcode = MockXcode();
when(mockXcode.sdkLocation(any, any)).thenAnswer((_) => Future<String>.value(kSDKPath));
when(mockXcode.sdkLocation(any)).thenAnswer((_) => Future<String>.value(kSDKPath));
for (final BuildMode mode in BuildMode.values) {
when(mockArtifacts.getArtifactPath(Artifact.snapshotDart,

View file

@ -178,36 +178,6 @@ void main() {
expect(getNameForSdk(SdkType.iPhoneSimulator), 'iphonesimulator');
expect(getNameForSdk(SdkType.macOS), 'macosx');
});
group('SDK location', () {
const String sdkroot = 'Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk';
testWithoutContext('environment', () async {
expect(await xcode.sdkLocation(SdkType.iPhone, <String, String>{'SDKROOT': sdkroot}), sdkroot);
});
testWithoutContext('--show-sdk-path iphoneos', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 0, sdkroot, '')));
expect(await xcode.sdkLocation(SdkType.iPhone, <String, String>{}), sdkroot);
});
testWithoutContext('--show-sdk-path macosx', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'macosx', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 0, sdkroot, '')));
expect(await xcode.sdkLocation(SdkType.macOS, <String, String>{}), sdkroot);
});
testWithoutContext('--show-sdk-path fails', () async {
when(processManager.run(<String>['xcrun', '--sdk', 'iphoneos', '--show-sdk-path'])).thenAnswer((_) =>
Future<ProcessResult>.value(ProcessResult(1, 1, '', 'xcrun: error:')));
expect(() async => await xcode.sdkLocation(SdkType.iPhone, <String, String>{}),
throwsToolExit(message: 'Could not find SDK location'));
});
});
});
group('xcdevice', () {