|
| 1 | +diff --git b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel |
| 2 | +--- b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel |
| 3 | ++++ a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel |
| 4 | +@@ -1,8 +1,9 @@ |
| 5 | + # This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
| 6 | + # See https://llvm.org/LICENSE.txt for license information. |
| 7 | + # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 8 | + |
| 9 | ++load("//:workspace_root.bzl", "workspace_root") |
| 10 | + load("//llvm:tblgen.bzl", "gentbl") |
| 11 | + load("//llvm:binary_alias.bzl", "binary_alias") |
| 12 | + load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") |
| 13 | + load("//llvm:config.bzl", "llvm_stdcxx_copts") |
| 14 | +@@ -684,8 +685,10 @@ gentbl( |
| 15 | + td_srcs = [ |
| 16 | + "include/clang/Basic/ASTNode.td", |
| 17 | + "include/clang/Basic/TypeNodes.td", |
| 18 | + ], |
| 19 | + ) |
| 20 | ++ |
| 21 | ++workspace_root(name = "workspace_root") |
| 22 | + |
| 23 | + cc_library( |
| 24 | + name = "ast", |
| 25 | +@@ -711,8 +714,8 @@ cc_library( |
| 26 | + # least bad approach. Using `includes` is *specifically* problematic for |
| 27 | + # this library because it contains files that collide easily with system |
| 28 | + # headers such as `CXXABI.h`. |
| 29 | +- "-I$(GENDIR)/external/llvm-project/clang/lib/AST", |
| 30 | +- "-I$(GENDIR)/external/llvm-project/clang/lib/AST/Interp", |
| 31 | ++ "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST", |
| 32 | ++ "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST/Interp", |
| 33 | + ] + llvm_stdcxx_copts, |
| 34 | + textual_hdrs = [ |
| 35 | + "include/clang/AST/AttrImpl.inc", |
| 36 | +@@ -730,8 +733,11 @@ cc_library |
| 37 | + "include/clang/AST/StmtDataCollectors.inc", |
| 38 | + "include/clang/AST/StmtNodes.inc", |
| 39 | + ] + glob([ |
| 40 | + "include/clang/AST/*.def", |
| 41 | + ], allow_empty = True), |
| 42 | ++ toolchains = [ |
| 43 | ++ ":workspace_root", |
| 44 | ++ ], |
| 45 | + deps = [ |
| 46 | + ":ast_attr_gen", |
| 47 | + ":ast_comment_command_info_gen", |
| 48 | + |
| 49 | +--- /dev/null |
| 50 | ++++ a/utils/bazel/llvm-project-overlay/workspace_root.bzl |
| 51 | +@@ -0,0 +1,17 @@ |
| 52 | ++def _workspace_root_impl(ctx): |
| 53 | ++ """Dynamically determine the workspace root from the current context. |
| 54 | ++ |
| 55 | ++ The path is made available as a `WORKSPACE_ROOT` environmment variable and |
| 56 | ++ may for instance be consumed in the `toolchains` attributes for `cc_library` |
| 57 | ++ and `genrule` targets. |
| 58 | ++ """ |
| 59 | ++ return [ |
| 60 | ++ platform_common.TemplateVariableInfo({ |
| 61 | ++ "WORKSPACE_ROOT": ctx.label.workspace_root, |
| 62 | ++ }), |
| 63 | ++ ] |
| 64 | ++ |
| 65 | ++workspace_root = rule( |
| 66 | ++ implementation = _workspace_root_impl, |
| 67 | ++ attrs = {}, |
| 68 | ++) |
0 commit comments