Skip to content

feat: allow adding cc deps to recipe rule #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{cc,hh,cpp,hpp}]
# matching .clang-format IndentWidth
indent_size = 2

[*.{bzl,bazel}]
# matches output of buildifier
indent_size = 4
indent_style = space
29 changes: 29 additions & 0 deletions ecsact/private/ecsact_build_recipe.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ def _ecsact_build_recipe(ctx):
})
recipe_data.append(info.plugin)

for cc_dep in ctx.attr.cc_deps:
cc_info = cc_dep[CcInfo]

for hdr in cc_info.compilation_context.headers.to_list():
hdr_prefix = ""

for quote_inc in cc_info.compilation_context.quote_includes.to_list():
if hdr.path.startswith(quote_inc):
hdr_prefix = quote_inc
break
for sys_inc in cc_info.compilation_context.system_includes.to_list():
if hdr.path.startswith(sys_inc):
hdr_prefix = sys_inc
break

if hdr_prefix:
hdr_prefix_base = hdr.path.removeprefix(hdr_prefix)
hdr_prefix_base_idx = hdr_prefix_base.rindex("/")
hdr_prefix_base = hdr_prefix_base[:hdr_prefix_base_idx]
sources.append({
"path": hdr.path,
"outdir": "include" + hdr_prefix_base,
"relative_to_cwd": True,
})
recipe_data.append(hdr)

recipe = {
"name": ctx.attr.name,
"sources": sources,
Expand All @@ -89,6 +115,9 @@ ecsact_build_recipe = rule(
"srcs": attr.label_list(
allow_files = True,
),
"cc_deps": attr.label_list(
providers = [CcInfo],
),
"fetch_srcs": attr.string_list_dict(
allow_empty = True,
),
Expand Down