Merge pull request #162 from adam-azarchs/azarchs/no-license-file
fix: allow license_text=None in license declaration
diff --git a/rules/license.bzl b/rules/license.bzl
index 7c68fc9..7e80018 100644
--- a/rules/license.bzl
+++ b/rules/license.bzl
@@ -42,7 +42,12 @@
" 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.
+ # Bazel 8+ users: In Bazel 8, the targets for package_metadata are
+ # always in a null configuration. This reflects the fact that they
+ # are non-configurable and keeps the node for a license in a single
+ # configuration, no matter what physical platforms you are building
+ # for.
+ # TODO: (after bazel 8.0 is mainstream): Remove this line.
cfg = "exec",
),
"copyright_notice": attr.string(
diff --git a/rules/licenses_core.bzl b/rules/licenses_core.bzl
index fff3b82..921cb06 100644
--- a/rules/licenses_core.bzl
+++ b/rules/licenses_core.bzl
@@ -151,7 +151,12 @@
# fully resolved. If exec is in the bin_dir path, then the current
# configuration is probably cfg = exec.
if "-exec-" in ctx.bin_dir.path:
- return [provider_factory(deps = depset(), licenses = depset(), traces = [])]
+ return [provider_factory(
+ target_under_license = target.label,
+ deps = depset(),
+ licenses = depset(),
+ traces = [],
+ )]
# Now gather transitive collection of providers from the targets
# this target depends upon.
@@ -164,7 +169,12 @@
_get_transitive_metadata(ctx, trans_licenses, trans_other_metadata, trans_package_info, trans_deps, traces, provider_factory, filter_func)
if not licenses and not trans_licenses:
- return [provider_factory(deps = depset(), licenses = depset(), traces = [])]
+ return [provider_factory(
+ target_under_license = target.label,
+ deps = depset(),
+ licenses = depset(),
+ traces = [],
+ )]
# If this is the target, start the sequence of traces.
if ctx.attr._trace[TraceInfo].trace and ctx.attr._trace[TraceInfo].trace in str(ctx.label):