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

Allow restricting the output languages for given proto files #2432

Open
Goldziher opened this issue Sep 11, 2023 · 3 comments
Open

Allow restricting the output languages for given proto files #2432

Goldziher opened this issue Sep 11, 2023 · 3 comments

Comments

@Goldziher
Copy link

Hi,

So the issue I have is that I am using buf to generate clients and servers for multiple languages (4 and counting). I need some proto files to generate code only in go, others in a couple of languages, and others in all languages. There is not way for me to do this now using a single workspace, or am I missing something?

I would love to have some simple configuration (exclude / include, etc.) or an ability to next buf.gen files in sub folders rather than have these top level. As it stands now, I have to generate a large amount of completely useless code.

@Goldziher
Copy link
Author

So, perhaps this can be done with exclude and include keywords. For example:

version: v1
managed:
    enabled: true
    optimize_for: LITE_RUNTIME
plugins:
    # typescript
    - plugin: buf.build/community/timostamm-protobuf-ts
      out: gen/ts
      exclude: [service1, service2]
    # golang
    - plugin: buf.build/grpc/go
      include: [service1]
      out: gen/go
      opt:
          - paths=source_relative
    - plugin: buf.build/protocolbuffers/go
      include: [service1]
      out: gen/go
      opt:
          - paths=source_relative
    # swift
    - plugin: buf.build/grpc/swift
      include: [service2]
      out: gen/swift
    - plugin: buf.build/apple/swift
      include: [service2]
      out: gen/swift

Note the addition of include / exclude.

@bufdev
Copy link
Member

bufdev commented Nov 27, 2023

You can use seperate buf.gen.yamls via the buf generate --template flag, and you can also do separate buf generate calls that themselves use separate --path and --exclude-path values.

@Goldziher
Copy link
Author

Goldziher commented Nov 27, 2023

You can use seperate buf.gen.yamls via the buf generate --template flag, and you can also do separate buf generate calls that themselves use separate --path and --exclude-path values.

Thanks, but this pretty much defeats the purpose of having a tool like this. The moment using it becomes more cumbersum than using protoc directly, there is really no point for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants