Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigeon] Recursively create output target files #4458

Merged
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.1.6

* Creates target files before trying to write to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Fixes generation failures when an output file is in a directory that doesn't already exist."


## 10.1.5

* Fixes import in generated Dart test output when overriding package name.
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'ast.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '10.1.5';
const String pigeonVersion = '10.1.6';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
2 changes: 2 additions & 0 deletions packages/pigeon/lib/pigeon_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ IOSink? _openSink(String? output, {String basePath = ''}) {
sink = stdout;
} else {
file = File(path.posix.join(basePath, output));
file.createSync(recursive: true);
sink = file.openWrite();
}
return sink;
Expand Down Expand Up @@ -472,6 +473,7 @@ class DartGeneratorAdapter implements GeneratorAdapter {
final DartOptions dartOptionsWithHeader = _dartOptionsWithCopyrightHeader(
options.dartOptions,
options.copyrightHeader,
dartOutPath: options.dartOut,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this change related to the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change to investigate something, but then I forgot to revert it. Later, I mistakenly assumed that I had made the change intentionally, and I apologize for that.

basePath: options.basePath ?? '',
);
const DartGenerator generator = DartGenerator();
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: pigeon
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
repository: https://github.com/flutter/packages/tree/main/packages/pigeon
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
version: 10.1.5 # This must match the version in lib/generator_tools.dart
version: 10.1.6 # This must match the version in lib/generator_tools.dart

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down
7 changes: 7 additions & 0 deletions packages/pigeon/tool/shared/test_suites.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ Future<int> _runCommandLineTests() async {
'--ast_out',
tempOutput
],
// Test writing a file in a directory that doesn't exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing final period.

<String>[
'--input',
'pigeons/message.dart',
'--dart_out',
'$tempDir/subdirectory/does/not/exist/message.g.dart',
],
];

int exitCode = 0;
Expand Down