Use filegroup() internally instead of pkg_files()

pkg_files() has some odd quirks, like breaking if a filename exists in multiple directories.  filegroup() does everything we need, without these quirks.

PiperOrigin-RevId: 547523447
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent a6852ec919
commit 79af13abde
  1. 42
      BUILD
  2. 6
      cmake/BUILD.bazel
  3. 5
      python/BUILD
  4. 9
      python/dist/BUILD.bazel
  5. 35
      upb/mini_descriptor/BUILD
  6. 35
      upb/mini_table/BUILD
  7. 9
      upb/util/BUILD

42
BUILD

@ -54,7 +54,6 @@ load(
"//bazel:amalgamation.bzl", "//bazel:amalgamation.bzl",
"upb_amalgamation", "upb_amalgamation",
) )
load("@rules_pkg//:mappings.bzl", "pkg_files")
# end:github_only # end:github_only
# begin:google_only # begin:google_only
@ -1133,33 +1132,24 @@ exports_files(
) )
filegroup( filegroup(
name = "cmake_files", name = "source_files",
srcs = glob([ srcs = glob(
"upb/**/*", [
"third_party/**/*", "upb/**/*.c",
]), "upb/**/*.h",
visibility = ["//cmake:__pkg__"], "upb/**/*.hpp",
) "upb/**/*.inc",
pkg_files(
name = "upb_source_files",
srcs = glob(
[
"upb/**/*.c",
"upb/**/*.h",
"upb/**/*.hpp",
"upb/**/*.inc",
],
exclude = [
"upb/**/conformance_upb.c",
"upb/reflection/stage0/**/*",
], ],
), exclude = [
strip_prefix = "", "upb/**/conformance_upb.c",
visibility = ["//python/dist:__pkg__"], "upb/reflection/stage0/**/*",
],
),
visibility = [
"//cmake:__pkg__",
"//python/dist:__pkg__",
]
) )
# end:github_only # end:github_only
# begin:google_only # begin:google_only

