3 Star 2 Fork 3

zhyulo/protobuf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BUILD.bazel 18.27 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("//bazel:java_proto_library.bzl", "java_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
licenses(["notice"])
exports_files([
"LICENSE",
"PrivacyInfo.xcprivacy",
])
################################################################################
# Well Known Types Proto Library Rules
#
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
################################################################################
# These proto_library rules can be used with one of the language specific proto
# library rules i.e. java_proto_library:
#
# java_proto_library(
# name = "any_java_proto",
# deps = ["@protobuf//:any_proto"],
# )
################################################################################
alias(
name = "any_proto",
actual = "//src/google/protobuf:any_proto",
visibility = ["//visibility:public"],
)
alias(
name = "api_proto",
actual = "//src/google/protobuf:api_proto",
visibility = ["//visibility:public"],
)
alias(
name = "duration_proto",
actual = "//src/google/protobuf:duration_proto",
visibility = ["//visibility:public"],
)
alias(
name = "empty_proto",
actual = "//src/google/protobuf:empty_proto",
visibility = ["//visibility:public"],
)
alias(
name = "field_mask_proto",
actual = "//src/google/protobuf:field_mask_proto",
visibility = ["//visibility:public"],
)
alias(
name = "source_context_proto",
actual = "//src/google/protobuf:source_context_proto",
visibility = ["//visibility:public"],
)
alias(
name = "struct_proto",
actual = "//src/google/protobuf:struct_proto",
visibility = ["//visibility:public"],
)
alias(
name = "timestamp_proto",
actual = "//src/google/protobuf:timestamp_proto",
visibility = ["//visibility:public"],
)
alias(
name = "type_proto",
actual = "//src/google/protobuf:type_proto",
visibility = ["//visibility:public"],
)
alias(
name = "wrappers_proto",
actual = "//src/google/protobuf:wrappers_proto",
visibility = ["//visibility:public"],
)
# C++ targets for the well-known types
alias(
name = "any_cc_proto",
actual = "//src/google/protobuf:any_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "api_cc_proto",
actual = "//src/google/protobuf:api_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "duration_cc_proto",
actual = "//src/google/protobuf:duration_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "empty_cc_proto",
actual = "//src/google/protobuf:empty_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "field_mask_cc_proto",
actual = "//src/google/protobuf:field_mask_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "source_context_cc_proto",
actual = "//src/google/protobuf:source_context_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "struct_cc_proto",
actual = "//src/google/protobuf:struct_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "timestamp_cc_proto",
actual = "//src/google/protobuf:timestamp_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "type_cc_proto",
actual = "//src/google/protobuf:type_cc_proto",
visibility = ["//visibility:public"],
)
alias(
name = "wrappers_cc_proto",
actual = "//src/google/protobuf:wrappers_cc_proto",
visibility = ["//visibility:public"],
)
# Source files: these are aliases to a filegroup, not a `proto_library`.
#
# (This is _probably_ not what you want.)
alias(
name = "lite_well_known_protos",
actual = "//src/google/protobuf:well_known_type_protos", # filegroup
visibility = ["//visibility:public"],
)
alias(
name = "well_known_type_protos",
actual = "//src/google/protobuf:well_known_type_protos", # filegroup
visibility = ["//visibility:public"],
)
# Built-in runtime protos: these are part of protobuf's internal
# implementation, but are not Well-Known Types.
alias(
name = "descriptor_proto",
actual = "//src/google/protobuf:descriptor_proto", # proto_library
visibility = ["//visibility:public"],
)
alias(
name = "descriptor_proto_srcs",
actual = "//src/google/protobuf:descriptor_proto_srcs", # filegroup
visibility = ["//visibility:public"],
)
alias(
name = "compiler_plugin_proto",
actual = "//src/google/protobuf/compiler:plugin_proto", # proto_library
visibility = ["//visibility:public"],
)
cc_library(
name = "cc_wkt_protos",
deprecation = "Only for backward compatibility. Do not use.",
visibility = ["//visibility:public"],
)
# Source protos that are typically part of the protobuf runtime.
#
# DEPRECATED: Prefer :well_known_type_protos for the Well-Known Types
# (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf)
# or :descriptor_proto(_srcs) for descriptor.proto (source), or
# :compiler_plugin_proto for compiler/plugin.proto.
filegroup(
name = "well_known_protos",
srcs = [
":descriptor_proto_srcs",
":well_known_type_protos",
"//src/google/protobuf/compiler:plugin.proto",
],
deprecation = "Prefer :well_known_type_protos instead.",
visibility = ["//visibility:public"],
)
################################################################################
# Protocol Buffers Compiler
################################################################################
alias(
name = "protoc_lib",
actual = "//src/google/protobuf/compiler:protoc_lib",
visibility = ["//visibility:public"],
)
cc_binary(
name = "protoc",
copts = COPTS,
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
cc_binary(
name = "protoc_static",
copts = COPTS,
features = select({
# This isn't possible on mac because there is no static library for lcrt0.o
"@platforms//os:osx": [],
"//build_defs:config_osx": [],
# When cross-compiling we need to statically link all C++ libraries.
"//conditions:default": ["fully_static_link"],
}),
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
################################################################################
# C++ runtime
################################################################################
# Expose the runtime for the proto_lang_toolchain so that it can also be used in
# a user-defined proto_lang_toolchain.
alias(
name = "protobuf",
actual = "//src/google/protobuf:protobuf_layering_check_legacy",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_nowkt",
actual = "//src/google/protobuf:protobuf_layering_check_legacy",
deprecation = "Use //:protobuf instead",
visibility = ["//visibility:public"],
)
# The "lite" runtime works for .proto files that specify the option:
# optimize_for = LITE_RUNTIME;
#
# The lite runtime does not include the `Reflection` APIs (including
# `Descriptor` and related types) or Well-Known Types.
#
# See also:
# https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#message
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
alias(
name = "protobuf_lite",
actual = "//src/google/protobuf:protobuf_lite",
visibility = ["//visibility:public"],
)
# This provides just the header files for use in projects that need to build
# shared libraries for dynamic loading. This target is available until Bazel
# adds native support for such use cases.
# TODO: Remove this target once the support gets added to Bazel.
alias(
name = "protobuf_headers",
actual = "//src/google/protobuf:protobuf_headers",
visibility = ["//visibility:public"],
)
alias(
name = "json",
actual = "//src/google/protobuf/json",
visibility = ["//visibility:public"],
)
alias(
name = "delimited_message_util",
actual = "//src/google/protobuf/util:delimited_message_util",
visibility = ["//visibility:public"],
)
alias(
name = "differencer",
actual = "//src/google/protobuf/util:differencer",
visibility = ["//visibility:public"],
)
alias(
name = "field_mask_util",
actual = "//src/google/protobuf/util:field_mask_util",
visibility = ["//visibility:public"],
)
alias(
name = "json_util",
actual = "//src/google/protobuf/util:json_util",
visibility = ["//visibility:public"],
)
alias(
name = "time_util",
actual = "//src/google/protobuf/util:time_util",
visibility = ["//visibility:public"],
)
alias(
name = "type_resolver",
actual = "//src/google/protobuf/util:type_resolver",
visibility = ["//visibility:public"],
)
alias(
name = "cpp_features_proto",
actual = "//src/google/protobuf:cpp_features_proto", # proto_library
visibility = ["//visibility:public"],
)
################################################################################
# Java support
################################################################################
alias(
name = "protobuf_java",
actual = "//java/core",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_javalite",
actual = "//java/lite",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_java_util",
actual = "//java/util",
visibility = ["//visibility:public"],
)
alias(
name = "java_toolchain",
actual = "//java/core:toolchain",
visibility = ["//visibility:public"],
)
alias(
name = "javalite_toolchain",
actual = "//java/lite:toolchain",
visibility = ["//visibility:public"],
)
alias(
name = "java_features_proto",
actual = "//java/core:java_features_proto", # proto_library
visibility = ["//visibility:public"],
)
################################################################################
# Python support
################################################################################
alias(
name = "protobuf_python",
actual = "//python:protobuf_python",
visibility = ["//visibility:public"],
)
alias(
name = "python_srcs",
actual = "//python:python_srcs",
visibility = ["//python:__subpackages__"],
)
alias(
name = "python_test_srcs",
actual = "//python:python_test_srcs",
visibility = ["//python:__subpackages__"],
)
alias(
name = "well_known_types_py_pb2",
actual = "//python:well_known_types_py_pb2",
visibility = ["//visibility:public"],
)
alias(
name = "python_common_test_protos",
actual = "//python:python_common_test_protos",
visibility = ["//visibility:public"],
)
alias(
name = "python_specific_test_protos",
actual = "//python:python_specific_test_protos",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [
"//:compiler_plugin_proto",
"//:cpp_features_proto",
"//:descriptor_proto",
],
command_line = "--cpp_out=$(OUT)",
runtime = "//src/google/protobuf",
visibility = ["//visibility:public"],
)
################################################################################
# Objective-C support
################################################################################
alias(
name = "objectivec",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_objc",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
################################################################################
# Rust support
################################################################################
alias(
name = "protobuf_rust",
actual = "//rust:protobuf",
visibility = ["//visibility:public"],
)
################################################################################
# Test protos
################################################################################
alias(
name = "lite_test_proto_srcs",
actual = "//src/google/protobuf:lite_test_proto_srcs", # proto_library
visibility = ["//:__subpackages__"],
)
alias(
name = "lite_test_protos",
actual = "//src/google/protobuf:lite_test_protos", # proto_library
visibility = ["//:__subpackages__"],
)
alias(
name = "test_proto_srcs",
actual = "//src/google/protobuf:test_proto_srcs", # filegroup
visibility = ["//:__subpackages__"],
)
alias(
name = "test_proto_editions_srcs",
actual = "//src/google/protobuf:test_proto_editions_srcs", # filegroup
visibility = ["//:__subpackages__"],
)
alias(
name = "test_protos",
actual = "//src/google/protobuf:test_protos", # proto_library
visibility = ["//:__subpackages__"],
)
# Validate generated proto source inputs:
genrule(
name = "generated_protos",
testonly = 1,
srcs = ["//src/google/protobuf:test_proto_srcs"],
outs = ["unittest_gen_import.proto"],
cmd = "cat src/google/protobuf/unittest_import.proto > $@",
)
proto_library(
name = "generated_protos_proto",
testonly = 1,
srcs = [":generated_protos"],
deps = ["//src/google/protobuf:generic_test_protos"],
)
internal_py_proto_library(
name = "generated_protos_py",
testonly = 1,
srcs = [":generated_protos"],
default_runtime = "",
protoc = ":protoc",
deps = ["//python:python_common_test_protos"],
)
################################################################################
# Conformance tests
################################################################################
cc_proto_library(
name = "test_messages_proto2_cc_proto",
visibility = [
"//conformance:__pkg__",
"//src:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto2_proto"],
)
cc_proto_library(
name = "test_messages_proto3_cc_proto",
visibility = [
"//conformance:__pkg__",
"//src:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto3_proto"],
)
java_proto_library(
name = "test_messages_proto2_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto2_proto"],
)
java_proto_library(
name = "test_messages_proto3_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto3_proto"],
)
java_lite_proto_library(
name = "test_messages_proto2_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto2_proto"],
)
java_lite_proto_library(
name = "test_messages_proto3_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = ["//src/google/protobuf:test_messages_proto3_proto"],
)
internal_objc_proto_library(
name = "test_messages_proto2_objc_proto",
testonly = 1,
srcs = ["//src/google/protobuf:test_messages_proto2.proto"],
includes = ["src/google/protobuf"],
visibility = [
"//conformance:__pkg__",
"//objectivec:__subpackages__",
],
)
internal_objc_proto_library(
name = "test_messages_proto3_objc_proto",
testonly = 1,
srcs = ["//src/google/protobuf:test_messages_proto3.proto"],
includes = [
"src/google/protobuf",
# The above must come first.
"src",
],
proto_deps = [":well_known_protos"],
visibility = [
"//conformance:__pkg__",
"//objectivec:__subpackages__",
],
)
internal_php_proto_library(
name = "test_messages_proto3_php_proto",
testonly = 1,
srcs = ["//src/google/protobuf:test_messages_proto3.proto"],
outs = [
"GPBMetadata/TestMessagesProto3.php",
"Protobuf_test_messages/Proto3/EnumOnlyProto3.php",
"Protobuf_test_messages/Proto3/EnumOnlyProto3/PBBool.php",
"Protobuf_test_messages/Proto3/ForeignEnum.php",
"Protobuf_test_messages/Proto3/ForeignMessage.php",
"Protobuf_test_messages/Proto3/NullHypothesisProto3.php",
"Protobuf_test_messages/Proto3/TestAllTypesProto3.php",
"Protobuf_test_messages/Proto3/TestAllTypesProto3/AliasedEnum.php",
"Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedEnum.php",
"Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedMessage.php",
],
includes = [
"src/google/protobuf",
# The above must come first.
"src",
],
proto_deps = [":well_known_protos"],
visibility = [
"//conformance:__pkg__",
"//php:__subpackages__",
],
)
filegroup(
name = "bzl_srcs",
srcs = glob(["**/*.bzl"]),
visibility = ["//visibility:public"],
)
################################################################################
# Packaging rules
################################################################################
# Files included in all source distributions
pkg_files(
name = "common_dist_files",
srcs = glob(
[
"*.bzl",
"cmake/*.cmake",
"cmake/*.in",
"editors/*",
],
allow_empty = True,
) + [
"BUILD.bazel",
"CMakeLists.txt",
"CONTRIBUTORS.txt",
"LICENSE",
"README.md",
"WORKSPACE",
"cmake/README.md",
"generate_descriptor_proto.sh",
"maven_install.json",
"//third_party:BUILD.bazel",
"//third_party:zlib.BUILD",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
# Additional files for C#
pkg_files(
name = "csharp_dist_files",
srcs = [
"global.json",
],
visibility = ["//pkg:__pkg__"],
)
# Additional files for ObjC
pkg_files(
name = "objectivec_dist_files",
srcs = [
"Protobuf.podspec",
],
visibility = ["//pkg:__pkg__"],
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhyulo/protobuf.git
git@gitee.com:zhyulo/protobuf.git
zhyulo
protobuf
protobuf
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385