bazel-skylib/docs/bzl_library.md

2.4 KiB
Executable File

Skylib module containing a library rule for aggregating rules files.

bzl_library

bzl_library(name, deps, srcs)

Creates a logical collection of Starlark .bzl and .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:

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
    name = "checkstyle-rules",
    srcs = ["checkstyle.bzl"],
)

lua/BUILD:

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 and .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