mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* 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
96 lines
3.5 KiB
Dart
96 lines
3.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 'dart:async';
|
|
|
|
import 'package:args/args.dart';
|
|
import 'package:flutter_tools/src/asset.dart' hide defaultManifestPath;
|
|
import 'package:flutter_tools/src/base/context.dart';
|
|
import 'package:flutter_tools/src/base/file_system.dart' as libfs;
|
|
import 'package:flutter_tools/src/base/io.dart';
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
import 'package:flutter_tools/src/context_runner.dart';
|
|
import 'package:flutter_tools/src/devfs.dart';
|
|
import 'package:flutter_tools/src/bundle.dart';
|
|
import 'package:flutter_tools/src/globals.dart';
|
|
import 'package:flutter_tools/src/reporting/reporting.dart';
|
|
|
|
const String _kOptionPackages = 'packages';
|
|
const String _kOptionAsset = 'asset-dir';
|
|
const String _kOptionManifest = 'manifest';
|
|
const String _kOptionAssetManifestOut = 'asset-manifest-out';
|
|
const String _kOptionComponentName = 'component-name';
|
|
const List<String> _kRequiredOptions = <String>[
|
|
_kOptionPackages,
|
|
_kOptionAsset,
|
|
_kOptionAssetManifestOut,
|
|
_kOptionComponentName,
|
|
];
|
|
|
|
Future<void> main(List<String> args) {
|
|
return runInContext<void>(() => run(args), overrides: <Type, Generator>{
|
|
Usage: () => DisabledUsage(),
|
|
});
|
|
}
|
|
|
|
Future<void> writeFile(libfs.File outputFile, DevFSContent content) async {
|
|
outputFile.createSync(recursive: true);
|
|
final List<int> data = await content.contentsAsBytes();
|
|
outputFile.writeAsBytesSync(data);
|
|
}
|
|
|
|
Future<void> run(List<String> args) async {
|
|
final ArgParser parser = ArgParser()
|
|
..addOption(_kOptionPackages, help: 'The .packages file')
|
|
..addOption(_kOptionAsset,
|
|
help: 'The directory where to put temporary files')
|
|
..addOption(_kOptionManifest, help: 'The manifest file')
|
|
..addOption(_kOptionAssetManifestOut)
|
|
..addOption(_kOptionComponentName);
|
|
final ArgResults argResults = parser.parse(args);
|
|
if (_kRequiredOptions
|
|
.any((String option) => !argResults.options.contains(option))) {
|
|
printError('Missing option! All options must be specified.');
|
|
exit(1);
|
|
}
|
|
Cache.flutterRoot = platform.environment['FLUTTER_ROOT'];
|
|
|
|
final String assetDir = argResults[_kOptionAsset] as String;
|
|
final AssetBundle assets = await buildAssets(
|
|
manifestPath: argResults[_kOptionManifest] as String ?? defaultManifestPath,
|
|
assetDirPath: assetDir,
|
|
packagesPath: argResults[_kOptionPackages] as String,
|
|
includeDefaultFonts: false,
|
|
);
|
|
|
|
if (assets == null) {
|
|
print('Unable to find assets.');
|
|
exit(1);
|
|
}
|
|
|
|
final List<Future<void>> calls = <Future<void>>[];
|
|
assets.entries.forEach((String fileName, DevFSContent content) {
|
|
final libfs.File outputFile = libfs.fs.file(libfs.fs.path.join(assetDir, fileName));
|
|
calls.add(writeFile(outputFile, content));
|
|
});
|
|
await Future.wait<void>(calls);
|
|
|
|
final String outputMan = argResults[_kOptionAssetManifestOut] as String;
|
|
await writeFuchsiaManifest(assets, argResults[_kOptionAsset] as String, outputMan, argResults[_kOptionComponentName] as String);
|
|
}
|
|
|
|
Future<void> writeFuchsiaManifest(AssetBundle assets, String outputBase, String fileDest, String componentName) async {
|
|
|
|
final libfs.File destFile = libfs.fs.file(fileDest);
|
|
await destFile.create(recursive: true);
|
|
final libfs.IOSink outFile = destFile.openWrite();
|
|
|
|
for (String path in assets.entries.keys) {
|
|
outFile.write('data/$componentName/$path=$outputBase/$path\n');
|
|
}
|
|
await outFile.flush();
|
|
await outFile.close();
|
|
}
|