Skip to content

Commit a03d332

Browse files
YannicAdam Cozzette
authored andcommitted
[bazel] Use strip_import_prefix for wkp instead of copying them
1 parent 582640e commit a03d332

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

BUILD

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -242,38 +242,36 @@ cc_library(
242242
# Map of all well known protos.
243243
# name => (include path, imports)
244244
WELL_KNOWN_PROTO_MAP = {
245-
"any": ("google/protobuf/any.proto", []),
245+
"any": ("src/google/protobuf/any.proto", []),
246246
"api": (
247-
"google/protobuf/api.proto",
247+
"src/google/protobuf/api.proto",
248248
[
249249
"source_context",
250250
"type",
251251
],
252252
),
253253
"compiler_plugin": (
254-
"google/protobuf/compiler/plugin.proto",
254+
"src/google/protobuf/compiler/plugin.proto",
255255
["descriptor"],
256256
),
257-
"descriptor": ("google/protobuf/descriptor.proto", []),
258-
"duration": ("google/protobuf/duration.proto", []),
259-
"empty": ("google/protobuf/empty.proto", []),
260-
"field_mask": ("google/protobuf/field_mask.proto", []),
261-
"source_context": ("google/protobuf/source_context.proto", []),
262-
"struct": ("google/protobuf/struct.proto", []),
263-
"timestamp": ("google/protobuf/timestamp.proto", []),
257+
"descriptor": ("src/google/protobuf/descriptor.proto", []),
258+
"duration": ("src/google/protobuf/duration.proto", []),
259+
"empty": ("src/google/protobuf/empty.proto", []),
260+
"field_mask": ("src/google/protobuf/field_mask.proto", []),
261+
"source_context": ("src/google/protobuf/source_context.proto", []),
262+
"struct": ("src/google/protobuf/struct.proto", []),
263+
"timestamp": ("src/google/protobuf/timestamp.proto", []),
264264
"type": (
265-
"google/protobuf/type.proto",
265+
"src/google/protobuf/type.proto",
266266
[
267267
"any",
268268
"source_context",
269269
],
270270
),
271-
"wrappers": ("google/protobuf/wrappers.proto", []),
271+
"wrappers": ("src/google/protobuf/wrappers.proto", []),
272272
}
273273

274-
RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
275-
276-
WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
274+
WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()]
277275

278276
filegroup(
279277
name = "well_known_protos",
@@ -303,17 +301,10 @@ cc_proto_library(
303301
# )
304302
################################################################################
305303

306-
internal_copied_filegroup(
307-
name = "_internal_wkt_protos",
308-
srcs = WELL_KNOWN_PROTOS,
309-
dest = "",
310-
strip_prefix = "src",
311-
visibility = ["//visibility:private"],
312-
)
313-
314304
[proto_library(
315305
name = proto[0] + "_proto",
316306
srcs = [proto[1][0]],
307+
strip_import_prefix = "src",
317308
visibility = ["//visibility:public"],
318309
deps = [dep + "_proto" for dep in proto[1][1]],
319310
) for proto in WELL_KNOWN_PROTO_MAP.items()]
@@ -893,7 +884,7 @@ internal_copied_filegroup(
893884

894885
# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
895886
# which case we can simply add :protos_python in srcs.
896-
COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
887+
COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS]
897888

898889
py_proto_library(
899890
name = "protobuf_python",

0 commit comments

Comments
 (0)