diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a5bbb0b --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/ecsact/private/ecsact_build_recipe.bzl b/ecsact/private/ecsact_build_recipe.bzl index 5c2cdd0..0fb84c8 100644 --- a/ecsact/private/ecsact_build_recipe.bzl +++ b/ecsact/private/ecsact_build_recipe.bzl @@ -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, @@ -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, ),