Add filegroups for test sources and include them in file lists. (#10049)

These will be used to generate lists of sources for non-Bazel builds.
This commit is contained in:
David L. Jones 2022-05-31 15:59:28 -07:00 committed by GitHub
parent 1ec6f26ce7
commit c2e99db90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 264 additions and 11 deletions

View File

@ -27,7 +27,7 @@ pkg_files(
pkg_files(
name = "compiler_plugin_protos_files",
srcs = [
"//src/google/protobuf/compiler:compiler_plugin_protos_files",
"//src/google/protobuf/compiler:compiler_plugin_protos_files",
],
prefix = "include/google/protobuf/compiler",
visibility = ["//visibility:private"],
@ -304,10 +304,33 @@ gen_file_lists(
testonly = 1,
out_stem = "src_file_lists",
src_libs = {
# source rule: name in generated file
# {[source rule]: [name in generated file]}
# Libraries:
":protobuf": "libprotobuf",
":protoc": "libprotoc",
":protobuf_lite": "libprotobuf_lite",
":protoc": "libprotoc",
# Protos:
"//src/google/protobuf:well_known_type_protos": "wkt_protos",
"//src/google/protobuf:descriptor_proto": "descriptor_proto",
"//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
# Test libraries:
":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_protos": "protobuf_test_protos",
"//src/google/protobuf:lite_test_srcs": "protobuf_lite_test",
"//src/google/protobuf:lite_test_protos": "protobuf_lite_test_protos",
"//src/google/protobuf/compiler:test_srcs": "compiler_test",
":compiler_annotation_test_util": "annotation_test_util",
":compiler_mock_code_generator": "mock_code_generator",
"//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",
":testinglib": "testing",
"//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",
},
)
@ -362,15 +385,15 @@ cc_dist_library(
}),
tags = ["manual"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf:arena",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf/compiler:importer",
"//src/google/protobuf/io",
"//src/google/protobuf/io:gzip_stream",
"//src/google/protobuf/io:io_win32",
"//src/google/protobuf/io:printer",
"//src/google/protobuf/io:tokenizer",
"//src/google/protobuf:protobuf",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf/stubs",
"//src/google/protobuf/stubs:lite",
"//src/google/protobuf/util:delimited_message_util",
@ -379,6 +402,14 @@ cc_dist_library(
"//src/google/protobuf/util:json_util",
"//src/google/protobuf/util:time_util",
"//src/google/protobuf/util:type_resolver_util",
"//src/google/protobuf/util/internal:datapiece",
"//src/google/protobuf/util/internal:default_value",
"//src/google/protobuf/util/internal:field_mask_utility",
"//src/google/protobuf/util/internal:json",
"//src/google/protobuf/util/internal:object_writer",
"//src/google/protobuf/util/internal:protostream",
"//src/google/protobuf/util/internal:type_info",
"//src/google/protobuf/util/internal:utility",
],
)
@ -398,6 +429,41 @@ cc_dist_library(
],
)
cc_dist_library(
name = "lite_test_util",
testonly = 1,
tags = ["manual"],
deps = ["//src/google/protobuf:lite_test_util"],
)
cc_dist_library(
name = "test_util",
testonly = 1,
tags = ["manual"],
deps = ["//src/google/protobuf:test_util"],
)
cc_dist_library(
name = "compiler_annotation_test_util",
deps = ["//src/google/protobuf/compiler:annotation_test_util"],
testonly = 1,
tags = ["manual"],
)
cc_dist_library(
name = "compiler_mock_code_generator",
deps = ["//src/google/protobuf/compiler:mock_code_generator"],
testonly = 1,
tags = ["manual"],
)
cc_dist_library(
name = "testinglib",
deps = ["//src/google/protobuf/testing"],
testonly = 1,
tags = ["manual"],
)
################################################################################
# Distribution sources
################################################################################

View File

@ -87,6 +87,10 @@ proto_library(
name = "descriptor_proto",
srcs = ["descriptor.proto"],
strip_import_prefix = "/src",
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
],
)
################################################################################
@ -760,8 +764,8 @@ cc_test(
],
}),
deps = [
":protobuf",
":lite_test_util",
":protobuf",
":test_util",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
@ -773,8 +777,8 @@ cc_test(
srcs = ["lite_unittest.cc"],
deps = [
":cc_lite_test_protos",
":protobuf",
":lite_test_util",
":protobuf",
"//src/google/protobuf/io",
"//src/google/protobuf/stubs",
"@com_google_googletest//:gtest",
@ -904,8 +908,8 @@ cc_test(
}),
deps = [
":cc_test_protos",
":protobuf",
":lite_test_util",
":protobuf",
"//src/google/protobuf/testing",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
@ -1101,3 +1105,27 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "full_test_srcs",
srcs = glob(
include = [
"*_test.cc",
"*unittest.cc",
],
exclude = [
"lite_unittest.cc",
"lite_arena_unittest.cc",
],
),
visibility = ["//pkg:__pkg__"],
)
filegroup(
name = "lite_test_srcs",
srcs = [
"lite_arena_unittest.cc",
"lite_unittest.cc",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -16,7 +16,10 @@ load("//build_defs:cpp_opts.bzl", "COPTS")
proto_library(
name = "plugin_proto",
srcs = ["plugin.proto"],
visibility = ["//:__pkg__"],
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
],
deps = ["//:descriptor_proto"],
)
@ -162,6 +165,7 @@ cc_library(
hdrs = ["mock_code_generator.h"],
copts = COPTS,
strip_include_prefix = "/src",
visibility = ["//pkg:__pkg__"],
deps = [
":code_generator",
"//src/google/protobuf/io",
@ -300,3 +304,34 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]) + [
"//src/google/protobuf/compiler/cpp:test_srcs",
"//src/google/protobuf/compiler/csharp:test_srcs",
"//src/google/protobuf/compiler/java:test_srcs",
"//src/google/protobuf/compiler/objectivec:test_srcs",
"//src/google/protobuf/compiler/php:test_srcs",
"//src/google/protobuf/compiler/python:test_srcs",
"//src/google/protobuf/compiler/ruby:test_srcs",
],
visibility = ["//pkg:__pkg__"],
)
filegroup(
name = "test_plugin_srcs",
srcs = ["test_plugin.cc"],
visibility = ["//pkg:__pkg__"],
)
filegroup(
name = "test_proto_srcs",
srcs = [
"//src/google/protobuf/compiler/cpp:test_proto_srcs",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -202,3 +202,21 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)
filegroup(
name = "test_proto_srcs",
srcs = [
"test_bad_identifiers.proto",
"test_large_enum_value.proto",
],
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -107,3 +107,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -124,3 +124,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -70,3 +70,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -32,3 +32,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -54,3 +54,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -59,3 +59,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//src/google/protobuf/compiler:__pkg__"],
)

View File

@ -145,3 +145,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//pkg:__pkg__"],
)

View File

@ -136,3 +136,12 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]),
visibility = ["//pkg:__pkg__"],
)

View File

@ -218,8 +218,13 @@ filegroup(
srcs = [
"json_format.proto",
"json_format_proto3.proto",
"message_differencer_unittest.proto",
"//src/google/protobuf/util/internal:test_proto_srcs",
],
visibility = [
"//pkg:__pkg__",
"//python:__pkg__",
],
visibility = ["//python:__pkg__"],
)
proto_library(
@ -281,3 +286,14 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]) + [
"//src/google/protobuf/util/internal:test_srcs",
],
visibility = ["//pkg:__pkg__"],
)

View File

@ -8,7 +8,10 @@ load("@rules_proto//proto:defs.bzl", "proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS")
package(
default_visibility = ["//src/google/protobuf/util:__pkg__"],
default_visibility = [
"//src/google/protobuf/util:__pkg__",
"//pkg:__pkg__",
],
)
cc_library(
@ -448,3 +451,18 @@ pkg_files(
strip_prefix = strip_prefix.from_root(""),
visibility = ["//src:__pkg__"],
)
filegroup(
name = "test_srcs",
srcs = glob([
"*_test.cc",
"*unittest.cc",
]) + [
"type_info_test_helper.cc",
],
)
filegroup(
name = "test_proto_srcs",
srcs = glob(["testdata/*.proto"]),
)