Skip to content

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Feb 28, 2025

Modifications:

  • Give the protobuf generator its own config struct
  • Use it in the protoc-gen-grpc-swift options
  • Add new options for module names and propagate them through to the config
  • Use the custom module names where applicable

Result:

  • Generated code can include different module name imports.

Modifications:

- Give the protobuf generator its own config struct
- Use it in the protoc-gen-grpc-swift options
- Add new options for module names and propagate them through to the
  config
- Use the custom module names where applicable

Result:

- Generated code can include different module name imports.
Package.swift Outdated
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "2.0.0"
branch: "main"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is temporary so that CI runs, we'll need bump to a version containing grpc/grpc-swift#2201 once it's released.

@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Feb 28, 2025
@glbrntt glbrntt requested a review from gjcairo February 28, 2025 17:26
rnro and others added 6 commits March 5, 2025 14:52
Motivation:

It is no longer required.

Modifications:

Remove explicit 'GITHUB_ACTIONS=true' from workflows, it's now set
automatically.

Result:

Clearer config.
### Motivation:

To make it simpler to generate gRPC stubs with `protoc-gen-grpc-swift`
and `protoc-gen-swift`.

### Modifications:

* Add a new command plugin
* Refactor some errors

The command plugin can be invoked from the CLI as:
```
swift package generate-grpc-code-from-protos --import-path /path/to/Protos -- /path/to/Protos/HelloWorld.proto
```

The plugin has flexible configuration:
```
❯ swift package generate-grpc-code-from-protos --help
Usage: swift package generate-grpc-code-from-protos [flags] [--] [input files]

Flags:

  --servers                   Indicate that server code is to be generated. Generated by default.
  --no-servers                Indicate that server code is not to be generated. Generated by default.
  --clients                   Indicate that client code is to be generated. Generated by default.
  --no-clients                Indicate that client code is not to be generated. Generated by default.
  --messages                  Indicate that message code is to be generated. Generated by default.
  --no-messages               Indicate that message code is not to be generated. Generated by default.
  --file-naming               The naming scheme for output files [fullPath/pathToUnderscores/dropPath]. Defaults to fullPath.
  --access-level              The access level of the generated source [internal/public/package]. Defaults to internal.
  --access-level-on-imports   Whether imports should have explicit access levels. Defaults to false.
  --import-path               The directory in which to search for imports.
  --protoc-path               The path to the protoc binary.
  --output-path               The path into which the generated source files are created.
  --verbose                   Emit verbose output.
  --dry-run                   Print but do not execute the protoc commands.
  --help                      Print this help.
```
* When executing, the command prints the `protoc` invocations it uses
for ease of debugging. The `--dry-run` flag can be supplied for this
purpose or so that they may be extracted and used separately e.g. in a
script.
* If no `protoc` path is supplied then Swift Package Manager will
attempt to locate it.
* If no `output` directory is supplied then generated files are placed a
Swift Package Manager build directory.
  
### Result:

More convenient code generation

This PR is split out of
grpc#26

---------

Co-authored-by: George Barnett <[email protected]>
@glbrntt glbrntt marked this pull request as ready for review March 5, 2025 14:54
@glbrntt glbrntt merged commit 9cd9d4e into grpc:main Mar 5, 2025
25 checks passed
@glbrntt glbrntt deleted the module-names branch March 5, 2025 15:06
@glbrntt glbrntt added 🆕 semver/minor Adds new public API. and removed 🔨 semver/patch No public API change. labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants