Created
December 16, 2023 13:00
-
-
Save Warchant/7d9d2508fd74cef6a71b9beee2bc22a6 to your computer and use it in GitHub Desktop.
Create headers for a target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _impl(target, ctx): | |
deps = [target] | |
if hasattr(ctx.rule.attr, "elf"): | |
deps.append(ctx.rule.attr.elf) | |
if hasattr(ctx.rule.attr, "srcs"): | |
deps.extend(ctx.rule.attr.srcs) | |
if hasattr(ctx.rule.attr, "deps"): | |
deps.extend(ctx.rule.attr.deps) | |
all_header_files = [] | |
for dep in deps: | |
if CcInfo in dep: | |
all_header_files.append(dep[CcInfo].compilation_context.headers) | |
if OutputGroupInfo in dep and hasattr(dep[OutputGroupInfo], "header_files"): | |
all_header_files.append(dep[OutputGroupInfo].header_files) | |
return [ | |
OutputGroupInfo( | |
header_files = depset( | |
transitive = all_header_files | |
), | |
), | |
] | |
materialize_headers = aspect( | |
attr_aspects = ["srcs", "deps", "elf"], | |
implementation = _impl, | |
apply_to_generating_rules = True, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment