xref: /aosp_15_r20/external/bazel-skylib/docs/bzl_library.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2
3Skylib module containing a library rule for aggregating rules files.
4
5<a id="bzl_library"></a>
6
7## bzl_library
8
9<pre>
10bzl_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
13Creates a logical collection of Starlark .bzl and .scl files.
14
15Example:
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**ATTRIBUTES**
60
61
62| Name  | Description | Type | Mandatory | Default |
63| :------------- | :------------- | :------------- | :------------- | :------------- |
64| <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 |  |
65| <a id="bzl_library-deps"></a>deps |  List of other `bzl_library` or `filegroup` targets that are required by the Starlark files listed in `srcs`.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
66| <a id="bzl_library-srcs"></a>srcs |  List of `.bzl` and `.scl` files that are processed to create this target.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
67
68
69<a id="StarlarkLibraryInfo"></a>
70
71## StarlarkLibraryInfo
72
73<pre>
74StarlarkLibraryInfo(<a href="#StarlarkLibraryInfo-srcs">srcs</a>, <a href="#StarlarkLibraryInfo-transitive_srcs">transitive_srcs</a>)
75</pre>
76
77Information on contained Starlark rules.
78
79**FIELDS**
80
81
82| Name  | Description |
83| :------------- | :------------- |
84| <a id="StarlarkLibraryInfo-srcs"></a>srcs |  Top level rules files.    |
85| <a id="StarlarkLibraryInfo-transitive_srcs"></a>transitive_srcs |  Transitive closure of rules files required for interpretation of the srcs    |
86
87
88