Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: better cc dep support on Windows #67

Merged
merged 1 commit into from
Sep 19, 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
28 changes: 14 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +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
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
31 changes: 22 additions & 9 deletions ecsact/private/ecsact_build_recipe.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,44 @@ def _ecsact_build_recipe(ctx):
})
recipe_data.append(info.plugin)

cc_dep_compilation_contexts = []
for cc_dep in ctx.attr.cc_deps:
cc_info = cc_dep[CcInfo]
cc_dep_compilation_contexts.append(cc_info.compilation_context)

for hdr in cc_info.compilation_context.headers.to_list():
if len(cc_dep_compilation_contexts) > 0:
cc_dep_compilation_context = cc_common.merge_compilation_contexts(compilation_contexts = cc_dep_compilation_contexts)

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

for quote_inc in cc_info.compilation_context.quote_includes.to_list():
for quote_inc in cc_dep_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():
for sys_inc in cc_dep_compilation_context.system_includes.to_list():
if hdr.path.startswith(sys_inc):
hdr_prefix = sys_inc
break
for inc in cc_dep_compilation_context.includes.to_list():
if hdr.path.startswith(inc):
hdr_prefix = inc
break

hdr_prefix_base = ""
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)
else:
hdr_prefix_base_idx = hdr.path.rindex("/")
hdr_prefix_base = "/" + hdr.path[: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,
Expand Down