Skip to content

Commit 6e33f97

Browse files
author
Paolo Tranquilli
committed
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.
1 parent 99494dd commit 6e33f97

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

actions/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ package(default_visibility = ["//visibility:public"])
1111
pack_prefix = "/".join(parts),
1212
)
1313
for parts in (
14+
["actions"],
1415
[
1516
"experimental",
1617
"actions",
1718
],
18-
["actions"],
1919
)
2020
]

misc/bazel/pkg.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,10 @@ def codeql_pack(
448448
contain the `{CODEQL_PLATFORM}` marker.
449449
All files in the pack will be prefixed with `name`, unless `pack_prefix` is set, then is used instead.
450450
451-
This rule also provides a convenient installer target, with a path governed by `install_dest`.
451+
This rule also provides a convenient installer target named `<name>-installer`, with a path governed by `install_dest`.
452452
This installer is used for installing this pack into the source-tree, relative to the directory where the rule is used.
453-
See `codeql_pack_install` for more details.
453+
See `codeql_pack_install` for more details. The first `codeql_pack` defined in a bazel package also aliases this
454+
installer target with the `installer` name as a shortcut.
454455
455456
This function does not accept `visibility`, as packs are always public to make it easy to define pack groups.
456457
"""
@@ -474,6 +475,8 @@ def codeql_pack(
474475
visibility = ["//visibility:public"],
475476
)
476477
_codeql_pack_install(internal("installer"), [name], install_dest = install_dest, apply_pack_prefix = False)
478+
if not native.existing_rule("installer"):
479+
native.alias(name = "installer", actual = internal("installer"))
477480

478481
strip_prefix = _strip_prefix
479482

rust/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ codeql_pkg_files(
5656
pack_prefix = "/".join(parts),
5757
)
5858
for parts in (
59+
["rust"],
5960
[
6061
"experimental",
6162
"rust",
6263
],
63-
["rust"],
6464
)
6565
]

0 commit comments

Comments
 (0)