diff --git a/cxx/cxx.bzl b/cxx/cxx.bzl index cfc80e4bd..4ea798849 100644 --- a/cxx/cxx.bzl +++ b/cxx/cxx.bzl @@ -116,6 +116,7 @@ load( "cxx_exported_preprocessor_info", "cxx_inherited_preprocessor_infos", "cxx_merge_cpreprocessors", + "format_system_include_arg", ) cxx_link_into_shared_library = _cxx_link_into_shared_library @@ -340,9 +341,10 @@ def prebuilt_cxx_library_impl(ctx: "context") -> ["provider"]: inherited_pp_infos = cxx_inherited_preprocessor_infos(exported_first_order_deps) generic_exported_pre = cxx_exported_preprocessor_info(ctx, cxx_get_regular_cxx_headers_layout(ctx), []) args = cxx_attr_exported_preprocessor_flags(ctx) + compiler_type = get_cxx_toolchain_info(ctx).cxx_compiler_info.compiler_type if header_dirs != None: for x in header_dirs: - args += ["-isystem", x] + args.append(format_system_include_arg(cmd_args(x), compiler_type)) specific_exportd_pre = CPreprocessor(args = args) providers.append(cxx_merge_cpreprocessors( ctx, diff --git a/cxx/preprocessor.bzl b/cxx/preprocessor.bzl index 0e5788d47..8ccac7034 100644 --- a/cxx/preprocessor.bzl +++ b/cxx/preprocessor.bzl @@ -82,7 +82,7 @@ def _cpreprocessor_include_dirs(pres: [CPreprocessor.type]): args.add(cmd_args(d, format = "-I{}")) if pre.system_include_dirs != None: for d in pre.system_include_dirs.include_dirs: - system_include_args = _format_system_include_arg(d, pre.system_include_dirs.compiler_type) + system_include_args = format_system_include_arg(cmd_args(d), pre.system_include_dirs.compiler_type) args.add(system_include_args) return args @@ -161,11 +161,11 @@ def _format_include_arg(flag: str.type, path: "cmd_args", compiler_type: str.typ else: return [cmd_args(flag), path] -def _format_system_include_arg(path: "label_relative_path", compiler_type: str.type) -> ["cmd_args"]: +def format_system_include_arg(path: "cmd_args", compiler_type: str.type) -> ["cmd_args"]: if compiler_type == "windows": return [cmd_args(path, format = "/external:I{}")] else: - return [cmd_args("-isystem"), cmd_args(path)] + return [cmd_args("-isystem"), path] def cxx_exported_preprocessor_info(ctx: "context", headers_layout: CxxHeadersLayout.type, extra_preprocessors: [CPreprocessor.type] = []) -> CPreprocessor.type: """