forked from firka/flutter
This reverts commit f865ac7e25.
This commit is contained in:
@@ -88,12 +88,6 @@ class CommandHelp {
|
||||
'Detach (terminate "flutter run" but leave application running).',
|
||||
);
|
||||
|
||||
CommandHelpOption _g;
|
||||
CommandHelpOption get g => _g ??= _makeOption(
|
||||
'g',
|
||||
'Run source code generators.'
|
||||
);
|
||||
|
||||
CommandHelpOption _h;
|
||||
CommandHelpOption get h => _h ??= _makeOption(
|
||||
'h',
|
||||
|
||||
@@ -486,7 +486,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
|
||||
);
|
||||
|
||||
if (debuggingOptions.buildInfo.isDebug) {
|
||||
await runSourceGenerators();
|
||||
// Full restart is always false for web, since the extra recompile is wasteful.
|
||||
final UpdateFSReport report = await _updateDevFS(fullRestart: false);
|
||||
if (report.success) {
|
||||
|
||||
@@ -134,12 +134,6 @@ abstract class Target {
|
||||
/// A list of zero or more depfiles, located directly under {BUILD_DIR}.
|
||||
List<String> get depfiles => const <String>[];
|
||||
|
||||
/// Whether this target can be executed with the given [environment].
|
||||
///
|
||||
/// Returning `true` will cause [build] to be skipped. This is equivalent
|
||||
/// to a build that produces no outputs.
|
||||
bool canSkip(Environment environment) => false;
|
||||
|
||||
/// The action which performs this build step.
|
||||
Future<void> build(Environment environment);
|
||||
|
||||
@@ -760,26 +754,18 @@ class _BuildInstance {
|
||||
updateGraph();
|
||||
return succeeded;
|
||||
}
|
||||
// Clear old inputs. These will be replaced with new inputs/outputs
|
||||
// after the target is run. In the case of a runtime skip, each list
|
||||
// must be empty to ensure the previous outputs are purged.
|
||||
node.inputs.clear();
|
||||
node.outputs.clear();
|
||||
logger.printTrace('${node.target.name}: Starting due to ${node.invalidatedReasons}');
|
||||
await node.target.build(environment);
|
||||
logger.printTrace('${node.target.name}: Complete');
|
||||
|
||||
// Check if we can skip via runtime dependencies.
|
||||
final bool runtimeSkip = node.target.canSkip(environment);
|
||||
if (runtimeSkip) {
|
||||
logger.printTrace('Skipping target: ${node.target.name}');
|
||||
skipped = true;
|
||||
} else {
|
||||
logger.printTrace('${node.target.name}: Starting due to ${node.invalidatedReasons}');
|
||||
await node.target.build(environment);
|
||||
logger.printTrace('${node.target.name}: Complete');
|
||||
node.inputs.addAll(node.target.resolveInputs(environment).sources);
|
||||
node.outputs.addAll(node.target.resolveOutputs(environment).sources);
|
||||
}
|
||||
node.inputs
|
||||
..clear()
|
||||
..addAll(node.target.resolveInputs(environment).sources);
|
||||
node.outputs
|
||||
..clear()
|
||||
..addAll(node.target.resolveOutputs(environment).sources);
|
||||
|
||||
// If we were missing the depfile, resolve input files after executing the
|
||||
// If we were missing the depfile, resolve input files after executing the
|
||||
// target so that all file hashes are up to date on the next run.
|
||||
if (node.missingDepfile) {
|
||||
await fileCache.diffFileList(node.inputs);
|
||||
|
||||
@@ -17,7 +17,6 @@ import '../depfile.dart';
|
||||
import '../exceptions.dart';
|
||||
import 'assets.dart';
|
||||
import 'icon_tree_shaker.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
/// The define to pass a [BuildMode].
|
||||
const String kBuildMode = 'BuildMode';
|
||||
@@ -184,9 +183,7 @@ class KernelSnapshot extends Target {
|
||||
];
|
||||
|
||||
@override
|
||||
List<Target> get dependencies => const <Target>[
|
||||
GenerateLocalizationsTarget(),
|
||||
];
|
||||
List<Target> get dependencies => <Target>[];
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
// 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 'package:process/process.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import '../../artifacts.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/io.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../convert.dart';
|
||||
import '../../globals.dart' as globals;
|
||||
import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
|
||||
const String _kDependenciesFileName = 'gen_l10n_inputs_and_outputs.json';
|
||||
|
||||
/// Run the localizations generation script with the configuration [options].
|
||||
Future<void> generateLocalizations({
|
||||
@required LocalizationOptions options,
|
||||
@required String flutterRoot,
|
||||
@required FileSystem fileSystem,
|
||||
@required ProcessManager processManager,
|
||||
@required Logger logger,
|
||||
@required Directory projectDir,
|
||||
@required String dartBinaryPath,
|
||||
@required Directory dependenciesDir,
|
||||
}) async {
|
||||
final String genL10nPath = fileSystem.path.join(
|
||||
flutterRoot,
|
||||
'dev',
|
||||
'tools',
|
||||
'localization',
|
||||
'bin',
|
||||
'gen_l10n.dart',
|
||||
);
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
dartBinaryPath,
|
||||
genL10nPath,
|
||||
'--gen-inputs-and-outputs-list=${dependenciesDir.path}',
|
||||
if (options.arbDirectory != null)
|
||||
'--arb-dir=${options.arbDirectory.toFilePath()}',
|
||||
if (options.templateArbFile != null)
|
||||
'--template-arb-file=${options.templateArbFile.toFilePath()}',
|
||||
if (options.outputLocalizationsFile != null)
|
||||
'--output-localization-file=${options.outputLocalizationsFile.toFilePath()}',
|
||||
if (options.untranslatedMessagesFile != null)
|
||||
'--untranslated-messages-file=${options.untranslatedMessagesFile.toFilePath()}',
|
||||
if (options.outputClass != null)
|
||||
'--output-class=${options.outputClass}',
|
||||
if (options.headerFile != null)
|
||||
'--header-file=${options.headerFile.toFilePath()}',
|
||||
if (options.header != null)
|
||||
'--header=${options.header}',
|
||||
if (options.deferredLoading != null)
|
||||
'--use-deferred-loading',
|
||||
if (options.preferredSupportedLocales != null)
|
||||
'--preferred-supported-locales=${options.preferredSupportedLocales}',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
logger.printError(result.stdout + result.stderr as String);
|
||||
throw Exception();
|
||||
}
|
||||
}
|
||||
|
||||
/// A build step that runs the generate localizations script from
|
||||
/// dev/tool/localizations.
|
||||
class GenerateLocalizationsTarget extends Target {
|
||||
const GenerateLocalizationsTarget();
|
||||
|
||||
@override
|
||||
List<Target> get dependencies => <Target>[];
|
||||
|
||||
@override
|
||||
List<Source> get inputs => <Source>[
|
||||
// This is added as a convenience for developing the tool.
|
||||
const Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/localizations.dart'),
|
||||
// TODO(jonahwilliams): once https://github.com/flutter/flutter/issues/56321 is
|
||||
// complete, we should add the artifact as a dependency here. Since the tool runs
|
||||
// this code from source, looking up each dependency will be cumbersome.
|
||||
];
|
||||
|
||||
@override
|
||||
String get name => 'gen_localizations';
|
||||
|
||||
@override
|
||||
List<Source> get outputs => <Source>[];
|
||||
|
||||
@override
|
||||
List<String> get depfiles => <String>['gen_localizations.d'];
|
||||
|
||||
@override
|
||||
bool canSkip(Environment environment) {
|
||||
final File configFile = environment.projectDir.childFile('l10n.yaml');
|
||||
return !configFile.existsSync();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> build(Environment environment) async {
|
||||
final File configFile = environment.projectDir.childFile('l10n.yaml');
|
||||
assert(configFile.existsSync());
|
||||
|
||||
final LocalizationOptions options = parseLocalizationsOptions(
|
||||
file: configFile,
|
||||
logger: globals.logger,
|
||||
);
|
||||
final DepfileService depfileService = DepfileService(
|
||||
logger: environment.logger,
|
||||
fileSystem: environment.fileSystem,
|
||||
);
|
||||
|
||||
await generateLocalizations(
|
||||
fileSystem: environment.fileSystem,
|
||||
flutterRoot: environment.flutterRootDir.path,
|
||||
logger: environment.logger,
|
||||
processManager: environment.processManager,
|
||||
options: options,
|
||||
projectDir: environment.projectDir,
|
||||
dartBinaryPath: environment.artifacts
|
||||
.getArtifactPath(Artifact.engineDartBinary),
|
||||
dependenciesDir: environment.buildDir,
|
||||
);
|
||||
final Map<String, Object> dependencies = json
|
||||
.decode(environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()) as Map<String, Object>;
|
||||
final Depfile depfile = Depfile(
|
||||
<File>[
|
||||
configFile,
|
||||
for (dynamic inputFile in dependencies['inputs'] as List<dynamic>)
|
||||
environment.fileSystem.file(inputFile)
|
||||
],
|
||||
<File>[
|
||||
for (dynamic outputFile in dependencies['outputs'] as List<dynamic>)
|
||||
environment.fileSystem.file(outputFile)
|
||||
]
|
||||
);
|
||||
depfileService.writeToFile(
|
||||
depfile,
|
||||
environment.buildDir.childFile('gen_localizations.d'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Typed configuration from the localizations config file.
|
||||
class LocalizationOptions {
|
||||
const LocalizationOptions({
|
||||
this.arbDirectory,
|
||||
this.templateArbFile,
|
||||
this.outputLocalizationsFile,
|
||||
this.untranslatedMessagesFile,
|
||||
this.header,
|
||||
this.outputClass,
|
||||
this.preferredSupportedLocales,
|
||||
this.headerFile,
|
||||
this.deferredLoading,
|
||||
});
|
||||
|
||||
/// The `--arb-dir` argument.
|
||||
///
|
||||
/// The directory where all localization files should reside.
|
||||
final Uri arbDirectory;
|
||||
|
||||
/// The `--template-arb-file` argument.
|
||||
///
|
||||
/// This URI is relative to [arbDirectory].
|
||||
final Uri templateArbFile;
|
||||
|
||||
/// The `--output-localization-file` argument.
|
||||
///
|
||||
/// This URI is relative to [arbDirectory].
|
||||
final Uri outputLocalizationsFile;
|
||||
|
||||
/// The `--untranslated-messages-file` argument.
|
||||
///
|
||||
/// This URI is relative to [arbDirectory].
|
||||
final Uri untranslatedMessagesFile;
|
||||
|
||||
/// The `--header` argument.
|
||||
///
|
||||
/// The header to prepend to the generated Dart localizations
|
||||
final String header;
|
||||
|
||||
/// The `--output-class` argument.
|
||||
final String outputClass;
|
||||
|
||||
/// The `--preferred-supported-locales` argument.
|
||||
final String preferredSupportedLocales;
|
||||
|
||||
/// The `--header-file` argument.
|
||||
///
|
||||
/// A file containing the header to preprend to the generated
|
||||
/// Dart localizations.
|
||||
final Uri headerFile;
|
||||
|
||||
/// The `--use-deferred-loading` argument.
|
||||
///
|
||||
/// Whether to generate the Dart localization file with locales imported
|
||||
/// as deferred.
|
||||
final bool deferredLoading;
|
||||
}
|
||||
|
||||
/// Parse the localizations configuration options from [file].
|
||||
///
|
||||
/// Throws [Exception] if any of the contents are invalid. Returns a
|
||||
/// [LocalizationOptions] with all fields as `null` if the config file exists
|
||||
/// but is empty.
|
||||
LocalizationOptions parseLocalizationsOptions({
|
||||
@required File file,
|
||||
@required Logger logger,
|
||||
}) {
|
||||
final String contents = file.readAsStringSync();
|
||||
if (contents.trim().isEmpty) {
|
||||
return const LocalizationOptions();
|
||||
}
|
||||
final YamlNode yamlNode = loadYamlNode(file.readAsStringSync());
|
||||
if (yamlNode is! YamlMap) {
|
||||
logger.printError('Expected ${file.path} to contain a map, instead was $yamlNode');
|
||||
throw Exception();
|
||||
}
|
||||
final YamlMap yamlMap = yamlNode as YamlMap;
|
||||
return LocalizationOptions(
|
||||
arbDirectory: _tryReadUri(yamlMap, 'arb-dir', logger),
|
||||
templateArbFile: _tryReadUri(yamlMap, 'template-arb-file', logger),
|
||||
outputLocalizationsFile: _tryReadUri(yamlMap, 'output-localization-file', logger),
|
||||
untranslatedMessagesFile: _tryReadUri(yamlMap, 'untranslated-messages-file', logger),
|
||||
header: _tryReadString(yamlMap, 'header', logger),
|
||||
outputClass: _tryReadString(yamlMap, 'output-class', logger),
|
||||
preferredSupportedLocales: _tryReadString(yamlMap, 'preferred-supported-locales', logger),
|
||||
headerFile: _tryReadUri(yamlMap, 'header-file', logger),
|
||||
deferredLoading: _tryReadBool(yamlMap, 'use-deferred-loading', logger),
|
||||
);
|
||||
}
|
||||
|
||||
// Try to read a `bool` value or null from `yamlMap`, otherwise throw.
|
||||
bool _tryReadBool(YamlMap yamlMap, String key, Logger logger) {
|
||||
final Object value = yamlMap[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value is! bool) {
|
||||
logger.printError('Expected "$key" to have a bool value, instead was "$value"');
|
||||
throw Exception();
|
||||
}
|
||||
return value as bool;
|
||||
}
|
||||
|
||||
// Try to read a `String` value or null from `yamlMap`, otherwise throw.
|
||||
String _tryReadString(YamlMap yamlMap, String key, Logger logger) {
|
||||
final Object value = yamlMap[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value is! String) {
|
||||
logger.printError('Expected "$key" to have a String value, instead was "$value"');
|
||||
throw Exception();
|
||||
}
|
||||
return value as String;
|
||||
}
|
||||
|
||||
// Try to read a valid `Uri` or null from `yamlMap`, otherwise throw.
|
||||
Uri _tryReadUri(YamlMap yamlMap, String key, Logger logger) {
|
||||
final String value = _tryReadString(yamlMap, key, logger);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
final Uri uri = Uri.tryParse(value);
|
||||
if (uri == null) {
|
||||
logger.printError('"$value" must be a relative file URI');
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import '../build_system.dart';
|
||||
import '../depfile.dart';
|
||||
import 'assets.dart';
|
||||
import 'dart.dart';
|
||||
import 'localizations.dart';
|
||||
|
||||
/// Whether web builds should call the platform initialization logic.
|
||||
const String kInitializePlatform = 'InitializePlatform';
|
||||
@@ -133,8 +132,7 @@ class Dart2JSTarget extends Target {
|
||||
|
||||
@override
|
||||
List<Target> get dependencies => const <Target>[
|
||||
WebEntrypointTarget(),
|
||||
GenerateLocalizationsTarget(),
|
||||
WebEntrypointTarget()
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
import 'package:devtools_server/devtools_server.dart' as devtools_server;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import 'application_package.dart';
|
||||
import 'artifacts.dart';
|
||||
@@ -21,10 +21,7 @@ import 'base/signals.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'build_info.dart';
|
||||
import 'build_system/build_system.dart';
|
||||
import 'build_system/targets/localizations.dart';
|
||||
import 'bundle.dart';
|
||||
import 'cache.dart';
|
||||
import 'codegen.dart';
|
||||
import 'compile.dart';
|
||||
import 'convert.dart';
|
||||
@@ -801,40 +798,6 @@ abstract class ResidentRunner {
|
||||
throw '${fullRestart ? 'Restart' : 'Reload'} is not supported in $mode mode';
|
||||
}
|
||||
|
||||
|
||||
BuildResult _lastBuild;
|
||||
Environment _environment;
|
||||
Future<void> runSourceGenerators() async {
|
||||
_environment ??= Environment(
|
||||
artifacts: globals.artifacts,
|
||||
logger: globals.logger,
|
||||
cacheDir: globals.cache.getRoot(),
|
||||
engineVersion: globals.flutterVersion.engineRevision,
|
||||
fileSystem: globals.fs,
|
||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
||||
processManager: globals.processManager,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
);
|
||||
globals.logger.printTrace('Starting incremental build...');
|
||||
_lastBuild = await globals.buildSystem.buildIncremental(
|
||||
const GenerateLocalizationsTarget(),
|
||||
_environment,
|
||||
_lastBuild,
|
||||
);
|
||||
if (!_lastBuild.success) {
|
||||
for (final ExceptionMeasurement exceptionMeasurement in _lastBuild.exceptions.values) {
|
||||
globals.logger.printError(
|
||||
exceptionMeasurement.exception.toString(),
|
||||
stackTrace: globals.logger.isVerbose
|
||||
? exceptionMeasurement.stackTrace
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
globals.logger.printTrace('complete');
|
||||
}
|
||||
|
||||
/// Toggle whether canvaskit is being used for rendering, returning the new
|
||||
/// state.
|
||||
///
|
||||
@@ -1235,7 +1198,6 @@ abstract class ResidentRunner {
|
||||
commandHelp.p.print();
|
||||
commandHelp.o.print();
|
||||
commandHelp.z.print();
|
||||
commandHelp.g.print();
|
||||
} else {
|
||||
commandHelp.S.print();
|
||||
commandHelp.U.print();
|
||||
@@ -1373,9 +1335,6 @@ class TerminalHandler {
|
||||
case 'D':
|
||||
await residentRunner.detach();
|
||||
return true;
|
||||
case 'g':
|
||||
await residentRunner.runSourceGenerators();
|
||||
return true;
|
||||
case 'h':
|
||||
case 'H':
|
||||
case '?':
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:package_config/package_config.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:pool/pool.dart';
|
||||
|
||||
import 'base/async_guard.dart';
|
||||
|
||||
import 'base/context.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
@@ -365,7 +365,6 @@ class HotRunner extends ResidentRunner {
|
||||
// build, reducing overall initialization time. This is safe because the first
|
||||
// invocation of the frontend server produces a full dill file that the
|
||||
// subsequent invocation in devfs will not overwrite.
|
||||
await runSourceGenerators();
|
||||
if (device.generator != null) {
|
||||
startupTasks.add(
|
||||
device.generator.recompile(
|
||||
@@ -675,10 +674,6 @@ class HotRunner extends ResidentRunner {
|
||||
emulator = false;
|
||||
}
|
||||
final Stopwatch timer = Stopwatch()..start();
|
||||
|
||||
// Run source generation if needed.
|
||||
await runSourceGenerators();
|
||||
|
||||
if (fullRestart) {
|
||||
final OperationResult result = await _fullRestartHelper(
|
||||
targetPlatform: targetPlatform,
|
||||
@@ -1195,7 +1190,7 @@ class ProjectFileInvalidator {
|
||||
static const String _pubCachePathWindows = 'Pub/Cache';
|
||||
|
||||
// As of writing, Dart supports up to 32 asynchronous I/O threads per
|
||||
// isolate. We also want to avoid hitting platform limits on open file
|
||||
// isolate. We also want to avoid hitting platform limits on open file
|
||||
// handles/descriptors.
|
||||
//
|
||||
// This value was chosen based on empirical tests scanning a set of
|
||||
@@ -1228,6 +1223,7 @@ class ProjectFileInvalidator {
|
||||
if (_isNotInPubCache(uri)) uri,
|
||||
];
|
||||
final List<Uri> invalidatedFiles = <Uri>[];
|
||||
|
||||
if (asyncScanning) {
|
||||
final Pool pool = Pool(_kMaxPendingStats);
|
||||
final List<Future<void>> waitList = <Future<void>>[];
|
||||
|
||||
Reference in New Issue
Block a user