Skip to content

Commit

Permalink
Use \external:I instead of -isystem when using MSVC for header dirs
Browse files Browse the repository at this point in the history
Summary:
WTTS
This allows us to correctly include header dirs and build bigger projects

Reviewed By: ndmitchell

Differential Revision: D44956819

fbshipit-source-id: b1ff91f9169562388d33e8c9e8c91924cf5b3971
  • Loading branch information
lmvasquezg authored and facebook-github-bot committed Apr 13, 2023
1 parent b643c35 commit 81233d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cxx/cxx.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions cxx/preprocessor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
"""
Expand Down

0 comments on commit 81233d0

Please sign in to comment.