|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | +load("@bazel_skylib//lib:paths.bzl", "paths") |
15 | 16 | load(
|
16 | 17 | "//toolchain:aliases.bzl",
|
17 | 18 | _aliased_libs = "aliased_libs",
|
@@ -49,6 +50,12 @@ def llvm_register_toolchains():
|
49 | 50 | pass
|
50 | 51 | """)
|
51 | 52 |
|
| 53 | +def _join(path1, path2): |
| 54 | + if path1: |
| 55 | + return paths.join(path1, path2.lstrip("/")) |
| 56 | + else: |
| 57 | + return path2 |
| 58 | + |
52 | 59 | def llvm_config_impl(rctx):
|
53 | 60 | _check_os_arch_keys(rctx.attr.sysroot)
|
54 | 61 | _check_os_arch_keys(rctx.attr.cxx_builtin_include_directories)
|
@@ -321,14 +328,14 @@ def _cc_toolchain_str(
|
321 | 328 | sysroot_prefix = "%sysroot%"
|
322 | 329 | if target_os == "linux":
|
323 | 330 | cxx_builtin_include_directories.extend([
|
324 |
| - sysroot_prefix + "/include", |
325 |
| - sysroot_prefix + "/usr/include", |
326 |
| - sysroot_prefix + "/usr/local/include", |
| 331 | + _join(sysroot_prefix, "/include"), |
| 332 | + _join(sysroot_prefix, "/usr/include"), |
| 333 | + _join(sysroot_prefix, "/usr/local/include"), |
327 | 334 | ])
|
328 | 335 | elif target_os == "darwin":
|
329 | 336 | cxx_builtin_include_directories.extend([
|
330 |
| - sysroot_prefix + "/usr/include", |
331 |
| - sysroot_prefix + "/System/Library/Frameworks", |
| 337 | + _join(sysroot_prefix, "/usr/include"), |
| 338 | + _join(sysroot_prefix, "/System/Library/Frameworks"), |
332 | 339 | ])
|
333 | 340 | else:
|
334 | 341 | fail("Unreachable")
|
|
0 commit comments