From 79af13abde31f5ab8d29931429df70d282a3e867 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 12 Jul 2023 09:50:26 -0700 Subject: [PATCH] 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 --- BUILD | 42 +++++++++++++++------------------------ cmake/BUILD.bazel | 6 +++--- python/BUILD | 5 ----- python/dist/BUILD.bazel | 9 ++++----- upb/mini_descriptor/BUILD | 35 ++++---------------------------- upb/mini_table/BUILD | 35 ++++---------------------------- upb/util/BUILD | 9 ++------- 7 files changed, 33 insertions(+), 108 deletions(-) diff --git a/BUILD b/BUILD index d89e992276..e71f1f972d 100644 --- a/BUILD +++ b/BUILD @@ -54,7 +54,6 @@ load( "//bazel:amalgamation.bzl", "upb_amalgamation", ) -load("@rules_pkg//:mappings.bzl", "pkg_files") # end:github_only # begin:google_only @@ -1133,33 +1132,24 @@ exports_files( ) filegroup( - name = "cmake_files", - srcs = glob([ - "upb/**/*", - "third_party/**/*", - ]), - visibility = ["//cmake:__pkg__"], -) - - -pkg_files( - name = "upb_source_files", - srcs = glob( - [ - "upb/**/*.c", - "upb/**/*.h", - "upb/**/*.hpp", - "upb/**/*.inc", - ], - exclude = [ - "upb/**/conformance_upb.c", - "upb/reflection/stage0/**/*", + name = "source_files", + srcs = glob( + [ + "upb/**/*.c", + "upb/**/*.h", + "upb/**/*.hpp", + "upb/**/*.inc", ], - ), - strip_prefix = "", - visibility = ["//python/dist:__pkg__"], + exclude = [ + "upb/**/conformance_upb.c", + "upb/reflection/stage0/**/*", + ], + ), + visibility = [ + "//cmake:__pkg__", + "//python/dist:__pkg__", + ] ) - # end:github_only # begin:google_only diff --git a/cmake/BUILD.bazel b/cmake/BUILD.bazel index a09712a100..06c2cf665f 100644 --- a/cmake/BUILD.bazel +++ b/cmake/BUILD.bazel @@ -99,9 +99,9 @@ sh_test( data = [ ":copy_protos", ":gen_cmakelists", - "//:cmake_files", - "//upb/mini_descriptor:cmake_files", - "//upb/mini_table:cmake_files", + "//:source_files", + "//upb/mini_descriptor:source_files", + "//upb/mini_table:source_files", "@utf8_range//:utf8_range_srcs", ], target_compatible_with = select({ diff --git a/python/BUILD b/python/BUILD index cefe185998..2acf4d58f9 100644 --- a/python/BUILD +++ b/python/BUILD @@ -187,11 +187,6 @@ _message_target_compatible_with = { "//conditions:default": [], } -pkg_files( - name = "message_extension", - srcs = [":message_srcs"], - prefix = "python/", -) # end:github_only # begin:google_only # _message_target_compatible_with = { diff --git a/python/dist/BUILD.bazel b/python/dist/BUILD.bazel index e1e99b4b32..6e758f21af 100644 --- a/python/dist/BUILD.bazel +++ b/python/dist/BUILD.bazel @@ -212,18 +212,17 @@ pkg_tar( ":generated_wkt_compiler", ":utf8_range_source_files", "//:LICENSE", - "//:upb_source_files", - "//python:message_extension", - "//upb/mini_descriptor:internal_source_files", + "//:source_files", + "//python:message_srcs", "//upb/mini_descriptor:source_files", - "//upb/mini_table:internal_source_files", "//upb/mini_table:source_files", - "//upb/util:util_source_files", + "//upb/util:source_files", "@com_google_protobuf//python:python_source_files", ], extension = "tar.gz", package_dir = "protobuf", package_file_name = "protobuf.tar.gz", + strip_prefix = ".", target_compatible_with = select({ "@system_python//:none": ["@platforms//:incompatible"], "//conditions:default": [], diff --git a/upb/mini_descriptor/BUILD b/upb/mini_descriptor/BUILD index 40eba6f3ef..6d90998101 100644 --- a/upb/mini_descriptor/BUILD +++ b/upb/mini_descriptor/BUILD @@ -4,10 +4,6 @@ load( "UPB_DEFAULT_CPPOPTS", ) -# begin:github_only -load("@rules_pkg//:mappings.bzl", "pkg_files") -# end:github_only - cc_library( name = "internal", srcs = [ @@ -88,39 +84,16 @@ cc_test( # begin:github_only filegroup( - name = "cmake_files", - srcs = glob( - [ - "**/*.c", - "**/*.h", - ], - ), - visibility = ["//cmake:__pkg__"], -) - -pkg_files( name = "source_files", srcs = glob( [ "**/*.c", "**/*.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 = ["//python/dist:__pkg__"], + visibility = [ + "//cmake:__pkg__", + "//python/dist:__pkg__", + ] ) # end:github_only diff --git a/upb/mini_table/BUILD b/upb/mini_table/BUILD index 80139dc32b..759660ece2 100644 --- a/upb/mini_table/BUILD +++ b/upb/mini_table/BUILD @@ -28,10 +28,6 @@ load( "UPB_DEFAULT_COPTS", ) -# begin:github_only -load("@rules_pkg//:mappings.bzl", "pkg_files") -# end:github_only - cc_library( name = "mini_table", srcs = [ @@ -80,40 +76,17 @@ cc_library( # begin:github_only filegroup( - name = "cmake_files", - srcs = glob( - [ - "**/*.c", - "**/*.h", - ], - exclude = ["encode_test.cc"], - ), - visibility = ["//cmake:__pkg__"], -) - -pkg_files( name = "source_files", srcs = glob( [ "**/*.c", "**/*.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"], ), - prefix = "upb/mini_table/internal", - visibility = ["//python/dist:__pkg__"], + visibility = [ + "//cmake:__pkg__", + "//python/dist:__pkg__", + ] ) # end:github_only diff --git a/upb/util/BUILD b/upb/util/BUILD index bdace2282b..6a54c2bb0c 100644 --- a/upb/util/BUILD +++ b/upb/util/BUILD @@ -4,10 +4,6 @@ load( "upb_proto_reflection_library", ) -# begin:github_only -load("@rules_pkg//:mappings.bzl", "pkg_files") -# end:github_only - # begin:google_only # package(default_applicable_licenses = ["//:license"]) # end:google_only @@ -165,8 +161,8 @@ cc_test( ) # begin:github_only -pkg_files( - name = "util_source_files", +filegroup( + name = "source_files", srcs = [ "compare.c", "compare.h", @@ -175,7 +171,6 @@ pkg_files( "required_fields.c", "required_fields.h", ], - prefix = "upb/util", visibility = ["//python/dist:__pkg__"], ) # end:github_only