Skip to content

Commit 77aa640

Browse files
afq984Chromeos LUCI
authored and
Chromeos LUCI
committed
Enforce go/cras-style#build-time-feature-switches in define_feature
BUG=None TEST=try to define a feature switch named FOO_BAR and Bazel complains about it Change-Id: I36100c59a9bc7699c7316e2de5a13c323c0f9e14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/6126535 Commit-Queue: Li-Yu Yu <[email protected]> Tested-by: [email protected] <[email protected]> Reviewed-by: Terry Cheong <[email protected]>
1 parent 3c7ba89 commit 77aa640

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

utils.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def bool_flag_config(name, build_setting_default):
2121

2222
def define_feature(condition, define):
2323
"""Defines `define`=1 if condition is true, otherwise 0"""
24+
if not define.startswith(("CRAS_", "HAVE_")):
25+
fail("Invalid feature switch %r. Feature switch names must start with CRAS_ or HAVE_. See go/cras-style#build-time-feature-switches" % define)
2426
return select({
2527
condition: ["{}=1".format(define)],
2628
"//conditions:default": ["{}=0".format(define)],

0 commit comments

Comments
 (0)