Skip to content

[pigeon] add support for multiple swift outputs - #12720

Open
tarrinneal wants to merge 1 commit into
flutter:mainfrom
tarrinneal:multi-output-swift
Open

[pigeon] add support for multiple swift outputs#12720
tarrinneal wants to merge 1 commit into
flutter:mainfrom
tarrinneal:multi-output-swift

Conversation

@tarrinneal

Copy link
Copy Markdown
Contributor

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for multiple output locations in the Swift generator via swiftOut and --swift_out. It updates option parsing, internal option models, and generation adapters to handle multiple paths, and adds corresponding unit tests. The review feedback suggests improving Windows compatibility by using platform-agnostic path.join instead of path.posix.join for file operations, and replacing backslashes with forward slashes before extracting file names from paths.

if (outputPath == 'stdout') {
stdout.write(content);
} else {
final file = File(path.posix.join(options.basePath ?? '', outputPath));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using path.posix.join forces POSIX-style forward slashes as path separators. Since this code is performing local file system operations (File(...)), it is better to use platform-agnostic path.join to ensure correct path resolution on Windows and other platforms.

Suggested change
final file = File(path.posix.join(options.basePath ?? '', outputPath));
final file = File(path.join(options.basePath ?? '', outputPath));

Comment on lines +102 to 107
(swiftOuts?.firstOrNull ?? swiftOut ?? '')
.split('/')
.lastOrNull
?.split('.')
.firstOrNull ??
'',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

When running on Windows, file paths typically use backslashes (\\) as separators. Splitting only by / will fail to extract the file name correctly, leading to invalid or colliding class names (e.g., C:\\path\\to\\file.swift would result in C:\\path\\to\\file instead of file). Replacing backslashes with forward slashes before splitting resolves this issue.

Suggested change
(swiftOuts?.firstOrNull ?? swiftOut ?? '')
.split('/')
.lastOrNull
?.split('.')
.firstOrNull ??
'',
(swiftOuts?.firstOrNull ?? swiftOut ?? '')
.replaceAll('\\', '/')
.split('/')
.lastOrNull
?.split('.')
.firstOrNull ??
'',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pigeon] Allow multiple output locations for generated Swift

1 participant