Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow .scl files in bzl_library #450

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bzl_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ 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.",
tetromino marked this conversation as resolved.
Show resolved Hide resolved
),
"deps": attr.label_list(
allow_files = [".bzl"],
allow_files = [".bzl", ".scl"],
providers = [
[StarlarkLibraryInfo],
],
doc = """List of other `bzl_library` targets that are required by the
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:
Expand Down
6 changes: 6 additions & 0 deletions docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
88 changes: 88 additions & 0 deletions docs/bzl_library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

Skylib module containing a library rule for aggregating rules files.

<a id="bzl_library"></a>

## bzl_library

<pre>
bzl_library(<a href="#bzl_library-name">name</a>, <a href="#bzl_library-deps">deps</a>, <a href="#bzl_library-srcs">srcs</a>)
</pre>

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 |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <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 | |
| <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> |
| <a id="bzl_library-srcs"></a>srcs | List of <code>.bzl</code> or <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> |


<a id="StarlarkLibraryInfo"></a>

## StarlarkLibraryInfo

<pre>
StarlarkLibraryInfo(<a href="#StarlarkLibraryInfo-srcs">srcs</a>, <a href="#StarlarkLibraryInfo-transitive_srcs">transitive_srcs</a>)
</pre>

Information on contained Starlark rules.

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="StarlarkLibraryInfo-srcs"></a>srcs | Top level rules files. |
| <a id="StarlarkLibraryInfo-transitive_srcs"></a>transitive_srcs | Transitive closure of rules files required for interpretation of the srcs |