[gen_l10n] Optionally generate list of inputs/outputs (#56490)

This commit is contained in:
Shi-Hao Hong
2020-05-07 11:46:02 -07:00
committed by GitHub
parent 8f7b2f9bee
commit 13501af6e6
3 changed files with 164 additions and 68 deletions

View File

@@ -105,6 +105,21 @@ void main(List<String> arguments) {
'Note that this flag does not affect other platforms such as mobile or '
'desktop.',
);
parser.addOption(
'gen-inputs-and-outputs-list',
valueHelp: 'path-to-output-directory',
help: 'When specified, the tool generates a JSON file containing the '
'tool\'s inputs and outputs named gen_l10n_inputs_and_outputs.json.'
'\n\n'
'This can be useful for keeping track of which files of the Flutter '
'project were used when generating the latest set of localizations. '
'For example, the Flutter tool\'s build system uses this file to '
'keep track of when to call gen_l10n during hot reload.\n\n'
'The value of this option is the directory where the JSON file will be '
'generated.'
'\n\n'
'When null, the JSON file will not be generated.'
);
final argslib.ArgResults results = parser.parse(arguments);
if (results['help'] == true) {
@@ -124,6 +139,7 @@ void main(List<String> arguments) {
final String headerString = results['header'] as String;
final String headerFile = results['header-file'] as String;
final bool useDeferredLoading = results['use-deferred-loading'] as bool;
final String inputsAndOutputsListPath = results['gen-inputs-and-outputs-list'] as String;
const local.LocalFileSystem fs = local.LocalFileSystem();
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);
@@ -140,9 +156,10 @@ void main(List<String> arguments) {
headerString: headerString,
headerFile: headerFile,
useDeferredLoading: useDeferredLoading,
inputsAndOutputsListPath: inputsAndOutputsListPath,
)
..loadResources()
..writeOutputFile()
..writeOutputFiles()
..outputUnimplementedMessages(untranslatedMessagesFile);
} on FileSystemException catch (e) {
exitWithError(e.message);