Skip to content

Commit

Permalink
Merge pull request #161 from cgrindel/gh0055_missing_target_under_lic…
Browse files Browse the repository at this point in the history
…ense

fix: ensure `gather_metadata_info_common()` returns providers with  `target_under_license` set
  • Loading branch information
tonyaiuto authored Jan 14, 2025
2 parents a0bc8e7 + ed5bb25 commit 8144e77
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rules/licenses_core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ def gather_metadata_info_common(target, ctx, provider_factory, metadata_provider
# 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.
Expand All @@ -164,7 +169,12 @@ def gather_metadata_info_common(target, ctx, provider_factory, metadata_provider
_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):
Expand Down

0 comments on commit 8144e77

Please sign in to comment.