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

How can I compile proto files using Protobuf Editions #751

Open
yanivkr opened this issue Mar 17, 2024 · 4 comments · May be fixed by #768
Open

How can I compile proto files using Protobuf Editions #751

yanivkr opened this issue Mar 17, 2024 · 4 comments · May be fixed by #768

Comments

@yanivkr
Copy link

yanivkr commented Mar 17, 2024

Im using the plugin wit 4.26.0 protoc version and I try to compile a file that looks like this:

edition = "2023";

package foo;

message TestEditionMessage {
    string message = 1;
}

and it results with the following error:

protoc: stdout: . stderr: TestEdition.proto: This file uses editions, but --experimental_editions has not been enabled. This syntax is experimental and should be avoided.

Is there a way to pass this flag to the proto compiler?

@yonik
Copy link

yonik commented Jul 29, 2024

If using cmake, use the PROTOC_OPTIONS in protobuf_generate. Example:

protobuf_generate(TARGET myproto LANGUAGE cpp
        PROTOC_OPTIONS --experimental_editions)
protobuf_generate(TARGET myproto LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
        PROTOC_OPTIONS --experimental_editions)

@waqaslam
Copy link

waqaslam commented Dec 4, 2024

If using cmake, use the PROTOC_OPTIONS in protobuf_generate. Example:

protobuf_generate(TARGET myproto LANGUAGE cpp
        PROTOC_OPTIONS --experimental_editions)
protobuf_generate(TARGET myproto LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
        PROTOC_OPTIONS --experimental_editions)

any idea how we can fix the issue in windows?

@waqaslam
Copy link

waqaslam commented Dec 4, 2024

For windows, I got it fixed by using a newer version of protoc.

artifact = 'com.google.protobuf:protoc:4.29.0'

@scr-oath
Copy link

This plugin is a gradle plugin - I'm not quite sure where cmake would come into the mix here. I tried upgrading to the latest protoc, but I can't figure out how to pass the --experimental_editions flag. It seems that only options (things added to the --language_out flag) are allowed/documented.

    protoc {
        artifact = "com.google.protobuf:protoc:4.29.1"
    }

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