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.

377 lines
9.5 KiB

# Conformance testing for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library")
load("@rules_python//python:defs.bzl", "py_library")
load("//:protobuf.bzl", "internal_py_proto_library", "internal_php_proto_library", "internal_csharp_proto_library", "internal_ruby_proto_library", "internal_objc_proto_library")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load(
"@rules_pkg//:mappings.bzl",
"pkg_attributes",
"pkg_filegroup",
"pkg_files",
"strip_prefix",
)
exports_files([
"conformance_test_runner.sh",
"failure_list_cpp.txt",
"failure_list_csharp.txt",
"failure_list_java.txt",
"failure_list_java_lite.txt",
"failure_list_objc.txt",
"failure_list_php.txt",
"failure_list_php_c.txt",
"failure_list_python.txt",
"failure_list_python_cpp.txt",
"failure_list_ruby.txt",
"failure_list_jruby.txt",
"text_format_failure_list_cpp.txt",
"text_format_failure_list_csharp.txt",
"text_format_failure_list_java.txt",
"text_format_failure_list_java_lite.txt",
"text_format_failure_list_php.txt",
"text_format_failure_list_php_c.txt",
"text_format_failure_list_python.txt",
"text_format_failure_list_python_cpp.txt",
"text_format_failure_list_ruby.txt",
"text_format_failure_list_jruby.txt",
])
cc_proto_library(
name = "test_messages_proto2_proto_cc",
deps = ["//src/google/protobuf:test_messages_proto2_proto"],
)
cc_proto_library(
name = "test_messages_proto3_proto_cc",
deps = ["//src/google/protobuf:test_messages_proto3_proto"],
)
proto_library(
name = "conformance_proto",
srcs = ["conformance.proto"],
visibility = ["//visibility:public"],
)
cc_proto_library(
name = "conformance_cc_proto",
deps = [":conformance_proto"],
)
internal_csharp_proto_library(
name = "conformance_csharp_proto",
srcs = ["conformance.proto"],
visibility = [
"//csharp:__subpackages__",
],
)
java_proto_library(
name = "conformance_java_proto",
visibility = [
"//java:__subpackages__",
],
deps = [":conformance_proto"],
)
java_lite_proto_library(
name = "conformance_java_proto_lite",
visibility = [
"//java:__subpackages__",
],
deps = [":conformance_proto"],
)
internal_objc_proto_library(
name = "conformance_objc_proto",
srcs = ["conformance.proto"],
visibility = [
"//conformance:__pkg__",
"//objc:__pkg__",
],
)
internal_py_proto_library(
name = "conformance_py_proto",
srcs = ["conformance.proto"],
visibility = [
"//python:__subpackages__",
],
srcs_version = "PY2AND3",
)
internal_php_proto_library(
name = "conformance_php_proto",
srcs = ["conformance.proto"],
outs = [
"Conformance/ConformanceRequest.php",
"Conformance/ConformanceResponse.php",
"Conformance/FailureSet.php",
"Conformance/JspbEncodingConfig.php",
"Conformance/TestCategory.php",
"Conformance/WireFormat.php",
"GPBMetadata/Conformance.php",
],
visibility = [
"//conformance:__pkg__",
"//php:__pkg__",
],
)
internal_ruby_proto_library(
name = "conformance_ruby_proto",
srcs = ["conformance.proto"],
visibility = [
"//conformance:__pkg__",
"//ruby:__pkg__",
],
)
cc_library(
name = "jsoncpp",
srcs = ["third_party/jsoncpp/jsoncpp.cpp"],
hdrs = ["third_party/jsoncpp/json.h"],
includes = ["."],
)
cc_library(
name = "conformance_test",
srcs = [
"conformance_test.cc",
"conformance_test_runner.cc",
],
hdrs = [
"conformance_test.h",
],
includes = ["."],
deps = [":conformance_cc_proto"],
)
cc_library(
name = "binary_json_conformance_suite",
srcs = ["binary_json_conformance_suite.cc"],
hdrs = ["binary_json_conformance_suite.h"],
deps = [
":conformance_test",
":jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
],
)
cc_library(
name = "text_format_conformance_suite",
srcs = ["text_format_conformance_suite.cc"],
hdrs = ["text_format_conformance_suite.h"],
deps = [
":conformance_test",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
],
)
cc_binary(
name = "conformance_test_runner",
srcs = ["conformance_test_main.cc"],
visibility = ["//visibility:public"],
deps = [
":binary_json_conformance_suite",
":conformance_test",
":text_format_conformance_suite",
],
)
cc_binary(
name = "conformance_cpp",
srcs = ["conformance_cpp.cc"],
deps = [
":conformance_cc_proto",
"//:protobuf",
"//:test_messages_proto2_cc_proto",
"//:test_messages_proto3_cc_proto",
],
testonly = 1,
visibility = ["//src:__subpackages__"],
)
java_binary(
name = "conformance_java",
srcs = ["ConformanceJava.java"],
main_class = "ConformanceJava",
deps = [
":conformance_java_proto",
"//:protobuf_java",
"//:protobuf_java_util",
"//:test_messages_proto2_java_proto",
"//:test_messages_proto3_java_proto",
],
testonly = 1,
visibility = [
"//java:__subpackages__",
],
)
java_binary(
name = "conformance_java_lite",
main_class = "ConformanceJavaLite",
visibility = [
"//java:__subpackages__",
],
deps = [
":conformance_java_proto_lite",
"//:protobuf_java_util",
"//:protobuf_javalite",
"//:test_messages_proto2_java_proto_lite",
"//:test_messages_proto3_java_proto_lite",
],
testonly = 1,
srcs = ["ConformanceJavaLite.java"],
)
py_binary(
name = "conformance_python",
srcs = ["conformance_python.py"],
deps = [
":conformance_py_proto",
"//:protobuf_python",
"//python:test_messages_proto2_py_proto",
"//python:test_messages_proto3_py_proto",
],
imports = [".", "../python"],
srcs_version = "PY2AND3",
testonly = 1,
visibility = ["//python:__subpackages__"],
)
inline_sh_binary(
name = "conformance_php",
srcs = [
"conformance_php.php",
"autoload.php",
],
deps = [
":conformance_php_proto",
"//php:source_files",
"//:test_messages_proto3_php_proto",
],
cmd = """
php -d include_path=conformance:src/google/protobuf \\
-d auto_prepend_file=$(rootpath autoload.php) \\
$(rootpath conformance_php.php)
""",
testonly = 1,
visibility = ["//php:__subpackages__"],
)
inline_sh_binary(
name = "conformance_php_c",
srcs = [
"conformance_php.php",
"//php:extension",
],
deps = [
":conformance_php_proto",
"//:test_messages_proto3_php_proto",
],
cmd = """
php -dextension=$(rootpath //php:extension) \\
-d include_path=conformance:src/google/protobuf \\
$(rootpath conformance_php.php)
""",
testonly = 1,
visibility = ["//php:__subpackages__"],
)
inline_sh_binary(
name = "conformance_csharp",
srcs = ["//csharp/src/Google.Protobuf.Conformance:conformance_dll"],
deps = [
"//csharp/src/Google.Protobuf.Conformance:conformance_runfiles",
],
cmd = "dotnet $(rootpath //csharp/src/Google.Protobuf.Conformance:conformance_dll)",
testonly = 1,
visibility = ["//csharp:__subpackages__"],
)
objc_library(
name = "conformance_objc_lib",
non_arc_srcs = ["conformance_objc.m"],
deps = [
":conformance_objc_proto",
"//:test_messages_proto2_objc_proto",
"//:test_messages_proto3_objc_proto",
],
testonly = 1,
# See https://github.com/bazelbuild/bazel/issues/12897.
tags = ["manual"],
)
cc_binary(
name = "conformance_objc",
deps = [":conformance_objc_lib"],
testonly = 1,
# See https://github.com/bazelbuild/bazel/issues/12897.
tags = ["manual"],
visibility = ["//objectivec:__subpackages__"],
)
inline_sh_binary(
name = "conformance_ruby",
srcs = ["conformance_ruby.rb"],
deps = [
":conformance_ruby_proto",
"//:well_known_ruby_protos",
"//:test_messages_proto2_ruby_proto",
"//:test_messages_proto3_ruby_proto",
"//ruby:protobuf",
],
cmd = "RUBYLIB=ruby/lib:conformance:src $(rootpath conformance_ruby.rb)",
testonly = 1,
visibility = ["//ruby:__subpackages__"],
)
################################################################################
# Distribution files
################################################################################
filegroup(
name = "all_files",
srcs = glob(["**/*"]),
visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
)
pkg_files(
name = "dist_files",
srcs = glob(
["**/*"],
exclude = [
# Handled by dist_scripts:
"conformance_test_runner.sh",
# The following are not in autotools dist:
"autoload.php",
"failure_list_jruby.txt",
"update_failure_list.py",
],
),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
pkg_files(
name = "dist_scripts",
srcs = ["conformance_test_runner.sh"],
attributes = pkg_attributes(mode = "0555"),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
pkg_filegroup(
name = "all_dist_files",
srcs = [
":dist_files",
":dist_scripts",
],
visibility = ["//pkg:__pkg__"],
)