Expand tree artifacts in textual_hdrs in generated module maps (#787) Tree artifacts in a `cc_library`'s `textual_hdrs` end up in the generated module map as a single `header` entry with the directory's path, which fails to parse (`error: header '<dir path>' not found`), instead of one `textual header` entry per contained file. `hdrs` and `srcs` already expand tree artifacts via the module map action's tree expander; this applies the same expansion to the `public_textual_headers` bucket. Closes #787 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/787 from fmeum:textual-hdrs-tree-expansion 83f1cf1cb41fce63c6a5c712fe5ba0d610a33036 PiperOrigin-RevId: 963952603 Change-Id: If193b253b0343583c283e3027e5154282afe8139
diff --git a/cc/private/compile/cc_compilation_helper.bzl b/cc/private/compile/cc_compilation_helper.bzl index 6e647fd..a30397d 100644 --- a/cc/private/compile/cc_compilation_helper.bzl +++ b/cc/private/compile/cc_compilation_helper.bzl
@@ -312,7 +312,7 @@ add_header(path = header.path, visibility = "", can_compile = False) added_paths.add(header.path) - for header in parameters.public_textual_headers: + for header in expanded(parameters.public_textual_headers): if header.path in added_paths: continue add_header(path = header.path, visibility = "", can_compile = False) @@ -402,6 +402,7 @@ tree_artifacts = [h for h in private_headers if h.is_directory] tree_artifacts += [h for h in public_headers if h.is_directory] tree_artifacts += [h for h in textual_headers if h.is_directory] + tree_artifacts += [h for h in public_textual_headers if h.is_directory] content.add_all(tree_artifacts, map_each = lambda x: None, allow_closure = True) actions.write(module_map.file, content = content, is_executable = True, mnemonic = "CppModuleMap")