From a6a12e91656579f021e88a70bffaade8d0c1107b Mon Sep 17 00:00:00 2001 From: HONG Yifan Date: Thu, 12 Dec 2024 13:44:52 -0800 Subject: [PATCH] docs: //pkg:bzl_srcs update deps. This change updates deps for //pkg:bzl_srcs to include paths and rules_python, which comes from the individual rules. This bzl_library is next to the .bzl files. Users of rules_pkg may build stardoc for their own extensions by relying on this bzl_library directly. This change deletes the unnecessary starlark_library rule, because starlark_library itself already creates the non-dev dependency from rules_pkg to skylib. A user of rules_pkg will have to have skylib anyways. So let's just use skylib's bzl_library directly. It is okay to put non .bzl files in bzl_library. Test: locally update latest.md, no significant difference other than small changes due to the file being outdated in the first place. Link: https://github.com/bazelbuild/rules_pkg/issues/897 --- doc_build/BUILD | 3 ++- pkg/BUILD | 9 ++++--- pkg/private/make_starlark_library.bzl | 35 --------------------------- 3 files changed, 8 insertions(+), 39 deletions(-) delete mode 100644 pkg/private/make_starlark_library.bzl diff --git a/doc_build/BUILD b/doc_build/BUILD index d45155b0a..00cfaba4d 100644 --- a/doc_build/BUILD +++ b/doc_build/BUILD @@ -116,8 +116,9 @@ bzl_library( name = "rules_pkg_lib", srcs = [ "//:version.bzl", + ], + deps = [ "//pkg:bzl_srcs", - "@bazel_skylib//lib:paths", ], visibility = ["//visibility:public"], ) diff --git a/pkg/BUILD b/pkg/BUILD index b3115f587..df6fd252b 100644 --- a/pkg/BUILD +++ b/pkg/BUILD @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library") - # -*- coding: utf-8 -*- +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@rules_python//python:defs.bzl", "py_binary", "py_library") package(default_applicable_licenses = ["//:license"]) @@ -51,7 +50,7 @@ filegroup( ], ) -starlark_library( +bzl_library( name = "bzl_srcs", srcs = [ ":standard_package", @@ -62,6 +61,10 @@ starlark_library( "//pkg/private/zip:standard_package", "//pkg/releasing:standard_package", ], + deps = [ + "@rules_python//python:defs_bzl", + "@bazel_skylib//lib:paths", + ], visibility = ["//visibility:public"], ) diff --git a/pkg/private/make_starlark_library.bzl b/pkg/private/make_starlark_library.bzl deleted file mode 100644 index c6b0dee9d..000000000 --- a/pkg/private/make_starlark_library.bzl +++ /dev/null @@ -1,35 +0,0 @@ -"""Turn a label_list of mixed sources and bzl_library's into a bzl_library. - -The sources can be anything. Only the ones that end in ".bzl" will be added. -""" - -load("@bazel_skylib//:bzl_library.bzl", "StarlarkLibraryInfo") - -def _make_starlark_library(ctx): - direct = [] - transitive = [] - for src in ctx.attr.srcs: - if StarlarkLibraryInfo in src: - transitive.append(src[StarlarkLibraryInfo]) - else: - for file in src[DefaultInfo].files.to_list(): - if file.path.endswith(".bzl"): - # print(file.path) - direct.append(file) - all_files = depset(direct, transitive = transitive) - return [ - DefaultInfo(files = all_files, runfiles = ctx.runfiles(transitive_files = all_files)), - StarlarkLibraryInfo(srcs = direct, transitive_srcs = all_files), - ] - -starlark_library = rule( - implementation = _make_starlark_library, - attrs = { - "srcs": attr.label_list( - doc = "Any mix of source files. Only .bzl files will be used.", - allow_files = True, - cfg = "exec", - mandatory = True, - ), - }, -)