add enable_editions and remove php editions support flag

pull/16712/head
Brent Shaffer 11 months ago
parent e95b76e4e5
commit a1c41add7d
  1. 1
      editions/BUILD
  2. 8
      protobuf.bzl
  3. 2
      src/google/protobuf/compiler/php/php_generator.h

@ -239,6 +239,7 @@ java_lite_proto_library(
internal_php_proto_library( internal_php_proto_library(
name = "test_messages_proto3_editions_php_proto", name = "test_messages_proto3_editions_php_proto",
testonly = 1, testonly = 1,
enable_editions = True,
srcs = ["golden/test_messages_proto3_editions.proto"], srcs = ["golden/test_messages_proto3_editions.proto"],
outs = [ outs = [
"GPBMetadata/TestMessagesProto3Editions.php", "GPBMetadata/TestMessagesProto3Editions.php",

@ -80,6 +80,7 @@ def _proto_gen_impl(ctx):
srcs = ctx.files.srcs srcs = ctx.files.srcs
langs = ctx.attr.langs or [] langs = ctx.attr.langs or []
out_type = ctx.attr.out_type out_type = ctx.attr.out_type
enable_editions = ctx.attr.enable_editions
deps = depset(direct = ctx.files.srcs) deps = depset(direct = ctx.files.srcs)
source_dir = _SourceDir(ctx) source_dir = _SourceDir(ctx)
gen_dir = _GenDir(ctx).rstrip("/") gen_dir = _GenDir(ctx).rstrip("/")
@ -130,6 +131,8 @@ def _proto_gen_impl(ctx):
generated_files = [] generated_files = []
for src in srcs: for src in srcs:
args = [] args = []
if enable_editions:
args.append("--experimental_editions")
in_gen_dir = src.root.path == gen_dir in_gen_dir = src.root.path == gen_dir
if in_gen_dir: if in_gen_dir:
@ -231,6 +234,7 @@ Args:
srcs: Protocol Buffers definition files (.proto) to run the protocol compiler srcs: Protocol Buffers definition files (.proto) to run the protocol compiler
against. against.
deps: a list of dependency labels; must be other proto libraries. deps: a list of dependency labels; must be other proto libraries.
enable_editions: if true, sets the --experimental_editions flag.
includes: a list of include paths to .proto files. includes: a list of include paths to .proto files.
protoc: the label of the protocol compiler to generate the sources. protoc: the label of the protocol compiler to generate the sources.
plugin: the label of the protocol compiler plugin to be passed to the protocol plugin: the label of the protocol compiler plugin to be passed to the protocol
@ -247,6 +251,7 @@ _proto_gen = rule(
attrs = { attrs = {
"srcs": attr.label_list(allow_files = True), "srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = [ProtoGenInfo]), "deps": attr.label_list(providers = [ProtoGenInfo]),
"enable_editions": attr.bool(),
"includes": attr.string_list(), "includes": attr.string_list(),
"protoc": attr.label( "protoc": attr.label(
cfg = "exec", cfg = "exec",
@ -655,6 +660,7 @@ def _source_proto_library(
protoc = Label("//:protoc"), protoc = Label("//:protoc"),
testonly = None, testonly = None,
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
enable_editions = False,
**kwargs): **kwargs):
"""Bazel rule to create generated protobuf code from proto source files for """Bazel rule to create generated protobuf code from proto source files for
languages not well supported by Bazel yet. This will output the generated languages not well supported by Bazel yet. This will output the generated
@ -699,6 +705,7 @@ def _source_proto_library(
srcs = proto_deps, srcs = proto_deps,
protoc = protoc, protoc = protoc,
includes = includes, includes = includes,
enable_editions = enable_editions,
) )
full_deps.append(":%s_deps_genproto" % name) full_deps.append(":%s_deps_genproto" % name)
@ -712,6 +719,7 @@ def _source_proto_library(
protoc = protoc, protoc = protoc,
testonly = testonly, testonly = testonly,
visibility = visibility, visibility = visibility,
enable_editions = enable_editions,
) )
native.filegroup( native.filegroup(

@ -37,7 +37,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
std::string* error) const override; std::string* error) const override;
uint64_t GetSupportedFeatures() const override { uint64_t GetSupportedFeatures() const override {
return Feature::FEATURE_PROTO3_OPTIONAL | Feature::FEATURE_SUPPORTS_EDITIONS; return Feature::FEATURE_PROTO3_OPTIONAL;
} }
Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; } Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }

Loading…
Cancel
Save