Skip to content

Commit b11471a

Browse files
authored
feat: better cc dep support on Windows (#67)
1 parent 4f9b35e commit b11471a

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

.editorconfig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
root = true
2-
3-
[*]
4-
end_of_line = lf
5-
insert_final_newline = true
6-
7-
[*.{cc,hh,cpp,hpp}]
8-
# matching .clang-format IndentWidth
9-
indent_size = 2
10-
11-
[*.{bzl,bazel}]
12-
# matches output of buildifier
13-
indent_size = 4
14-
indent_style = space
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{cc,hh,cpp,hpp}]
8+
# matching .clang-format IndentWidth
9+
indent_size = 2
10+
11+
[*.{bzl,bazel}]
12+
# matches output of buildifier
13+
indent_size = 4
14+
indent_style = space

ecsact/private/ecsact_build_recipe.bzl

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,44 @@ def _ecsact_build_recipe(ctx):
6464
})
6565
recipe_data.append(info.plugin)
6666

67+
cc_dep_compilation_contexts = []
6768
for cc_dep in ctx.attr.cc_deps:
6869
cc_info = cc_dep[CcInfo]
70+
cc_dep_compilation_contexts.append(cc_info.compilation_context)
6971

70-
for hdr in cc_info.compilation_context.headers.to_list():
72+
if len(cc_dep_compilation_contexts) > 0:
73+
cc_dep_compilation_context = cc_common.merge_compilation_contexts(compilation_contexts = cc_dep_compilation_contexts)
74+
75+
for hdr in cc_dep_compilation_context.headers.to_list():
7176
hdr_prefix = ""
7277

73-
for quote_inc in cc_info.compilation_context.quote_includes.to_list():
78+
for quote_inc in cc_dep_compilation_context.quote_includes.to_list():
7479
if hdr.path.startswith(quote_inc):
7580
hdr_prefix = quote_inc
7681
break
77-
for sys_inc in cc_info.compilation_context.system_includes.to_list():
82+
for sys_inc in cc_dep_compilation_context.system_includes.to_list():
7883
if hdr.path.startswith(sys_inc):
7984
hdr_prefix = sys_inc
8085
break
86+
for inc in cc_dep_compilation_context.includes.to_list():
87+
if hdr.path.startswith(inc):
88+
hdr_prefix = inc
89+
break
8190

91+
hdr_prefix_base = ""
8292
if hdr_prefix:
8393
hdr_prefix_base = hdr.path.removeprefix(hdr_prefix)
8494
hdr_prefix_base_idx = hdr_prefix_base.rindex("/")
8595
hdr_prefix_base = hdr_prefix_base[:hdr_prefix_base_idx]
86-
sources.append({
87-
"path": hdr.path,
88-
"outdir": "include" + hdr_prefix_base,
89-
"relative_to_cwd": True,
90-
})
91-
recipe_data.append(hdr)
96+
else:
97+
hdr_prefix_base_idx = hdr.path.rindex("/")
98+
hdr_prefix_base = "/" + hdr.path[:hdr_prefix_base_idx]
99+
sources.append({
100+
"path": hdr.path,
101+
"outdir": "include" + hdr_prefix_base,
102+
"relative_to_cwd": True,
103+
})
104+
recipe_data.append(hdr)
92105

93106
recipe = {
94107
"name": ctx.attr.name,

0 commit comments

Comments
 (0)