Unverified Commit 6118eaa0 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Check for iOS simulator SDK during AOT validation instead of assuming x86 (#72834)

parent 27f29e75
...@@ -66,10 +66,14 @@ abstract class AotAssemblyBase extends Target { ...@@ -66,10 +66,14 @@ abstract class AotAssemblyBase extends Target {
if (targetPlatform != TargetPlatform.ios) { if (targetPlatform != TargetPlatform.ios) {
throw Exception('aot_assembly is only supported for iOS applications.'); throw Exception('aot_assembly is only supported for iOS applications.');
} }
if (darwinArchs.contains(DarwinArch.x86_64)) {
final String sdkRoot = environment.defines[kSdkRoot];
final EnvironmentType environmentType =
environmentTypeFromSdkroot(environment.fileSystem.directory(sdkRoot));
if (environmentType == EnvironmentType.simulator) {
throw Exception( throw Exception(
'release/profile builds are only supported for physical devices. ' 'release/profile builds are only supported for physical devices. '
'attempted to build for $darwinArchs.' 'attempted to build for simulator.'
); );
} }
final String codeSizeDirectory = environment.defines[kCodeSizeDirectory]; final String codeSizeDirectory = environment.defines[kCodeSizeDirectory];
...@@ -95,7 +99,7 @@ abstract class AotAssemblyBase extends Target { ...@@ -95,7 +99,7 @@ abstract class AotAssemblyBase extends Target {
mainPath: environment.buildDir.childFile('app.dill').path, mainPath: environment.buildDir.childFile('app.dill').path,
outputPath: environment.fileSystem.path.join(buildOutputPath, getNameForDarwinArch(darwinArch)), outputPath: environment.fileSystem.path.join(buildOutputPath, getNameForDarwinArch(darwinArch)),
darwinArch: darwinArch, darwinArch: darwinArch,
sdkRoot: environment.defines[kSdkRoot], sdkRoot: sdkRoot,
bitcode: bitcode, bitcode: bitcode,
quiet: true, quiet: true,
splitDebugInfo: splitDebugInfo, splitDebugInfo: splitDebugInfo,
......
...@@ -469,7 +469,7 @@ void main() { ...@@ -469,7 +469,7 @@ void main() {
'-arch', '-arch',
'armv7', 'armv7',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-c', '-c',
'$build/armv7/snapshot_assembly.S', '$build/armv7/snapshot_assembly.S',
'-o', '-o',
...@@ -481,7 +481,7 @@ void main() { ...@@ -481,7 +481,7 @@ void main() {
'-arch', '-arch',
'arm64', 'arm64',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-c', '-c',
'$build/arm64/snapshot_assembly.S', '$build/arm64/snapshot_assembly.S',
'-o', '-o',
...@@ -505,7 +505,7 @@ void main() { ...@@ -505,7 +505,7 @@ void main() {
'-install_name', '-install_name',
'@rpath/App.framework/App', '@rpath/App.framework/App',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-o', '-o',
'$build/armv7/App.framework/App', '$build/armv7/App.framework/App',
'$build/armv7/snapshot_assembly.o', '$build/armv7/snapshot_assembly.o',
...@@ -528,7 +528,7 @@ void main() { ...@@ -528,7 +528,7 @@ void main() {
'-install_name', '-install_name',
'@rpath/App.framework/App', '@rpath/App.framework/App',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-o', '-o',
'$build/arm64/App.framework/App', '$build/arm64/App.framework/App',
'$build/arm64/snapshot_assembly.o', '$build/arm64/snapshot_assembly.o',
...@@ -543,7 +543,7 @@ void main() { ...@@ -543,7 +543,7 @@ void main() {
]), ]),
]); ]);
iosEnvironment.defines[kIosArchs] ='armv7 arm64'; iosEnvironment.defines[kIosArchs] ='armv7 arm64';
iosEnvironment.defines[kSdkRoot] = 'path/to/sdk'; iosEnvironment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
await const AotAssemblyProfile().build(iosEnvironment); await const AotAssemblyProfile().build(iosEnvironment);
...@@ -557,7 +557,7 @@ void main() { ...@@ -557,7 +557,7 @@ void main() {
testUsingContext('AotAssemblyProfile with bitcode sends correct argument to snapshotter (one arch)', () async { testUsingContext('AotAssemblyProfile with bitcode sends correct argument to snapshotter (one arch)', () async {
iosEnvironment.defines[kIosArchs] = 'arm64'; iosEnvironment.defines[kIosArchs] = 'arm64';
iosEnvironment.defines[kBitcodeFlag] = 'true'; iosEnvironment.defines[kBitcodeFlag] = 'true';
iosEnvironment.defines[kSdkRoot] = 'path/to/sdk'; iosEnvironment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
final String build = iosEnvironment.buildDir.path; final String build = iosEnvironment.buildDir.path;
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
...@@ -575,7 +575,7 @@ void main() { ...@@ -575,7 +575,7 @@ void main() {
'-arch', '-arch',
'arm64', 'arm64',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
// Contains bitcode flag. // Contains bitcode flag.
'-fembed-bitcode', '-fembed-bitcode',
'-c', '-c',
...@@ -603,7 +603,7 @@ void main() { ...@@ -603,7 +603,7 @@ void main() {
// Contains bitcode flag. // Contains bitcode flag.
'-fembed-bitcode', '-fembed-bitcode',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-o', '-o',
'$build/arm64/App.framework/App', '$build/arm64/App.framework/App',
'$build/arm64/snapshot_assembly.o', '$build/arm64/snapshot_assembly.o',
...@@ -629,7 +629,7 @@ void main() { ...@@ -629,7 +629,7 @@ void main() {
testUsingContext('AotAssemblyRelease configures gen_snapshot with code size directory', () async { testUsingContext('AotAssemblyRelease configures gen_snapshot with code size directory', () async {
iosEnvironment.defines[kCodeSizeDirectory] = 'code_size_1'; iosEnvironment.defines[kCodeSizeDirectory] = 'code_size_1';
iosEnvironment.defines[kIosArchs] = 'arm64'; iosEnvironment.defines[kIosArchs] = 'arm64';
iosEnvironment.defines[kSdkRoot] = 'path/to/sdk'; iosEnvironment.defines[kSdkRoot] = 'path/to/iPhoneOS.sdk';
iosEnvironment.defines[kBitcodeFlag] = 'true'; iosEnvironment.defines[kBitcodeFlag] = 'true';
final String build = iosEnvironment.buildDir.path; final String build = iosEnvironment.buildDir.path;
processManager.addCommands(<FakeCommand>[ processManager.addCommands(<FakeCommand>[
...@@ -650,7 +650,7 @@ void main() { ...@@ -650,7 +650,7 @@ void main() {
'-arch', '-arch',
'arm64', 'arm64',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
// Contains bitcode flag. // Contains bitcode flag.
'-fembed-bitcode', '-fembed-bitcode',
'-c', '-c',
...@@ -678,7 +678,7 @@ void main() { ...@@ -678,7 +678,7 @@ void main() {
// Contains bitcode flag. // Contains bitcode flag.
'-fembed-bitcode', '-fembed-bitcode',
'-isysroot', '-isysroot',
'path/to/sdk', 'path/to/iPhoneOS.sdk',
'-o', '-o',
'$build/arm64/App.framework/App', '$build/arm64/App.framework/App',
'$build/arm64/snapshot_assembly.o', '$build/arm64/snapshot_assembly.o',
......
...@@ -181,21 +181,21 @@ void main() { ...@@ -181,21 +181,21 @@ void main() {
Platform: () => macPlatform, Platform: () => macPlatform,
}); });
testUsingContext('AotAssemblyRelease throws exception if asked to build for x86 target', () async { testUsingContext('AotAssemblyRelease throws exception if asked to build for simulator', () async {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final Environment environment = Environment.test( final Environment environment = Environment.test(
fileSystem.currentDirectory, fileSystem.currentDirectory,
defines: <String, String>{ defines: <String, String>{
kTargetPlatform: 'ios', kTargetPlatform: 'ios',
kSdkRoot: 'path/to/sdk', kSdkRoot: 'path/to/iPhoneSimulator.sdk',
kBuildMode: 'release',
kIosArchs: 'x86_64',
}, },
processManager: processManager, processManager: processManager,
artifacts: artifacts, artifacts: artifacts,
logger: logger, logger: logger,
fileSystem: fileSystem, fileSystem: fileSystem,
); );
environment.defines[kBuildMode] = 'release';
environment.defines[kIosArchs] = 'x86_64';
expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>() expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>()
.having( .having(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment