Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
7.7 KiB

load(
"@rules_pkg//:mappings.bzl",
"pkg_attributes",
"pkg_files",
)
Breaking change: make protobuf comply with the C++ layering check This check enforces that each C++ build target has the correct dependencies for all headers that it includes. We have many targets that were not correct with respect to this check, so I fixed them up. I also cleaned up the C++ targets related to the well-known types. I created a cc_proto_library() target for each one and removed the :wkt_cc_protos target, since this was necessary to satisfy the layering check. I deleted the //src/google/protobuf:protobuf_nowkt target and deprecated :protobuf_nowkt, because the distinction between the :protobuf and :protobuf_nowkt targets was not really correct. Neither one exposed the headers for the well-known types in a way that was valid with respect to the layering check, and the idea of bundling all the well-known types together is not idiomatic in Bazel anyway. This is a breaking change, because the //:protobuf target no longer bundles the well-known types. From now on they should be accessed through the new //:*_cc_proto aliases in our top-level package. I renamed the :port_def target to :port, which simplifies things a bit by matching our internal name. The original motivation for this change was that to move utf8_range onto our CI infrastructure, we needed to make its dependency rules_fuzzing compatible with Bazel 6. The rules_fuzzing project builds with the layering check, and I found that the process of upgrading it to Bazel 6 made it take a dependency on protobuf, which caused it to break due to layering violations. I was able to work around this, but it would still be nice to comply with the layering check so that we don't have to worry about this kind of thing in the future. PiperOrigin-RevId: 595516736
11 months ago
load("@rules_pkg//:pkg.bzl", "pkg_zip")
load("//:protobuf_release.bzl", "package_naming")
load(":build_systems.bzl", "gen_file_lists")
load(":cc_dist_library.bzl", "cc_dist_library")
package_naming(
name = "protobuf_pkg_naming",
)
pkg_files(
name = "wkt_protos_files",
srcs = [
3 years ago
"//:well_known_type_protos",
"//src/google/protobuf:descriptor_proto_srcs",
],
prefix = "include/google/protobuf",
visibility = ["//visibility:private"],
)
pkg_files(
name = "compiler_plugin_protos_files",
3 years ago
srcs = [
"//src/google/protobuf/compiler:compiler_plugin_protos_files",
3 years ago
],
prefix = "include/google/protobuf/compiler",
visibility = ["//visibility:private"],
)
################################################################################
# Generates protoc release artifacts.
################################################################################
genrule(
name = "protoc_readme",
outs = ["readme.txt"],
cmd = """
echo "Protocol Buffers - Google's data interchange format
Copyright 2008 Google Inc.
https://developers.google.com/protocol-buffers/
This package contains a precompiled binary version of the protocol buffer
compiler (protoc). This binary is intended for users who want to use Protocol
Buffers in languages other than C++ but do not want to compile protoc
themselves. To install, simply place this binary somewhere in your PATH.
If you intend to use the included well known types then don't forget to
copy the contents of the 'include' directory somewhere as well, for example
into '/usr/local/include/'.
Please refer to our official github site for more installation instructions:
https://github.com/protocolbuffers/protobuf" > $@
""",
visibility = ["//visibility:private"],
)
genrule(
name = "rename_protoc",
srcs = ["//:protoc_static"],
outs = ["bin/protoc"],
cmd = "cp $< $@",
tags = ["manual"],
)
genrule(
name = "rename_protoc_exe",
srcs = ["//:protoc_static"],
outs = ["bin/protoc.exe"],
cmd = "cp $< $@",
tags = ["manual"],
)
pkg_files(
name = "protoc_files",
srcs = select({
"//build_defs:config_win": ["bin/protoc.exe"],
"//conditions:default": ["bin/protoc"],
}),
attributes = pkg_attributes(mode = "0555"),
prefix = "bin/",
visibility = ["//visibility:private"],
)
pkg_zip(
name = "protoc_release",
srcs = [
":compiler_plugin_protos_files",
":protoc_files",
":protoc_readme",
":wkt_protos_files",
],
package_file_name = "protoc-{version}-{platform}.zip",
package_variables = ":protobuf_pkg_naming",
)
################################################################################
# Generated file lists for build systems
################################################################################
gen_file_lists(
name = "gen_src_file_lists",
testonly = 1,
out_stem = "src_file_lists",
src_libs = {
# {[source rule]: [name in generated file]}
# Libraries:
":protobuf": "libprotobuf",
":protobuf_lite": "libprotobuf_lite",
":protoc": "libprotoc",
# Protos:
"//src/google/protobuf:well_known_type_protos": "wkt_protos",
"//src/google/protobuf:cpp_features_proto": "cpp_features_proto",
"//src/google/protobuf:descriptor_proto": "descriptor_proto",
"//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
"//java/core:java_features_proto": "java_features_proto,src/google/protobuf/compiler/java/",
# Test libraries:
":common_test": "common_test",
":lite_test_util": "lite_test_util",
":test_util": "test_util",
# Tests and test-only protos:
"//src/google/protobuf:full_test_srcs": "protobuf_test",
"//src/google/protobuf:test_proto_all_srcs": "protobuf_test_protos",
"//src/google/protobuf:lite_test_srcs": "protobuf_lite_test",
"//src/google/protobuf:lite_test_proto_srcs": "protobuf_lite_test_protos",
"//src/google/protobuf/compiler:fake_plugin_srcs": "fake_plugin",
"//src/google/protobuf/compiler:test_srcs": "compiler_test",
"//src/google/protobuf/compiler:test_proto_srcs": "compiler_test_protos",
"//src/google/protobuf/compiler:test_plugin_srcs": "test_plugin",
"//src/google/protobuf/io:test_srcs": "io_test",
"//src/google/protobuf/util:test_srcs": "util_test",
"//src/google/protobuf/util:test_proto_srcs": "util_test_protos",
"//src/google/protobuf/stubs:test_srcs": "stubs_test",
},
)
################################################################################
# Protobuf runtime libraries.
################################################################################
cc_dist_library(
name = "protobuf_lite",
linkopts = select({
"//build_defs:config_msvc": [],
"//conditions:default": ["-lpthread"],
}),
tags = ["manual"],
deps = [
"//src/google/protobuf:arena_align",
"//src/google/protobuf:protobuf_lite",
],
)
cc_dist_library(
name = "protobuf",
linkopts = select({
"//build_defs:config_msvc": [],
"//conditions:default": [
"-lz",
"-lpthread",
],
}),
tags = ["manual"],
deps = [
Breaking change: make protobuf comply with the C++ layering check This check enforces that each C++ build target has the correct dependencies for all headers that it includes. We have many targets that were not correct with respect to this check, so I fixed them up. I also cleaned up the C++ targets related to the well-known types. I created a cc_proto_library() target for each one and removed the :wkt_cc_protos target, since this was necessary to satisfy the layering check. I deleted the //src/google/protobuf:protobuf_nowkt target and deprecated :protobuf_nowkt, because the distinction between the :protobuf and :protobuf_nowkt targets was not really correct. Neither one exposed the headers for the well-known types in a way that was valid with respect to the layering check, and the idea of bundling all the well-known types together is not idiomatic in Bazel anyway. This is a breaking change, because the //:protobuf target no longer bundles the well-known types. From now on they should be accessed through the new //:*_cc_proto aliases in our top-level package. I renamed the :port_def target to :port, which simplifies things a bit by matching our internal name. The original motivation for this change was that to move utf8_range onto our CI infrastructure, we needed to make its dependency rules_fuzzing compatible with Bazel 6. The rules_fuzzing project builds with the layering check, and I found that the process of upgrading it to Bazel 6 made it take a dependency on protobuf, which caused it to break due to layering violations. I was able to work around this, but it would still be nice to comply with the layering check so that we don't have to worry about this kind of thing in the future. PiperOrigin-RevId: 595516736
11 months ago
"//src/google/protobuf",
"//src/google/protobuf:arena_align",
"//src/google/protobuf:cmake_wkt_cc_proto",
"//src/google/protobuf/compiler:importer",
"//src/google/protobuf/json",
"//src/google/protobuf/util:delimited_message_util",
"//src/google/protobuf/util:differencer",
"//src/google/protobuf/util:field_mask_util",
"//src/google/protobuf/util:json_util",
"//src/google/protobuf/util:time_util",
"//src/google/protobuf/util:type_resolver_util",
],
)
cc_dist_library(
name = "protoc",
dist_deps = [
":protobuf",
":protobuf_lite",
],
tags = ["manual"],
deps = [
"//src/google/protobuf/compiler:command_line_interface",
"//src/google/protobuf/compiler/cpp",
"//src/google/protobuf/compiler/csharp",
"//src/google/protobuf/compiler/java",
"//src/google/protobuf/compiler/objectivec",
"//src/google/protobuf/compiler/php",
"//src/google/protobuf/compiler/python",
"//src/google/protobuf/compiler/ruby",
"//src/google/protobuf/compiler/rust",
],
)
cc_dist_library(
name = "lite_test_util",
testonly = 1,
dist_deps = [":protobuf"],
tags = ["manual"],
deps = ["//src/google/protobuf:lite_test_util"],
)
cc_dist_library(
name = "test_util",
testonly = 1,
dist_deps = [
":common_test",
":lite_test_util",
":protoc",
":protobuf",
":protobuf_lite",
],
tags = ["manual"],
deps = [
"//src/google/protobuf:lite_test_util",
"//src/google/protobuf:test_util",
"//src/google/protobuf:test_util2",
"//src/google/protobuf:unredacted_debug_format_for_test",
"//src/google/protobuf/compiler:annotation_test_util",
"//src/google/protobuf/compiler/cpp:unittest_lib",
"//src/google/protobuf/io:test_zero_copy_stream",
],
)
cc_dist_library(
name = "common_test",
testonly = 1,
dist_deps = [
":protobuf",
":protobuf_lite",
":protoc",
],
tags = ["manual"],
deps = [
"//src/google/protobuf:internal_visibility_for_testing",
"//src/google/protobuf:test_textproto",
"//src/google/protobuf/compiler:command_line_interface_tester",
"//src/google/protobuf/compiler:mock_code_generator",
"//src/google/protobuf/testing",
],
)