flutter/packages/flutter_tools/lib/src/fuchsia/application_package.dart
Ian Hickson 449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00

83 lines
2.5 KiB
Dart

// Copyright 2014 The Flutter 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 'package:meta/meta.dart';
import '../application_package.dart';
import '../base/file_system.dart';
import '../build_info.dart';
import '../globals.dart';
import '../project.dart';
abstract class FuchsiaApp extends ApplicationPackage {
FuchsiaApp({@required String projectBundleId}) : super(id: projectBundleId);
/// Creates a new [FuchsiaApp] from a fuchsia sub project.
factory FuchsiaApp.fromFuchsiaProject(FuchsiaProject project) {
if (!project.existsSync()) {
// If the project doesn't exist at all the current hint to run flutter
// create is accurate.
return null;
}
return BuildableFuchsiaApp(
project: project,
);
}
/// Creates a new [FuchsiaApp] from an existing .far archive.
///
/// [applicationBinary] is the path to the .far archive.
factory FuchsiaApp.fromPrebuiltApp(FileSystemEntity applicationBinary) {
final FileSystemEntityType entityType = fs.typeSync(applicationBinary.path);
if (entityType != FileSystemEntityType.file) {
printError('File "${applicationBinary.path}" does not exist or is not a .far file. Use far archive.');
return null;
}
return PrebuiltFuchsiaApp(
farArchive: applicationBinary.path,
);
}
@override
String get displayName => id;
/// The location of the 'far' archive containing the built app.
File farArchive(BuildMode buildMode);
}
class PrebuiltFuchsiaApp extends FuchsiaApp {
PrebuiltFuchsiaApp({
@required String farArchive,
}) : _farArchive = farArchive,
// TODO(zra): Extract the archive and extract the id from meta/package.
super(projectBundleId: farArchive);
final String _farArchive;
@override
File farArchive(BuildMode buildMode) => fs.file(_farArchive);
@override
String get name => _farArchive;
}
class BuildableFuchsiaApp extends FuchsiaApp {
BuildableFuchsiaApp({this.project}) :
super(projectBundleId: project.project.manifest.appName);
final FuchsiaProject project;
@override
File farArchive(BuildMode buildMode) {
// TODO(zra): Distinguish among build modes.
final String outDir = getFuchsiaBuildDirectory();
final String pkgDir = fs.path.join(outDir, 'pkg');
final String appName = project.project.manifest.appName;
return fs.file(fs.path.join(pkgDir, '$appName-0.far'));
}
@override
String get name => project.project.manifest.appName;
}