bazelbuild / rules_license

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gather_licenses_info_common does not traverse inputs via label_keyed_dict(s)

carpenterjc opened this issue · comments

Expected Behavior

Should traverse the dependencies, and pickup all licenses

Actual Behavior

The dict is not which are not list and is converted to a list of a dict so the labels are not traversed. Instead the keys from the dict should be traversed.

Steps to Reproduce the Problem

  1. Define a rule which takes a attr.label_keyed_string_dict
  2. Add a label as an input to that rule which has a license
  3. Check that gather licenses using the rule defined above

Specifications

diff --git a/C:/dev/rules_license-0.0.4/rules/licenses_core.bzl b/rules_license/rules/licenses_core.bzl
index 42702bdb7d..fae491539e 100644
--- a/C:/dev/rules_license-0.0.4/rules/licenses_core.bzl
+++ b/rules_license/rules/licenses_core.bzl
@@ -74,7 +74,9 @@ def _get_transitive_licenses(ctx, trans_licenses, trans_deps, traces, provider,
         a = getattr(ctx.rule.attr, name)
 
         # Make anything singleton into a list for convenience.
-        if type(a) != type([]):
+        if type(a) == type({}):
+            a = a.keys()
+        elif type(a) != type([]):
             a = [a]
         for dep in a:
             # Ignore anything that isn't a target
  • Version: 0.0.4
  • Platform: all