From 2d726fc0c5dd559416b954921ba9090bcfde943a Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 24 May 2016 15:49:53 -0700 Subject: [PATCH] Build app.so instead of app.a on iOS (#4168) The app.a wasn't getting pulled into the main executable because we weren't referencing any of its symbols. Instead, create a dylib that can be packaged with the application and loaded at runtime. --- .../lib/src/commands/build_aot.dart | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index 71f1330d4ba..e012ddd1242 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -100,8 +100,12 @@ String buildAotSnapshot( } else { String artifactsDir = tools.getEngineArtifactsDirectory(platform, buildMode).path; entryPointsDir = artifactsDir; - String hostToolsDir = path.join(artifactsDir, getNameForHostPlatform(getCurrentHostPlatform())); - genSnapshot = path.join(hostToolsDir, 'gen_snapshot'); + if (platform == TargetPlatform.ios) { + genSnapshot = path.join(artifactsDir, 'gen_snapshot'); + } else { + String hostToolsDir = path.join(artifactsDir, getNameForHostPlatform(getCurrentHostPlatform())); + genSnapshot = path.join(hostToolsDir, 'gen_snapshot'); + } } Directory outputDir = new Directory(outputPath); @@ -224,7 +228,7 @@ String buildAotSnapshot( // On iOS, we use Xcode to compile the snapshot into a static library that the // end-developer can link into their app. if (platform == TargetPlatform.ios) { - printStatus('Building app.a...'); + printStatus('Building app.so...'); // These names are known to from the engine. const String kDartVmIsolateSnapshotBuffer = 'kDartVmIsolateSnapshotBuffer'; @@ -252,17 +256,16 @@ String buildAotSnapshot( runCheckedSync(['xcrun', 'cc', '-c', kDartVmIsolateSnapshotBufferC, '-o', kDartVmIsolateSnapshotBufferO]); runCheckedSync(['xcrun', 'cc', '-c', kDartIsolateSnapshotBufferC, '-o', kDartIsolateSnapshotBufferO]); - String appLib = path.join(outputDir.path, 'app.a'); + String appSo = path.join(outputDir.path, 'app.so'); - runCheckedSync(['rm', '-f', appLib]); - List archiveCommand = [ - 'xcrun', 'ar', 'rcs', appLib, + List linkCommand = [ + 'xcrun', 'ld', '-dylib', '-o', appSo, kDartVmIsolateSnapshotBufferO, kDartIsolateSnapshotBufferO, ]; if (!interpreter) - archiveCommand.add(assemblyO); - runCheckedSync(archiveCommand); + linkCommand.add(assemblyO); + runCheckedSync(linkCommand); } return outputPath;