Skip to content

Commit

Permalink
runner: propagate 'testonly' property to sh_binary
Browse files Browse the repository at this point in the history
this makes sure that if testonly is set in the macro, it's propagated
both to the runner _and_ the wrapper sh_binary. as is, setting
'testonly' in the macro will result in an unbuildable sh_binary if there
are testonly dependencies.

why this is needed: slightly esoteric, but our build process currently
uses the gazelle plugin from contrib_rules_jvm. for uninteresting
reasons, this depends on the output of another tool, which itself needs
to process testonly dependencies.
  • Loading branch information
pjjw authored and fmeum committed Jan 6, 2025
1 parent 661b2a0 commit 12cc6fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ def _gazelle_kwargs_prepare(name, kwargs):
visibility = kwargs.pop("visibility", None)
return name + "-runner", visibility

def gazelle(name, **kwargs):
def gazelle(name, testonly = False, **kwargs):
runner_name, visibility = _gazelle_kwargs_prepare(name, kwargs)

_gazelle_runner(
name = runner_name,
testonly = testonly,
**kwargs
)
tags_set = {t: "" for t in kwargs.pop("tags", [])}
Expand All @@ -229,6 +230,7 @@ def gazelle(name, **kwargs):
tags = tags,
srcs = [runner_name],
visibility = visibility,
testonly = testonly,
deps = ["@bazel_tools//tools/bash/runfiles"],
data = kwargs["data"] if "data" in kwargs else [],
)
Expand Down

0 comments on commit 12cc6fe

Please sign in to comment.