Add json_options.proto and json_enumvalue_options.proto and/or gencode derived from them to release artifacts

* `protoc`: Included in zips alongside binary
* Java: Generated classes have been added to the Maven `util` artifact
* Ruby: Generated classes have been added to gems
* CMake: `.proto` files are included in installation

PiperOrigin-RevId: 957382561
This commit is contained in:
Jason Aragorn Tobias Lunn 2026-07-31 16:17:28 -07:00 committed by Copybara-Service
parent a5412936c7
commit 713b6a4a24
13 changed files with 147 additions and 53 deletions

View file

@ -98,15 +98,8 @@ include(${protobuf_SOURCE_DIR}/src/file_lists.cmake)
set(protobuf_HEADERS
${libprotobuf_hdrs}
${libprotoc_public_hdrs}
${wkt_protos_files}
${cpp_file_options_proto_proto_srcs}
${json_enumvalue_options_proto_proto_srcs}
${cpp_features_proto_proto_srcs}
${descriptor_proto_proto_srcs}
${plugin_proto_proto_srcs}
${c_sharp_features_proto_proto_srcs}
${java_features_proto_proto_srcs}
${go_features_proto_proto_srcs}
${release_all_options_protos_files}
)
if (protobuf_BUILD_LIBUPB)
list(APPEND protobuf_HEADERS ${libupb_hdrs})

View file

@ -45,6 +45,7 @@ google/protobuf/cpp_features.pb.h
google/protobuf/cpp_features.proto
google/protobuf/cpp_file_options.pb.h
google/protobuf/cpp_file_options.proto
google/protobuf/cpp_options.proto
google/protobuf/descriptor.h
google/protobuf/descriptor.pb.h
google/protobuf/descriptor.proto
@ -97,6 +98,7 @@ google/protobuf/json_enumvalue_options.pb.h
google/protobuf/json_enumvalue_options.proto
google/protobuf/json_enumvalue_options.upb.h
google/protobuf/json_enumvalue_options.upb_minitable.h
google/protobuf/json_options.proto
google/protobuf/map.h
google/protobuf/map_entry.h
google/protobuf/map_field.h

View file

