Skip to content

Commit

Permalink
Update cc_binary_wrapper to account for select statements
Browse files Browse the repository at this point in the history
Previously, cc_binary would fail if dynamic_deps was specified and a select statement

RELNOTES: none
PiperOrigin-RevId: 435754932
  • Loading branch information
Googler authored and copybara-github committed Mar 18, 2022
1 parent 314b090 commit 987bf12
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_binary_wrapper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ dynamic_deps attribute is not specified.
load(":common/cc/cc_binary_with_aspects.bzl", cc_binary_with_aspects = "cc_binary")
load(":common/cc/cc_binary_without_aspects.bzl", cc_binary_without_aspects = "cc_binary")

def _is_non_empty_list_or_select(value, attr):
if type(value) == "list":
return len(value) > 0
elif type(value) == "select":
return True
else:
fail("Only select or list is valid for {} attr".format(attr))

def cc_binary(**kwargs):
# Propagate an aspect if dynamic_deps attribute is specified.
if "dynamic_deps" in kwargs and len(kwargs["dynamic_deps"]) > 0:
if "dynamic_deps" in kwargs and _is_non_empty_list_or_select(kwargs["dynamic_deps"], "dynamic_deps"):
cc_binary_with_aspects(**kwargs)
else:
cc_binary_without_aspects(**kwargs)

0 comments on commit 987bf12

Please sign in to comment.