Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.aspect.build/llms.txt

Use this file to discover all available pages before exploring further.

sh_library rule definition.

Rule: sh_library

The main use for this rule is to aggregate together a logical “library” consisting of related scripts — programs in an interpreted language that does not require compilation or linking, such as the Bourne shell — and any data those programs need at run-time. Such “libraries” can then be used from the data attribute of one or more sh_binary rules. You can use the filegroup rule to aggregate data files. In interpreted programming languages, there’s not always a clear distinction between “code” and “data”: after all, the program is just “data” from the interpreter’s point of view. For this reason this rule has three attributes which are all essentially equivalent: srcs, deps and data. The current implementation does not distinguish between the elements of these lists. All three attributes accept rules, source files and generated files. It is however good practice to use the attributes for their usual purpose (as with other rules).

Examples

sh_library(
    name = "foo",
    data = [
        ":foo_service_script",  # an sh_binary with srcs
        ":deploy_foo",  # another sh_binary with srcs
    ],
)

Attributes

name
name
required
A unique name for this target.
srcs
list of labels
default:"[]"
The list of input files.This attribute should be used to list shell script source files that belong to this library. Scripts can load other scripts using the shell’s source or . command.
data
list of labels
default:"[]"
deps
list of labels
default:"[]"
The list of “library” targets to be aggregated into this target. See general comments about deps at Typical attributes defined by most build rules.This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target.