mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 23:16:35 +00:00

The `clang:ast` and `clang:builtin_headers_gen` targets currently use hardcoded `external/llvm-project` paths to access generated headers. With bzlmod this path becomes dependent on the module name, module version and module extension, so we need a more dynamic approach. Does not affect the WORKSPACE build. Reviewed By: GMNGeoffrey, #bazel_build Differential Revision: https://reviews.llvm.org/D137007
18 lines
520 B
Python
18 lines
520 B
Python
def _workspace_root_impl(ctx):
|
|
"""Dynamically determine the workspace root from the current context.
|
|
|
|
The path is made available as a `WORKSPACE_ROOT` environmment variable and
|
|
may for instance be consumed in the `toolchains` attributes for `cc_library`
|
|
and `genrule` targets.
|
|
"""
|
|
return [
|
|
platform_common.TemplateVariableInfo({
|
|
"WORKSPACE_ROOT": ctx.label.workspace_root,
|
|
}),
|
|
]
|
|
|
|
workspace_root = rule(
|
|
implementation = _workspace_root_impl,
|
|
attrs = {},
|
|
)
|