From c0742652982333a0e8c407ba0b7b1ec6920a6f4c Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 20 Oct 2016 01:32:45 -0700 Subject: [PATCH] Add support for building on Fuchsia (#6415) This patch makes it possible to build Flutter apps that use the framework on Fuchsia. --- packages/flutter/BUILD.gn | 20 +++++++++++++++++++ .../flutter_tools/bin/fuchsia_builder.dart | 2 ++ packages/flutter_tools/lib/src/asset.dart | 5 +++-- packages/flutter_tools/lib/src/flx.dart | 4 ++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 packages/flutter/BUILD.gn diff --git a/packages/flutter/BUILD.gn b/packages/flutter/BUILD.gn new file mode 100644 index 0000000000..b956764340 --- /dev/null +++ b/packages/flutter/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/dart/dart_package.gni") + +dart_package("flutter") { + package_name = "flutter" + + source_dir = "lib" + + deps = [ + "//third_party/dart-pkg/pub/async", + "//third_party/dart-pkg/pub/collection", + "//third_party/dart-pkg/pub/http_parser", + "//third_party/dart-pkg/pub/intl", + "//third_party/dart-pkg/pub/meta", + "//third_party/dart-pkg/pub/vector_math", + ] +} diff --git a/packages/flutter_tools/bin/fuchsia_builder.dart b/packages/flutter_tools/bin/fuchsia_builder.dart index 3eca9afc66..ccebe47b25 100644 --- a/packages/flutter_tools/bin/fuchsia_builder.dart +++ b/packages/flutter_tools/bin/fuchsia_builder.dart @@ -9,6 +9,7 @@ import 'package:args/args.dart'; import '../lib/src/base/context.dart'; import '../lib/src/base/logger.dart'; +import '../lib/src/cache.dart'; import '../lib/src/flx.dart'; import '../lib/src/globals.dart'; @@ -48,6 +49,7 @@ Future main(List args) async { printError('Missing option! All options must be specified.'); exit(1); } + Cache.flutterRoot = Platform.environment['FLUTTER_ROOT']; String outputPath = argResults[_kOptionOutput]; final int buildResult = await build( snapshotterPath: argResults[_kOptionSnapshotter], diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index 19331bea80..21fd0a9658 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -68,10 +68,12 @@ class AssetBundle { Future build({ String manifestPath: defaultManifestPath, String workingDirPath, + String packagesPath, bool includeRobotoFonts: true, bool reportLicensedPackages: false }) async { workingDirPath ??= getAssetBuildDirectory(); + packagesPath ??= path.absolute(PackageMap.globalPackagesPath); Object manifest = _loadFlutterYamlManifest(manifestPath); if (manifest == null) { // No manifest file found for this application. @@ -88,8 +90,7 @@ class AssetBundle { _lastBuildTimestamp = new DateTime.now(); - final PackageMap packageMap = - new PackageMap(path.join(assetBasePath, '.packages')); + final PackageMap packageMap = new PackageMap(packagesPath); Map<_Asset, List<_Asset>> assetVariants = _parseAssets( packageMap, diff --git a/packages/flutter_tools/lib/src/flx.dart b/packages/flutter_tools/lib/src/flx.dart index c159c55c97..b0ced7bac5 100644 --- a/packages/flutter_tools/lib/src/flx.dart +++ b/packages/flutter_tools/lib/src/flx.dart @@ -118,6 +118,7 @@ Future build({ outputPath: outputPath, privateKeyPath: privateKeyPath, workingDirPath: workingDirPath, + packagesPath: packagesPath, includeRobotoFonts: includeRobotoFonts, reportLicensedPackages: reportLicensedPackages ); @@ -129,11 +130,13 @@ Future assemble({ String outputPath, String privateKeyPath: defaultPrivateKeyPath, String workingDirPath, + String packagesPath, bool includeRobotoFonts: true, bool reportLicensedPackages: false }) async { outputPath ??= defaultFlxOutputPath; workingDirPath ??= getAssetBuildDirectory(); + packagesPath ??= path.absolute(PackageMap.globalPackagesPath); printTrace('Building $outputPath'); // Build the asset bundle. @@ -141,6 +144,7 @@ Future assemble({ int result = await assetBundle.build( manifestPath: manifestPath, workingDirPath: workingDirPath, + packagesPath: packagesPath, includeRobotoFonts: includeRobotoFonts, reportLicensedPackages: reportLicensedPackages );