From a96abe6f29022eda111d53009ceae70a4275029a Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 11 Jul 2024 19:21:47 +0000 Subject: [PATCH] Update unix_cc_toolchain_config.bzl --- tools/cpp/unix_cc_toolchain_config.bzl | 32 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/cpp/unix_cc_toolchain_config.bzl b/tools/cpp/unix_cc_toolchain_config.bzl index 5a0cd710575076..d87917d9043714 100644 --- a/tools/cpp/unix_cc_toolchain_config.bzl +++ b/tools/cpp/unix_cc_toolchain_config.bzl @@ -102,6 +102,33 @@ def parse_headers_support(parse_headers_tool_path): if not parse_headers_tool_path: return [], [] action_configs = [ + action_config( + action_name = ACTION_NAMES.c_header_parsing, + tools = [ + tool(path = parse_headers_tool_path), + ], + flag_sets = [ + flag_set( + flag_groups = [ + flag_group( + flags = [ + "-xc-header", + "-fsyntax-only", + ], + ), + ], + ), + ], + implies = [ + # Copied from the legacy feature definition in CppActionConfigs.java. + "legacy_compile_flags", + "user_compile_flags", + "sysroot", + "unfiltered_compile_flags", + "compiler_input_flags", + "compiler_output_flags", + ], + ), action_config( action_name = ACTION_NAMES.cpp_header_parsing, tools = [ @@ -112,10 +139,6 @@ def parse_headers_support(parse_headers_tool_path): flag_groups = [ flag_group( flags = [ - # Note: This treats all headers as C++ headers, which may lead to - # parsing failures for C headers that are not valid C++. - # For such headers, use features = ["-parse_headers"] to selectively - # disable parsing. "-xc++-header", "-fsyntax-only", ], @@ -145,6 +168,7 @@ all_compile_actions = [ ACTION_NAMES.linkstamp_compile, ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_header_parsing, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen,