diff --git a/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java b/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java index 1f5aaebba66..479ff691e05 100644 --- a/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java +++ b/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon import android.util.Log; diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index 4aa5169e7f3..8d9dc6e5f3f 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index 3467edf3c3c..48b22d65706 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation diff --git a/packages/pigeon/example/app/lib/src/messages.g.dart b/packages/pigeon/example/app/lib/src/messages.g.dart index 66ae5c55f33..ad7560805ec 100644 --- a/packages/pigeon/example/app/lib/src/messages.g.dart +++ b/packages/pigeon/example/app/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.h b/packages/pigeon/example/app/macos/Runner/messages.g.h index 5fb709ca3d2..f7cbe391105 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.h +++ b/packages/pigeon/example/app/macos/Runner/messages.g.h @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon #import diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.m b/packages/pigeon/example/app/macos/Runner/messages.g.m index 8a43bffac32..a74215d47f6 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.m +++ b/packages/pigeon/example/app/macos/Runner/messages.g.m @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" diff --git a/packages/pigeon/example/app/windows/runner/messages.g.cpp b/packages/pigeon/example/app/windows/runner/messages.g.cpp index 50053cf2334..a5fac7be46b 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.cpp +++ b/packages/pigeon/example/app/windows/runner/messages.g.cpp @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS diff --git a/packages/pigeon/example/app/windows/runner/messages.g.h b/packages/pigeon/example/app/windows/runner/messages.g.h index 917de2da37a..92ab57e3176 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.h +++ b/packages/pigeon/example/app/windows/runner/messages.g.h @@ -1,7 +1,7 @@ // Copyright 2013 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. -// Autogenerated from Pigeon (v10.1.2), do not edit directly. +// Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_MESSAGES_G_H_ diff --git a/packages/pigeon/tool/generate.dart b/packages/pigeon/tool/generate.dart index 02e28ad81c1..99be94b83e1 100644 --- a/packages/pigeon/tool/generate.dart +++ b/packages/pigeon/tool/generate.dart @@ -19,12 +19,21 @@ import 'shared/generation.dart'; const String _helpFlag = 'help'; const String _formatFlag = 'format'; +const String _files = 'files'; +const String _test = 'test'; +const String _example = 'example'; + +const List _fileGroups = [_test, _example]; Future main(List args) async { final ArgParser parser = ArgParser() ..addFlag(_formatFlag, abbr: 'f', help: 'Autoformats after generation.') ..addFlag(_helpFlag, - negatable: false, abbr: 'h', help: 'Print this reference.'); + negatable: false, abbr: 'h', help: 'Print this reference.') + ..addMultiOption(_files, + help: + 'Select specific groups of files to generate; $_test or $_example. Defaults to both.', + allowed: _fileGroups); final ArgResults argResults = parser.parse(args); if (argResults.wasParsed(_helpFlag)) { @@ -37,13 +46,29 @@ ${parser.usage}'''); final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath())); - print('Generating platform_test/ output...'); - final int generateExitCode = await generateTestPigeons(baseDir: baseDir); - if (generateExitCode == 0) { - print('Generation complete!'); - } else { - print('Generation failed; see above for errors.'); - exit(generateExitCode); + final List? toGenerate = + argResults.wasParsed(_files) ? argResults[_files] as List : null; + + if (toGenerate == null || toGenerate.contains(_test)) { + print('Generating platform_test/ output...'); + final int generateExitCode = await generateTestPigeons(baseDir: baseDir); + if (generateExitCode == 0) { + print('Generation complete!'); + } else { + print('Generation failed; see above for errors.'); + exit(generateExitCode); + } + } + + if (toGenerate == null || toGenerate.contains(_example)) { + print('Generating example/ output...'); + final int generateExitCode = await generateExamplePigeons(); + if (generateExitCode == 0) { + print('Generation complete!'); + } else { + print('Generation failed; see above for errors.'); + exit(generateExitCode); + } } if (argResults.wasParsed(_formatFlag)) { diff --git a/packages/pigeon/tool/run_tests.dart b/packages/pigeon/tool/run_tests.dart index 4d1c4fa2cc9..42ee8183808 100644 --- a/packages/pigeon/tool/run_tests.dart +++ b/packages/pigeon/tool/run_tests.dart @@ -90,10 +90,7 @@ Future _validateGeneratedExampleFiles() async { print('Validating generated files:'); print(' Generating example output...'); - final int generateExitCode = await runPigeon( - input: './example/app/pigeons/messages.dart', - basePath: './example/app', - ); + final int generateExitCode = await generateExamplePigeons(); if (generateExitCode != 0) { print('Generation failed; see above for errors.'); diff --git a/packages/pigeon/tool/shared/generation.dart b/packages/pigeon/tool/shared/generation.dart index ee54f2f263d..14370ad14af 100644 --- a/packages/pigeon/tool/shared/generation.dart +++ b/packages/pigeon/tool/shared/generation.dart @@ -45,6 +45,14 @@ String _javaFilenameForName(String inputName) { return specialCases[inputName] ?? _snakeToPascalCase(inputName); } +Future generateExamplePigeons() async { + return runPigeon( + input: './example/app/pigeons/messages.dart', + basePath: './example/app', + suppressVersion: true, + ); +} + Future generateTestPigeons({required String baseDir}) async { // TODO(stuartmorgan): Make this dynamic rather than hard-coded. Or eliminate // it entirely; see https://github.com/flutter/flutter/issues/115169.