diff options
author | Tony Aiuto <aiuto@google.com> | 2023-03-21 15:56:03 -0400 |
---|---|---|
committer | Tony Aiuto <aiuto@google.com> | 2023-03-21 15:56:03 -0400 |
commit | 903667be86beb87ac9792ef8d7d065cca03f00d6 (patch) | |
tree | 1fc58c580cc4f6d42d8ceca4a6f3b371e9be5803 | |
parent | ad97c7dcf0df30e7a9e9337d13b42fffca8fb962 (diff) | |
download | bazelbuild-rules_license-903667be86beb87ac9792ef8d7d065cca03f00d6.tar.gz |
Allow license_text to be a normal label.
Make it easy for someone (who vendors the code) to enable the old behavior.
Fixes #68
-rw-r--r-- | rules/license.bzl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/rules/license.bzl b/rules/license.bzl index e461388..ea7a586 100644 --- a/rules/license.bzl +++ b/rules/license.bzl @@ -24,6 +24,8 @@ load( "license_rule_impl", ) +_require_license_text_is_a_file = False + _license = rule( implementation = license_rule_impl, attrs = { @@ -34,6 +36,7 @@ _license = rule( " should be listed here. If the user can choose a single one" + " of many, then only list one here.", providers = [LicenseKindInfo], + # This should be the null configuration, not the exec. cfg = "exec", ), "copyright_notice": attr.string( @@ -107,11 +110,12 @@ def license( fail("Can not use both license_kind and license_kinds") license_kinds = [license_kind] - # Make sure the file exists as named in the rule. A glob expression that - # expands to the name of the file is not acceptable. - srcs = native.glob([license_text]) - if len(srcs) != 1 or srcs[0] != license_text: - fail("Specified license file doesn't exist: %s" % license_text) + if _require_license_text_is_a_file: + # Make sure the file exists as named in the rule. A glob expression that + # expands to the name of the file is not acceptable. + srcs = native.glob([license_text]) + if len(srcs) != 1 or srcs[0] != license_text: + fail("Specified license file doesn't exist: %s" % license_text) _license( name = name, |