• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2load("//:protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
3load("//bazel:cc_proto_library.bzl", "cc_proto_library")
4load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
5load("//bazel:java_proto_library.bzl", "java_proto_library")
6load("//bazel:proto_library.bzl", "proto_library")
7load("//bazel:py_proto_library.bzl", "py_proto_library")
8load("//bazel:upb_proto_library.bzl", "upb_c_proto_library", "upb_proto_reflection_library")
9load(":defaults.bzl", "compile_edition_defaults", "embed_edition_defaults")
10
11bzl_library(
12    name = "defaults",
13    srcs = ["defaults.bzl"],
14    visibility = ["//visibility:public"],
15    deps = ["//bazel/common:proto_info_bzl"],
16)
17
18# Aggregate all the features owned by the Protobuf repo.
19compile_edition_defaults(
20    name = "protobuf_defaults",
21    testonly = True,
22    srcs = [
23        "//java/core:java_features_proto",
24        "//src/google/protobuf:cpp_features_proto",
25    ],
26    maximum_edition = "2023",
27    minimum_edition = "2023",
28)
29
30compile_edition_defaults(
31    name = "test_defaults_2023",
32    testonly = True,
33    srcs = ["//src/google/protobuf:unittest_features_proto"],
34    maximum_edition = "2023",
35    minimum_edition = "2023",
36)
37
38compile_edition_defaults(
39    name = "test_defaults_future",
40    testonly = True,
41    srcs = ["//src/google/protobuf:unittest_features_proto"],
42    maximum_edition = "99997_TEST_ONLY",
43    minimum_edition = "2023",
44)
45
46compile_edition_defaults(
47    name = "test_defaults_far_future",
48    testonly = True,
49    srcs = ["//src/google/protobuf:unittest_features_proto"],
50    maximum_edition = "99999_TEST_ONLY",
51    minimum_edition = "99997_TEST_ONLY",
52)
53
54embed_edition_defaults(
55    name = "embed_test_defaults",
56    testonly = True,
57    defaults = ":test_defaults_2023",
58    output = "defaults_test_embedded.h",
59    placeholder = "DEFAULTS_VALUE",
60    template = "defaults_test_embedded.h.template",
61)
62
63embed_edition_defaults(
64    name = "embed_test_defaults_base64",
65    testonly = True,
66    defaults = ":test_defaults_2023",
67    encoding = "base64",
68    output = "defaults_test_embedded_base64.h",
69    placeholder = "DEFAULTS_VALUE",
70    template = "defaults_test_embedded_base64.h.template",
71)
72
73cc_binary(
74    name = "internal_defaults_escape",
75    srcs = ["internal_defaults_escape.cc"],
76    # This needs to be public for users of embed_edition_defaults.
77    visibility = ["//visibility:public"],
78    deps = [
79        "//src/google/protobuf",
80        "@com_google_absl//absl/flags:flag",
81        "@com_google_absl//absl/flags:parse",
82        "@com_google_absl//absl/log:absl_log",
83        "@com_google_absl//absl/strings",
84    ],
85)
86
87cc_library(
88    name = "defaults_test_embedded",
89    hdrs = [
90        "defaults_test_embedded.h",
91        "defaults_test_embedded_base64.h",
92    ],
93)
94
95cc_test(
96    name = "defaults_test",
97    srcs = ["defaults_test.cc"],
98    data = [
99        ":protobuf_defaults",
100        ":test_defaults_2023",
101        ":test_defaults_far_future",
102        ":test_defaults_future",
103    ],
104    deps = [
105        ":defaults_test_embedded",
106        "//:protobuf",
107        "//java/core:java_features_cc_proto",
108        "//src/google/protobuf",
109        "//src/google/protobuf:cpp_features_cc_proto",
110        "//src/google/protobuf:port",
111        "//src/google/protobuf:protobuf_lite",
112        "//src/google/protobuf:test_textproto",
113        "//src/google/protobuf:unittest_features_cc_proto",
114        "//src/google/protobuf/stubs",
115        "//src/google/protobuf/testing",
116        "//src/google/protobuf/testing:file",
117        "@bazel_tools//tools/cpp/runfiles",
118        "@com_google_absl//absl/memory",
119        "@com_google_absl//absl/status",
120        "@com_google_absl//absl/status:statusor",
121        "@com_google_absl//absl/strings",
122        "@com_google_absl//absl/strings:string_view",
123        "@com_google_googletest//:gtest",
124        "@com_google_googletest//:gtest_main",
125    ],
126)
127
128proto_library(
129    name = "test_messages_proto2_editions_proto",
130    testonly = True,
131    srcs = ["golden/test_messages_proto2_editions.proto"],
132)
133
134cc_proto_library(
135    name = "test_messages_proto2_editions_cc_proto",
136    testonly = True,
137    visibility = ["//conformance:__pkg__"],
138    deps = [":test_messages_proto2_editions_proto"],
139)
140
141internal_objc_proto_library(
142    name = "test_messages_proto2_editions_objc_proto",
143    testonly = True,
144    srcs = ["golden/test_messages_proto2_editions.proto"],
145    visibility = ["//conformance:__pkg__"],
146)
147
148java_proto_library(
149    name = "test_messages_proto2_editions_java_proto",
150    testonly = True,
151    visibility = ["//conformance:__pkg__"],
152    deps = [":test_messages_proto2_editions_proto"],
153)
154
155java_lite_proto_library(
156    name = "test_messages_proto2_editions_java_proto_lite",
157    testonly = True,
158    visibility = ["//conformance:__pkg__"],
159    deps = [":test_messages_proto2_editions_proto"],
160)
161
162internal_py_proto_library(
163    name = "test_messages_proto2_editions_py_pb2",
164    testonly = True,
165    srcs = ["golden/test_messages_proto2_editions.proto"],
166    srcs_version = "PY2AND3",
167    visibility = [
168        "//conformance:__pkg__",
169    ],
170)
171
172upb_c_proto_library(
173    name = "test_messages_proto2_editions_upb_proto",
174    testonly = 1,
175    deps = [":test_messages_proto2_editions_proto"],
176)
177
178upb_proto_reflection_library(
179    name = "test_messages_proto2_editions_upbdefs",
180    testonly = 1,
181    visibility = ["//upb/conformance:__pkg__"],
182    deps = [":test_messages_proto2_editions_proto"],
183)
184
185proto_library(
186    name = "test_messages_proto3_editions_proto",
187    testonly = True,
188    srcs = ["golden/test_messages_proto3_editions.proto"],
189    deps = [
190        "//:any_proto",
191        "//:duration_proto",
192        "//:field_mask_proto",
193        "//:struct_proto",
194        "//:timestamp_proto",
195        "//:wrappers_proto",
196    ],
197)
198
199cc_proto_library(
200    name = "test_messages_proto3_editions_cc_proto",
201    testonly = True,
202    visibility = ["//conformance:__pkg__"],
203    deps = [":test_messages_proto3_editions_proto"],
204)
205
206internal_objc_proto_library(
207    name = "test_messages_proto3_editions_objc_proto",
208    testonly = True,
209    srcs = ["golden/test_messages_proto3_editions.proto"],
210    includes = [
211        ".",
212        "src",
213    ],
214    proto_deps = ["//:well_known_type_protos"],
215    visibility = ["//conformance:__pkg__"],
216)
217
218java_proto_library(
219    name = "test_messages_proto3_editions_java_proto",
220    testonly = True,
221    visibility = ["//conformance:__pkg__"],
222    deps = [":test_messages_proto3_editions_proto"],
223)
224
225java_lite_proto_library(
226    name = "test_messages_proto3_editions_java_proto_lite",
227    testonly = True,
228    visibility = ["//conformance:__pkg__"],
229    deps = [":test_messages_proto3_editions_proto"],
230)
231
232internal_php_proto_library(
233    name = "test_messages_proto3_editions_php_proto",
234    testonly = 1,
235    srcs = ["golden/test_messages_proto3_editions.proto"],
236    outs = [
237        "GPBMetadata/TestMessagesProto3Editions.php",
238        "Protobuf_test_messages/Editions/Proto3/EnumOnlyProto3.php",
239        "Protobuf_test_messages/Editions/Proto3/EnumOnlyProto3/PBBool.php",
240        "Protobuf_test_messages/Editions/Proto3/ForeignEnum.php",
241        "Protobuf_test_messages/Editions/Proto3/ForeignMessage.php",
242        "Protobuf_test_messages/Editions/Proto3/NullHypothesisProto3.php",
243        "Protobuf_test_messages/Editions/Proto3/TestAllTypesProto3.php",
244        "Protobuf_test_messages/Editions/Proto3/TestAllTypesProto3/AliasedEnum.php",
245        "Protobuf_test_messages/Editions/Proto3/TestAllTypesProto3/NestedEnum.php",
246        "Protobuf_test_messages/Editions/Proto3/TestAllTypesProto3/NestedMessage.php",
247    ],
248    enable_editions = True,
249    includes = [
250        "golden",
251        "src",
252    ],
253    proto_deps = ["//:well_known_type_protos"],
254    visibility = ["//conformance:__pkg__"],
255)
256
257internal_py_proto_library(
258    name = "test_messages_proto3_editions_py_pb2",
259    testonly = True,
260    srcs = ["golden/test_messages_proto3_editions.proto"],
261    srcs_version = "PY2AND3",
262    visibility = [
263        "//conformance:__pkg__",
264    ],
265    deps = ["//python:well_known_types_py_pb2"],
266)
267
268upb_c_proto_library(
269    name = "test_messages_proto3_editions_upb_proto",
270    testonly = 1,
271    deps = [":test_messages_proto3_editions_proto"],
272)
273
274upb_proto_reflection_library(
275    name = "test_messages_proto3_editions_upbdefs",
276    testonly = 1,
277    visibility = ["//upb/conformance:__pkg__"],
278    deps = ["test_messages_proto3_editions_proto"],
279)
280
281# Export these for conformance tests for ruby and C# codegen.
282exports_files(
283    [
284        "golden/test_messages_proto2_editions.proto",
285        "golden/test_messages_proto3_editions.proto",
286    ],
287    visibility = [
288        "//ruby:__pkg__",
289        "//src/google/protobuf/csharp:__pkg__",
290    ],
291)
292
293proto_library(
294    name = "test_editions_default_features_proto",
295    testonly = True,
296    srcs = ["proto/test_editions_default_features.proto"],
297)
298
299cc_proto_library(
300    name = "test_editions_default_features_cc_proto",
301    testonly = True,
302    deps = [":test_editions_default_features_proto"],
303)
304
305cc_test(
306    name = "generated_files_test",
307    srcs = ["generated_files_test.cc"],
308    deps = [
309        ":test_editions_default_features_cc_proto",
310        ":test_messages_proto2_editions_cc_proto",
311        ":test_messages_proto3_editions_cc_proto",
312        "//:protobuf",
313        "//src/google/protobuf:test_textproto",
314        "@com_google_googletest//:gtest",
315        "@com_google_googletest//:gtest_main",
316    ],
317)
318
319cc_test(
320    name = "generated_reflection_test",
321    srcs = ["generated_reflection_test.cc"],
322    deps = [
323        ":test_messages_proto2_editions_cc_proto",
324        "@com_google_googletest//:gtest",
325        "@com_google_googletest//:gtest_main",
326    ],
327)
328
329# Define a test suite to allow us to trigger these tests from //src expansions.
330test_suite(name = "all_tests")
331