Skip to content

Commit

Permalink
handle rhs leading slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Apr 9, 2024
1 parent f6e3eed commit a3cfeb0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def llvm_register_toolchains():
pass
""")

def _join(path1, path2):
if path1:
return paths.join(path1, path2.lstrip("/"))
else:
return path2

def llvm_config_impl(rctx):
_check_os_arch_keys(rctx.attr.sysroot)
_check_os_arch_keys(rctx.attr.cxx_builtin_include_directories)
Expand Down Expand Up @@ -322,14 +328,14 @@ def _cc_toolchain_str(
sysroot_prefix = "%sysroot%"
if target_os == "linux":
cxx_builtin_include_directories.extend([
paths.join(sysroot_prefix, "include"),
paths.join(sysroot_prefix, "usr/include"),
paths.join(sysroot_prefix, "usr/local/include"),
_join(sysroot_prefix, "/include"),
_join(sysroot_prefix, "/usr/include"),
_join(sysroot_prefix, "/usr/local/include"),
])
elif target_os == "darwin":
cxx_builtin_include_directories.extend([
paths.join(sysroot_prefix, "usr/include"),
paths.join(sysroot_prefix, "System/Library/Frameworks"),
_join(sysroot_prefix, "/usr/include"),
_join(sysroot_prefix, "/System/Library/Frameworks"),
])
else:
fail("Unreachable")
Expand Down

0 comments on commit a3cfeb0

Please sign in to comment.