This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Bzl

Bazel rules related to Bazel itself

Develop rulesets from the monorepo root using their package paths, for example bazel test //tools/rules_docs/.... Each project declares its standalone name in its own release.MODULE.bazel.

To package the source archives, run:

bazel run //tools/bzl/cmd/release_archives -- --output-directory "$PWD/out/releases"

The command packages the committed source at HEAD, translates package labels for standalone consumers, removes the enclosing monorepo visibility directive from OpenSpec packages, and installs each release.MODULE.bazel as MODULE.bazel inside its archive. Use those manifests and archive checksums to prepare registry entries. DNSControl, ISO, and systemd provide their own release_archive build targets.

1 - Bzl

Bazel code

1.1 - al_alias_map

al_alias_map

load("@com_alwaldend_src//tools/bzl/rules:al_alias_map.bzl", "al_alias_map")

al_alias_map(aliases, visibility)

Generate aliases from an alias map

PARAMETERS

NameDescriptionDefault Value
aliasesalias map, keys are names, values are alias argumentsnone
visibilitydefault visibility["//:__subpackages__"]

1.2 - al_bzl_generate_repository

al_bzl_generate_repository

load("@com_alwaldend_src//tools/bzl/rules:al_bzl_generate_repository.bzl", "al_bzl_generate_repository")

al_bzl_generate_repository(name, files)

Generate a repository

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this repository.Namerequired
filesFiles to generate, keys are paths, values are file contentsDictionary: String -> Stringoptional{}

1.3 - al_bzl_library_map

al_bzl_library_map

load("@com_alwaldend_src//tools/bzl/rules:al_bzl_library_map.bzl", "al_bzl_library_map")

al_bzl_library_map(name, visibility, libs, deps, **kwargs)

Create bzl_library targets from a map

PARAMETERS

NameDescriptionDefault Value
namecombined bzl_library target namenone
visibility

-

None
libsbzl_library names{}
depsother al_bzl_library_map targets[]
kwargsbzl_library kwargsnone

1.4 - al_bzl_target_doc

al_bzl_target_doc

load("@com_alwaldend_src//tools/bzl/rules:al_bzl_target_doc.bzl", "al_bzl_target_doc")

al_bzl_target_doc(name, visibility, subpackages)

Document bazel targets

PARAMETERS

NameDescriptionDefault Value
nametarget namenone
visibility

-

none
subpackageslist of subpackages[]

1.5 - al_genquery_write_to_source_file

al_genquery_write_to_source_file

load("@com_alwaldend_src//tools/bzl/rules:al_genquery_write_to_source_file.bzl", "al_genquery_write_to_source_file")

al_genquery_write_to_source_file(name, expression, scope, var_name, out_file)

Write genquery result to a bzl file

Example:

    al_genquery_write_to_source_file(
        name = "al_bzl_libs",
        expression = """
            filter(
                "^//",
                attr(
                    "srcs",
                    ".{3,}",
                    kind(
                        "bzl_library",
                        deps("//bzl")
                    )
                )
            )
        """,
        out_file = "al_bzl_libs.bzl",
        scope = ["//bzl"],
        var_name = "AL_BZL_LIBS",
    )

PARAMETERS

NameDescriptionDefault Value
namename prefixnone
expressiongenquery expressionnone
scopegenquery scopenone
var_namevariable name in the generated .bzl filenone
out_fileoutput bzl filenone