@ -15,7 +15,7 @@ load("//upb/cmake:build_defs.bzl", "staleness_test")
filegroup(
name = "c_sharp_features_proto_srcs",
srcs = ["google/protobuf/c_sharp_features.proto"],
visibility = ["//:__subpackages__"],
visibility = ["//src/google/protobuf:__pkg__"],
)
proto_library(

View file

@ -3,7 +3,7 @@ load("//bazel:proto_library.bzl", "proto_library")
filegroup(
name = "go_features_proto_srcs",
srcs = ["google/protobuf/go_features.proto"],
visibility = ["//:__subpackages__"],
visibility = ["//src/google/protobuf:__pkg__"],
)
proto_library(

View file

@ -193,7 +193,7 @@ proto_library(
"//:__pkg__",
"//editions:__pkg__",
"//java/__subpackages__",
"//pkg:__pkg__",
"//src/google/protobuf:__pkg__",
],
deps = ["//:descriptor_proto"],
)
@ -211,8 +211,8 @@ filegroup(
name = "java_features_proto_srcs",
srcs = ["src/main/resources/google/protobuf/java_features.proto"],
visibility = [
"//pkg:__pkg__",
"//python:__pkg__",
"//src/google/protobuf:__pkg__",
],
)

View file

@ -1,18 +1,28 @@
load("@rules_java//java:java_library.bzl", "java_library")
load("//:protobuf.bzl", "internal_gen_well_known_protos_java")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//bazel:java_proto_library.bzl", "java_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_versioned_java_library")
load("//java/internal:testing.bzl", "junit_tests")
internal_gen_well_known_protos_java(
name = "gen_language_neutral_protos_java",
deps = [
"//:json_enumvalue_options_proto",
"//:json_options_proto",
],
)
java_library(
name = "util",
srcs = glob([
"src/main/java/com/google/protobuf/util/*.java",
]),
]) + [
":gen_language_neutral_protos_java",
],
visibility = ["//visibility:public"],
deps = [
":json_enumvalue_options_java_proto",
"//java/core",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_code_gson_gson",
@ -24,14 +34,15 @@ protobuf_versioned_java_library(
name = "util_bundle",
srcs = glob([
"src/main/java/com/google/protobuf/util/*.java",
]),
]) + [
":gen_language_neutral_protos_java",
],
automatic_module_name = "com.google.protobuf.util",
bundle_description = "Utilities for Protocol Buffers",
bundle_name = "Protocol Buffers [Util]",
bundle_symbolic_name = "com.google.protobuf.util",
visibility = ["//visibility:public"],
deps = [
":json_enumvalue_options_java_proto",
"//java/core",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_code_gson_gson",
@ -45,6 +56,9 @@ protobuf_java_export(
deploy_env = ["//java/core"],
maven_coordinates = "com.google.protobuf:protobuf-java-util:%s" % PROTOBUF_JAVA_VERSION,
pom_template = "pom_template.xml",
resources = [
"//src/google/protobuf:json_options_proto_srcs",
],
tags = ["manual"],
visibility = ["//java:__pkg__"],
runtime_deps = [":util_bundle"],

View file

@ -0,0 +1,10 @@
<project name="generate-sources">
<echo message="Running protoc ..."/>
<mkdir dir="${generated.sources.dir}"/>
<exec executable="${protoc}">
<arg value="--java_out=${generated.sources.dir}"/>
<arg value="--proto_path=${protobuf.source.dir}"/>
<arg value="${protobuf.source.dir}/google/protobuf/json_options.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/json_enumvalue_options.proto"/>
</exec>
</project>

View file

@ -13,14 +13,9 @@ package_naming(
)
pkg_files(
name = "wkt_protos_files",
name = "release_all_options_protos_files",
srcs = [
"//:well_known_type_protos",
"//csharp:c_sharp_features_proto_srcs",
"//go:go_features_proto_srcs",
"//java/core:java_features_proto_srcs",
"//src/google/protobuf:cpp_features_proto_srcs",
"//src/google/protobuf:descriptor_proto_srcs",
"//src/google/protobuf:release_all_options_proto_srcs",
],
prefix = "include/google/protobuf",
visibility = ["//visibility:private"],
@ -92,7 +87,7 @@ pkg_zip(
":compiler_plugin_protos_files",
":protoc_files",
":protoc_readme",
":wkt_protos_files",
":release_all_options_protos_files",
],
package_file_name = "protoc-{version}-{platform}.zip",
package_variables = ":protobuf_pkg_naming",
@ -118,16 +113,9 @@ gen_file_lists(
":protoc-gen-upbdefs": "protoc-gen-upbdefs",
":protoc-gen-upb_minitable": "protoc-gen-upb_minitable",
# Protos:
"//src/google/protobuf:well_known_type_protos": "wkt_protos",
"//src/google/protobuf:cpp_file_options_proto": "cpp_file_options_proto",
"//src/google/protobuf:cpp_features_proto": "cpp_features_proto",
"//src/google/protobuf:descriptor_proto": "descriptor_proto",
"//src/google/protobuf:json_enumvalue_options_proto": "json_enumvalue_options_proto",
"//src/google/protobuf:json_enumvalue_options_cc_proto": "json_enumvalue_options_cc_proto",
"//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
"//csharp:c_sharp_features_proto": "c_sharp_features_proto",
"//java/core:java_features_proto": "java_features_proto,src/google/protobuf/compiler/java/",
"//go:go_features_proto": "go_features_proto,go/",
"//src/google/protobuf:release_all_options_proto_srcs": "release_all_options_protos",
# Test libraries:
":common_test": "common_test",

View file

@ -26,21 +26,9 @@ py_dist_module(
)
py_proto_library(
name = "well_known_proto_py_pb2",
name = "language_neutral_protos_py_pb2",
deps = [
"//:any_proto",
"//:api_proto",
"//:descriptor_proto",
"//:duration_proto",
"//:empty_proto",
"//:field_mask_proto",
"//:json_enumvalue_options_proto",
"//:json_options_proto",
"//:source_context_proto",
"//:struct_proto",
"//:timestamp_proto",
"//:type_proto",
"//:wrappers_proto",
"//src/google/protobuf:language_neutral_protos",
],
)
@ -246,9 +234,9 @@ selects.config_setting_group(
)
pkg_files(
name = "generated_wkt",
name = "generated_bootstrap",
srcs = [
":well_known_proto_py_pb2",
":language_neutral_protos_py_pb2",
"//src/google/protobuf:descriptor_upb_c_proto",
"//src/google/protobuf:descriptor_upb_minitable_proto",
"//src/google/protobuf:descriptor_upb_reflection_proto",
@ -315,7 +303,7 @@ pkg_tar(
srcs = [
":dist_source_files",
":filegroup_source_files",
":generated_wkt",
":generated_bootstrap",
":generated_wkt_compiler",
":utf8_range_source_files",
"//python:python_source_files",
@ -409,9 +397,9 @@ py_wheel(
}),
version = PROTOBUF_PYTHON_VERSION,
deps = [
":language_neutral_protos_py_pb2",
":message_mod",
":plugin_py_pb2",
":well_known_proto_py_pb2",
"//:python_srcs",
],
)
@ -449,8 +437,8 @@ py_wheel(
}),
version = PROTOBUF_PYTHON_VERSION,
deps = [
":language_neutral_protos_py_pb2",
":plugin_py_pb2",
":well_known_proto_py_pb2",
"//:python_srcs",
],
)

View file

@ -105,7 +105,11 @@ def _py_proto_library_aspect_impl(target, ctx):
[_get_real_short_path(file) for file in proto_sources],
progress_message = "Generating Python protos for :" + ctx.label.name,
)
outs_depset = depset(srcs)
transitive_py_sources = [dep[PyInfo].transitive_sources for dep in ctx.rule.attr.deps if PyInfo in dep] if hasattr(ctx.rule.attr, "deps") else []
outs_depset = depset(
direct = srcs,
transitive = transitive_py_sources,
)
return [
PyInfo(transitive_sources = outs_depset),
]

View file

@ -93,8 +93,8 @@ selects.config_setting_group(
internal_copy_files(
name = "copied_wkt_proto_files",
srcs = [
"//:well_known_type_protos",
"//src/google/protobuf:descriptor_proto_srcs",
"//src/google/protobuf:language_neutral_proto_srcs",
"//src/google/protobuf/compiler:plugin.proto",
],
strip_prefix = "src",

View file

@ -1237,6 +1237,99 @@ filegroup(
visibility = ["//:__subpackages__"],
)
# TODO: Revisit location of aggregate rules
filegroup(
name = "language_neutral_proto_srcs",
srcs = [
":json_options_proto_srcs",
":well_known_type_protos",
],
visibility = [
"//ruby:__pkg__",
],
)
filegroup(
name = "release_all_options_proto_srcs",
srcs = [
":cpp_release_options_proto_srcs",
":descriptor_proto_srcs",
":language_neutral_proto_srcs",
"//csharp:c_sharp_features_proto_srcs",
"//go:go_features_proto_srcs",
"//java/core:java_features_proto_srcs",
],
visibility = [
"//java/core:__pkg__",
"//pkg:__pkg__",
"//python/dist:__pkg__",
],
)
proto_library(
name = "language_neutral_protos",
srcs = [":language_neutral_proto_srcs"],
strip_import_prefix = "/src",
visibility = [
"//python/dist:__pkg__",
],
exports = [
":descriptor_proto",
],
deps = [
":descriptor_proto",
],
)
proto_library(
name = "release_all_options_protos",
srcs = [],
strip_import_prefix = "/src",
visibility = [
"//java/core:__pkg__",
"//pkg:__pkg__",
"//python/dist:__pkg__",
],
exports = [
":cpp_release_options_protos",
":descriptor_proto",
":language_neutral_protos",
# TODO: Create //lang:lang_release_options_protos targets for each language and
# depend on those instead.
"//csharp:c_sharp_features_proto",
"//go:go_features_proto",
"//java/core:java_features_proto",
],
deps = [
":cpp_release_options_protos",
":descriptor_proto",
":language_neutral_protos",
# TODO: Create //lang:lang_release_options_protos targets for each language and
# depend on those instead.
"//csharp:c_sharp_features_proto",
"//go:go_features_proto",
"//java/core:java_features_proto",
],
)
filegroup(
name = "cpp_release_options_proto_srcs",
srcs = glob(["cpp_*options.proto"]) + ["cpp_features.proto"],
)
proto_library(
name = "cpp_release_options_protos",
srcs = [":cpp_release_options_proto_srcs"],
strip_import_prefix = "/src",
deps = [":descriptor_proto"],
)
filegroup(
name = "json_options_proto_srcs",
srcs = glob(["json_*options.proto"]),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "testdata",
srcs = glob(["testdata/**/*"]) + [

View file

@ -12,3 +12,5 @@ edition = "2024";
package pb;
import public "google/protobuf/json_enumvalue_options.proto";
option java_package = "com.google.protobuf.util";