Skip to content

Commit 12dd004

Browse files
authored
Allow .scl files in bzl_library (#450)
See bazelbuild/bazel@a0cd355
1 parent 0a34b7e commit 12dd004

File tree

3 files changed

+98
-4
lines changed

3 files changed

+98
-4
lines changed

bzl_library.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ bzl_library = rule(
4646
implementation = _bzl_library_impl,
4747
attrs = {
4848
"srcs": attr.label_list(
49-
allow_files = [".bzl"],
50-
doc = "List of `.bzl` files that are processed to create this target.",
49+
allow_files = [".bzl", ".scl"],
50+
doc = "List of `.bzl` and `.scl` files that are processed to create this target.",
5151
),
5252
"deps": attr.label_list(
53-
allow_files = [".bzl"],
53+
allow_files = [".bzl", ".scl"],
5454
providers = [
5555
[StarlarkLibraryInfo],
5656
],
5757
doc = """List of other `bzl_library` targets that are required by the
5858
Starlark files listed in `srcs`.""",
5959
),
6060
},
61-
doc = """Creates a logical collection of Starlark .bzl files.
61+
doc = """Creates a logical collection of Starlark .bzl and .scl files.
6262
6363
Example:
6464
Suppose your project has the following structure:

docs/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ stardoc_with_diff_test(
1414
out_label = "//docs:build_test_doc.md",
1515
)
1616

17+
stardoc_with_diff_test(
18+
name = "bzl_library",
19+
bzl_library_target = "//:bzl_library",
20+
out_label = "//docs:bzl_library.md",
21+
)
22+
1723
stardoc_with_diff_test(
1824
name = "collections",
1925
bzl_library_target = "//lib:collections",

docs/bzl_library.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2+
3+
Skylib module containing a library rule for aggregating rules files.
4+
5+
<a id="bzl_library"></a>
6+
7+
## bzl_library
8+
9+
<pre>
10+
bzl_library(<a href="#bzl_library-name">name</a>, <a href="#bzl_library-deps">deps</a>, <a href="#bzl_library-srcs">srcs</a>)
11+
</pre>
12+
13+
Creates a logical collection of Starlark .bzl and .scl files.
14+
15+
Example:
16+
Suppose your project has the following structure:
17+
18+
```
19+
[workspace]/
20+
WORKSPACE
21+
BUILD
22+
checkstyle/
23+
BUILD
24+
checkstyle.bzl
25+
lua/
26+
BUILD
27+
lua.bzl
28+
luarocks.bzl
29+
```
30+
31+
In this case, you can have `bzl_library` targets in `checkstyle/BUILD` and
32+
`lua/BUILD`:
33+
34+
`checkstyle/BUILD`:
35+
36+
```python
37+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
38+
39+
bzl_library(
40+
name = "checkstyle-rules",
41+
srcs = ["checkstyle.bzl"],
42+
)
43+
```
44+
45+
`lua/BUILD`:
46+
47+
```python
48+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
49+
50+
bzl_library(
51+
name = "lua-rules",
52+
srcs = [
53+
"lua.bzl",
54+
"luarocks.bzl",
55+
],
56+
)
57+
```
58+
59+
60+
**ATTRIBUTES**
61+
62+
63+
| Name | Description | Type | Mandatory | Default |
64+
| :------------- | :------------- | :------------- | :------------- | :------------- |
65+
| <a id="bzl_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
66+
| <a id="bzl_library-deps"></a>deps | List of other <code>bzl_library</code> targets that are required by the Starlark files listed in <code>srcs</code>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
67+
| <a id="bzl_library-srcs"></a>srcs | List of <code>.bzl</code> and <code>.scl</code> files that are processed to create this target. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
68+
69+
70+
<a id="StarlarkLibraryInfo"></a>
71+
72+
## StarlarkLibraryInfo
73+
74+
<pre>
75+
StarlarkLibraryInfo(<a href="#StarlarkLibraryInfo-srcs">srcs</a>, <a href="#StarlarkLibraryInfo-transitive_srcs">transitive_srcs</a>)
76+
</pre>
77+
78+
Information on contained Starlark rules.
79+
80+
**FIELDS**
81+
82+
83+
| Name | Description |
84+
| :------------- | :------------- |
85+
| <a id="StarlarkLibraryInfo-srcs"></a>srcs | Top level rules files. |
86+
| <a id="StarlarkLibraryInfo-transitive_srcs"></a>transitive_srcs | Transitive closure of rules files required for interpretation of the srcs |
87+
88+

0 commit comments

Comments
 (0)