@ -99,9 +99,9 @@ sh_test(
data = [ data = [
":copy_protos", ":copy_protos",
":gen_cmakelists", ":gen_cmakelists",
"//:cmake_files", "//:source_files",
"//upb/mini_descriptor:cmake_files", "//upb/mini_descriptor:source_files",
"//upb/mini_table:cmake_files", "//upb/mini_table:source_files",
"@utf8_range//:utf8_range_srcs", "@utf8_range//:utf8_range_srcs",
], ],
target_compatible_with = select({ target_compatible_with = select({

@ -187,11 +187,6 @@ _message_target_compatible_with = {
"//conditions:default": [], "//conditions:default": [],
} }
pkg_files(
name = "message_extension",
srcs = [":message_srcs"],
prefix = "python/",
)
# end:github_only # end:github_only
# begin:google_only # begin:google_only
# _message_target_compatible_with = { # _message_target_compatible_with = {

@ -212,18 +212,17 @@ pkg_tar(
":generated_wkt_compiler", ":generated_wkt_compiler",
":utf8_range_source_files", ":utf8_range_source_files",
"//:LICENSE", "//:LICENSE",
"//:upb_source_files", "//:source_files",
"//python:message_extension", "//python:message_srcs",
"//upb/mini_descriptor:internal_source_files",
"//upb/mini_descriptor:source_files", "//upb/mini_descriptor:source_files",
"//upb/mini_table:internal_source_files",
"//upb/mini_table:source_files", "//upb/mini_table:source_files",
"//upb/util:util_source_files", "//upb/util:source_files",
"@com_google_protobuf//python:python_source_files", "@com_google_protobuf//python:python_source_files",
], ],
extension = "tar.gz", extension = "tar.gz",
package_dir = "protobuf", package_dir = "protobuf",
package_file_name = "protobuf.tar.gz", package_file_name = "protobuf.tar.gz",
strip_prefix = ".",
target_compatible_with = select({ target_compatible_with = select({
"@system_python//:none": ["@platforms//:incompatible"], "@system_python//:none": ["@platforms//:incompatible"],
"//conditions:default": [], "//conditions:default": [],

@ -4,10 +4,6 @@ load(
"UPB_DEFAULT_CPPOPTS", "UPB_DEFAULT_CPPOPTS",
) )
# begin:github_only
load("@rules_pkg//:mappings.bzl", "pkg_files")
# end:github_only
cc_library( cc_library(
name = "internal", name = "internal",
srcs = [ srcs = [
@ -88,39 +84,16 @@ cc_test(
# begin:github_only # begin:github_only
filegroup( filegroup(
name = "cmake_files",
srcs = glob(
[
"**/*.c",
"**/*.h",
],
),
visibility = ["//cmake:__pkg__"],
)
pkg_files(
name = "source_files", name = "source_files",
srcs = glob( srcs = glob(
[ [
"**/*.c", "**/*.c",
"**/*.h", "**/*.h",
], ],
exclude = ["internal/**"],
),
prefix = "upb/mini_descriptor",
visibility = ["//python/dist:__pkg__"],
)
pkg_files(
name = "internal_source_files",
srcs = glob(
[
"internal/*.c",
"internal/*.h",
],
exclude = ["encode_test.cc"],
), ),
prefix = "upb/mini_descriptor/internal", visibility = [
visibility = ["//python/dist:__pkg__"], "//cmake:__pkg__",
"//python/dist:__pkg__",
]
) )
# end:github_only # end:github_only

@ -28,10 +28,6 @@ load(
"UPB_DEFAULT_COPTS", "UPB_DEFAULT_COPTS",
) )
# begin:github_only
load("@rules_pkg//:mappings.bzl", "pkg_files")
# end:github_only
cc_library( cc_library(
name = "mini_table", name = "mini_table",
srcs = [ srcs = [
@ -80,40 +76,17 @@ cc_library(
# begin:github_only # begin:github_only
filegroup( filegroup(
name = "cmake_files",
srcs = glob(
[
"**/*.c",
"**/*.h",
],
exclude = ["encode_test.cc"],
),
visibility = ["//cmake:__pkg__"],
)
pkg_files(
name = "source_files", name = "source_files",
srcs = glob( srcs = glob(
[ [
"**/*.c", "**/*.c",
"**/*.h", "**/*.h",
], ],
exclude = ["internal/**", "encode_test.cc"],
),
prefix = "upb/mini_table",
visibility = ["//python/dist:__pkg__"],
)
pkg_files(
name = "internal_source_files",
srcs = glob(
[
"internal/*.c",
"internal/*.h",
],
exclude = ["encode_test.cc"], exclude = ["encode_test.cc"],
), ),
prefix = "upb/mini_table/internal", visibility = [
visibility = ["//python/dist:__pkg__"], "//cmake:__pkg__",
"//python/dist:__pkg__",
]
) )
# end:github_only # end:github_only

@ -4,10 +4,6 @@ load(
"upb_proto_reflection_library", "upb_proto_reflection_library",
) )
# begin:github_only
load("@rules_pkg//:mappings.bzl", "pkg_files")
# end:github_only
# begin:google_only # begin:google_only
# package(default_applicable_licenses = ["//:license"]) # package(default_applicable_licenses = ["//:license"])
# end:google_only # end:google_only
@ -165,8 +161,8 @@ cc_test(
) )
# begin:github_only # begin:github_only
pkg_files( filegroup(
name = "util_source_files", name = "source_files",
srcs = [ srcs = [
"compare.c", "compare.c",
"compare.h", "compare.h",
@ -175,7 +171,6 @@ pkg_files(
"required_fields.c", "required_fields.c",
"required_fields.h", "required_fields.h",
], ],
prefix = "upb/util",
visibility = ["//python/dist:__pkg__"], visibility = ["//python/dist:__pkg__"],
) )
# end:github_only # end:github_only

Loading…
Cancel
Save