diff --git a/examples/flutter_gallery/fuchsia/meta/flutter_gallery.cmx b/examples/flutter_gallery/fuchsia/meta/flutter_gallery.cmx new file mode 100644 index 00000000000..42bef318461 --- /dev/null +++ b/examples/flutter_gallery/fuchsia/meta/flutter_gallery.cmx @@ -0,0 +1,18 @@ +{ + "program": { + "data": "data/flutter_gallery" + }, + "sandbox": { + "services": [ + "fuchsia.cobalt.LoggerFactory", + "fuchsia.fonts.Provider", + "fuchsia.logger.LogSink", + "fuchsia.modular.Clipboard", + "fuchsia.sys.Environment", + "fuchsia.sys.Launcher", + "fuchsia.ui.input.ImeService", + "fuchsia.ui.policy.Presenter", + "fuchsia.ui.scenic.Scenic" + ] + } +} diff --git a/examples/hello_world/fuchsia/meta/hello_world.cmx b/examples/hello_world/fuchsia/meta/hello_world.cmx new file mode 100644 index 00000000000..f68343617fa --- /dev/null +++ b/examples/hello_world/fuchsia/meta/hello_world.cmx @@ -0,0 +1,18 @@ +{ + "program": { + "data": "data/hello_world" + }, + "sandbox": { + "services": [ + "fuchsia.cobalt.LoggerFactory", + "fuchsia.fonts.Provider", + "fuchsia.logger.LogSink", + "fuchsia.modular.Clipboard", + "fuchsia.sys.Environment", + "fuchsia.sys.Launcher", + "fuchsia.ui.input.ImeService", + "fuchsia.ui.policy.Presenter", + "fuchsia.ui.scenic.Scenic" + ] + } +} diff --git a/packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart b/packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart index 80e43efb6af..07881278e45 100644 --- a/packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart +++ b/packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart @@ -102,7 +102,7 @@ class FuchsiaAmberCtl { /// the Fuchsia package server that it was accessing via [serverUrl]. Future pkgCtlRepoRemove(FuchsiaDevice device, FuchsiaPackageServer server) async { final String repoUrl = 'fuchsia-pkg://${server.name}'; - final RunResult result = await device.shell('pkgctl repo remove --repo-url $repoUrl'); + final RunResult result = await device.shell('pkgctl repo rm $repoUrl'); return result.exitCode == 0; } } diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index 142a7b9aa5f..d6271231e74 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -246,14 +246,25 @@ class FuchsiaDevice extends Device { printError('Failed to find a free port'); return LaunchResult.failed(); } + + // Try Start with a fresh package repo in case one was left over from a + // previous run. final Directory packageRepo = fs.directory(fs.path.join(getFuchsiaBuildDirectory(), '.pkg-repo')); - packageRepo.createSync(recursive: true); + try { + if (packageRepo.existsSync()) { + packageRepo.deleteSync(recursive: true); + } + packageRepo.createSync(recursive: true); + } catch (e) { + printError('Failed to create Fuchisa package repo directory ' + 'at ${packageRepo.path}: $e'); + return LaunchResult.failed(); + } final String appName = FlutterProject.current().manifest.appName; - final Status status = logger.startProgress( - 'Starting Fuchsia application...', + 'Starting Fuchsia application $appName...', timeout: null, ); FuchsiaPackageServer fuchsiaPackageServer; @@ -332,8 +343,7 @@ class FuchsiaDevice extends Device { } // Instruct tiles_ctl to start the app. - final String fuchsiaUrl = - 'fuchsia-pkg://$packageServerName/$appName#meta/$appName.cmx'; + final String fuchsiaUrl = 'fuchsia-pkg://$packageServerName/$appName#meta/$appName.cmx'; if (!await fuchsiaDeviceTools.tilesCtl.add(this, fuchsiaUrl, [])) { printError('Failed to add the app to tiles'); return LaunchResult.failed(); @@ -345,8 +355,15 @@ class FuchsiaDevice extends Device { await fuchsiaDeviceTools.amberCtl.pkgCtlRepoRemove(this, fuchsiaPackageServer); } // Shutdown the package server and delete the package repo; + printTrace('Shutting down the tool\'s package server.'); fuchsiaPackageServer?.stop(); - packageRepo.deleteSync(recursive: true); + printTrace('Removing the tool\'s package repo: at ${packageRepo.path}'); + try { + packageRepo.deleteSync(recursive: true); + } catch (e) { + printError('Failed to remove Fuchsia package repo directory ' + 'at ${packageRepo.path}: $e.'); + } status.cancel(); } diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart index 6b30946b98a..b991803315e 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_kernel_compiler.dart @@ -58,7 +58,9 @@ class FuchsiaKernelCompiler { '--filesystem-root', fsRoot, '--packages', '$multiRootScheme:///$relativePackagesFile', '--output', fs.path.join(outDir, '$appName.dil'), - '--no-link-platform', + // TODO(zra): Add back when this is supported again. + // See: https://github.com/flutter/flutter/issues/44925 + // '--no-link-platform', '--split-output-by-packages', '--manifest', manifestPath, '--component-name', appName,