Support for placing an AOT dylib in the flx.  Part of Fuchsia AOT sup… (#9240)

Support for placing an AOT dylib in the flx.  Part of Fuchsia AOT support.

diff --git a/packages/flutter_tools/bin/fuchsia_builder.dart b/packages/flutter_tools/bin/fuchsia_builder.dart
index 6d9f237..99f08cc 100644
--- a/packages/flutter_tools/bin/fuchsia_builder.dart
+++ b/packages/flutter_tools/bin/fuchsia_builder.dart
@@ -24,6 +24,7 @@
 const String _kOptionOutput = 'output-file';
 const String _kOptionHeader = 'header';
 const String _kOptionSnapshot = 'snapshot';
+const String _kOptionDylib = 'dylib';
 const String _kOptionWorking = 'working-dir';
 const String _kOptionManifest = 'manifest';
 const String _kOptionDepFile = 'depfile';
@@ -32,7 +33,6 @@
   _kOptionPackages,
   _kOptionOutput,
   _kOptionHeader,
-  _kOptionSnapshot,
   _kOptionWorking,
   _kOptionDepFile,
   _kOptionBuildRoot,
@@ -60,6 +60,7 @@
     ..addOption(_kOptionPackages, help: 'The .packages file')
     ..addOption(_kOptionOutput, help: 'The generated flx file')
     ..addOption(_kOptionHeader, help: 'The header of the flx file')
+    ..addOption(_kOptionDylib, help: 'The generated AOT dylib file')
     ..addOption(_kOptionSnapshot, help: 'The generated snapshot file')
     ..addOption(_kOptionWorking,
         help: 'The directory where to put temporary files')
@@ -75,9 +76,12 @@
   Cache.flutterRoot = platform.environment['FLUTTER_ROOT'];
   final String outputPath = argResults[_kOptionOutput];
   try {
+    final String snapshotPath = argResults[_kOptionSnapshot];
+    final String dylibPath = argResults[_kOptionDylib];
     final List<String> dependencies = await assemble(
       outputPath: outputPath,
-      snapshotFile: fs.file(argResults[_kOptionSnapshot]),
+      snapshotFile: snapshotPath == null ? null : fs.file(snapshotPath),
+      dylibFile: dylibPath == null ? null : fs.file(dylibPath),
       workingDirPath: argResults[_kOptionWorking],
       packagesPath: argResults[_kOptionPackages],
       manifestPath: argResults[_kOptionManifest] ?? defaultManifestPath,
diff --git a/packages/flutter_tools/lib/src/flx.dart b/packages/flutter_tools/lib/src/flx.dart
index 48464db..b4b9114 100644
--- a/packages/flutter_tools/lib/src/flx.dart
+++ b/packages/flutter_tools/lib/src/flx.dart
@@ -27,6 +27,7 @@
 
 const String _kKernelKey = 'kernel_blob.bin';
 const String _kSnapshotKey = 'snapshot_blob.bin';
+const String _kDylibKey = 'libapp.so';
 
 Future<int> createSnapshot({
   @required String mainPath,
@@ -114,6 +115,7 @@
   String manifestPath,
   DevFSContent kernelContent,
   File snapshotFile,
+  File dylibFile,
   String outputPath,
   String privateKeyPath: defaultPrivateKeyPath,
   String workingDirPath,
@@ -151,6 +153,8 @@
     zipBuilder.entries[_kKernelKey] = kernelContent;
   if (snapshotFile != null)
     zipBuilder.entries[_kSnapshotKey] = new DevFSFileContent(snapshotFile);
+  if (dylibFile != null)
+    zipBuilder.entries[_kDylibKey] = new DevFSFileContent(dylibFile);
 
   ensureDirectoryExists(outputPath);