Bazel: add an `installer` shortcut to `codeql_pack`

This makes the first `codeql_pack` in a package add an `installer` target
aliasing the `<name>-installer` one. This makes it so that one can for
example do `bazel run //rust:installer` instead of the stuttering
`bazel run //rust:rust-installer`. If a bazel package defines multiple
`codeql_pack` targets, the first one only will get the `installer` alias.
This commit is contained in:
Paolo Tranquilli 2024-11-19 10:25:31 +01:00
Родитель 99494dd540
Коммит 6e33f979c7
3 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -11,10 +11,10 @@ package(default_visibility = ["//visibility:public"])
pack_prefix = "/".join(parts), pack_prefix = "/".join(parts),
) )
for parts in ( for parts in (
["actions"],
[ [
"experimental", "experimental",
"actions", "actions",
], ],
["actions"],
) )
] ]

Просмотреть файл

@ -448,9 +448,10 @@ def codeql_pack(
contain the `{CODEQL_PLATFORM}` marker. contain the `{CODEQL_PLATFORM}` marker.
All files in the pack will be prefixed with `name`, unless `pack_prefix` is set, then is used instead. All files in the pack will be prefixed with `name`, unless `pack_prefix` is set, then is used instead.
This rule also provides a convenient installer target, with a path governed by `install_dest`. This rule also provides a convenient installer target named `<name>-installer`, with a path governed by `install_dest`.
This installer is used for installing this pack into the source-tree, relative to the directory where the rule is used. This installer is used for installing this pack into the source-tree, relative to the directory where the rule is used.
See `codeql_pack_install` for more details. See `codeql_pack_install` for more details. The first `codeql_pack` defined in a bazel package also aliases this
installer target with the `installer` name as a shortcut.
This function does not accept `visibility`, as packs are always public to make it easy to define pack groups. This function does not accept `visibility`, as packs are always public to make it easy to define pack groups.
""" """
@ -474,6 +475,8 @@ def codeql_pack(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
_codeql_pack_install(internal("installer"), [name], install_dest = install_dest, apply_pack_prefix = False) _codeql_pack_install(internal("installer"), [name], install_dest = install_dest, apply_pack_prefix = False)
if not native.existing_rule("installer"):
native.alias(name = "installer", actual = internal("installer"))
strip_prefix = _strip_prefix strip_prefix = _strip_prefix

Просмотреть файл

@ -56,10 +56,10 @@ codeql_pkg_files(
pack_prefix = "/".join(parts), pack_prefix = "/".join(parts),
) )
for parts in ( for parts in (
["rust"],
[ [
"experimental", "experimental",
"rust", "rust",
], ],
["rust"],
) )
] ]