From 5fe27626cb76083f9ef3f92d14a629dc769f7555 Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Wed, 31 May 2023 11:48:01 -0400 Subject: [PATCH 1/3] Allow .scl files in bzl_library See https://github.com/bazelbuild/bazel/commit/a0cd355347b57b17f28695a84af168f9fd200ba1 --- bzl_library.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bzl_library.bzl b/bzl_library.bzl index 1b59440f..be63efd5 100644 --- a/bzl_library.bzl +++ b/bzl_library.bzl @@ -46,11 +46,11 @@ bzl_library = rule( implementation = _bzl_library_impl, attrs = { "srcs": attr.label_list( - allow_files = [".bzl"], - doc = "List of `.bzl` files that are processed to create this target.", + allow_files = [".bzl", ".scl"], + doc = "List of `.bzl` or `.scl` files that are processed to create this target.", ), "deps": attr.label_list( - allow_files = [".bzl"], + allow_files = [".bzl", ".scl"], providers = [ [StarlarkLibraryInfo], ], @@ -58,7 +58,7 @@ bzl_library = rule( Starlark files listed in `srcs`.""", ), }, - doc = """Creates a logical collection of Starlark .bzl files. + doc = """Creates a logical collection of Starlark .bzl or .scl files. Example: Suppose your project has the following structure: From baf484925a840757ff0fa141f345937707dba0ad Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Wed, 31 May 2023 11:48:23 -0400 Subject: [PATCH 2/3] Add docs for bzl_library --- docs/BUILD | 6 ++++ docs/bzl_library.md | 88 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100755 docs/bzl_library.md diff --git a/docs/BUILD b/docs/BUILD index 4d31cd10..a809f2f0 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -14,6 +14,12 @@ stardoc_with_diff_test( out_label = "//docs:build_test_doc.md", ) +stardoc_with_diff_test( + name = "bzl_library", + bzl_library_target = "//:bzl_library", + out_label = "//docs:bzl_library.md", +) + stardoc_with_diff_test( name = "collections", bzl_library_target = "//lib:collections", diff --git a/docs/bzl_library.md b/docs/bzl_library.md new file mode 100755 index 00000000..54694caf --- /dev/null +++ b/docs/bzl_library.md @@ -0,0 +1,88 @@ + + +Skylib module containing a library rule for aggregating rules files. + + + +## bzl_library + +
+bzl_library(name, deps, srcs)
+
+ +Creates a logical collection of Starlark .bzl or .scl files. + +Example: + Suppose your project has the following structure: + + ``` + [workspace]/ + WORKSPACE + BUILD + checkstyle/ + BUILD + checkstyle.bzl + lua/ + BUILD + lua.bzl + luarocks.bzl + ``` + + In this case, you can have `bzl_library` targets in `checkstyle/BUILD` and + `lua/BUILD`: + + `checkstyle/BUILD`: + + ```python + load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + + bzl_library( + name = "checkstyle-rules", + srcs = ["checkstyle.bzl"], + ) + ``` + + `lua/BUILD`: + + ```python + load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + + bzl_library( + name = "lua-rules", + srcs = [ + "lua.bzl", + "luarocks.bzl", + ], + ) + ``` + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | List of other bzl_library targets that are required by the Starlark files listed in srcs. | List of labels | optional | [] | +| srcs | List of .bzl or .scl files that are processed to create this target. | List of labels | optional | [] | + + + + +## StarlarkLibraryInfo + +
+StarlarkLibraryInfo(srcs, transitive_srcs)
+
+ +Information on contained Starlark rules. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| srcs | Top level rules files. | +| transitive_srcs | Transitive closure of rules files required for interpretation of the srcs | + + From 201c106fe62bf488286373232a172ea4f3ee1afe Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Wed, 31 May 2023 13:28:24 -0400 Subject: [PATCH 3/3] s/or/and/g --- bzl_library.bzl | 4 ++-- docs/bzl_library.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bzl_library.bzl b/bzl_library.bzl index be63efd5..ef479494 100644 --- a/bzl_library.bzl +++ b/bzl_library.bzl @@ -47,7 +47,7 @@ bzl_library = rule( attrs = { "srcs": attr.label_list( allow_files = [".bzl", ".scl"], - doc = "List of `.bzl` or `.scl` files that are processed to create this target.", + doc = "List of `.bzl` and `.scl` files that are processed to create this target.", ), "deps": attr.label_list( allow_files = [".bzl", ".scl"], @@ -58,7 +58,7 @@ bzl_library = rule( Starlark files listed in `srcs`.""", ), }, - doc = """Creates a logical collection of Starlark .bzl or .scl files. + doc = """Creates a logical collection of Starlark .bzl and .scl files. Example: Suppose your project has the following structure: diff --git a/docs/bzl_library.md b/docs/bzl_library.md index 54694caf..f4b0dc7e 100755 --- a/docs/bzl_library.md +++ b/docs/bzl_library.md @@ -10,7 +10,7 @@ Skylib module containing a library rule for aggregating rules files. bzl_library(name, deps, srcs) -Creates a logical collection of Starlark .bzl or .scl files. +Creates a logical collection of Starlark .bzl and .scl files. Example: Suppose your project has the following structure: @@ -64,7 +64,7 @@ Example: | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | deps | List of other bzl_library targets that are required by the Starlark files listed in srcs. | List of labels | optional | [] | -| srcs | List of .bzl or .scl files that are processed to create this target. | List of labels | optional | [] | +| srcs | List of .bzl and .scl files that are processed to create this target. | List of labels | optional | [] |