diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel copy from utils/bazel/llvm-project-overlay/clang/BUILD.bazel copy to utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/BUILD.bazel @@ -3,10 +3,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load("//:workspace_root.bzl", "workspace_root") -load("//llvm:tblgen.bzl", "gentbl") -load("//llvm:binary_alias.bzl", "binary_alias") -load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") +load("@rules_python//python:defs.bzl", "py_binary") load( "//:vars.bzl", "LLVM_VERSION", @@ -14,6 +12,11 @@ "LLVM_VERSION_MINOR", "LLVM_VERSION_PATCH", ) +load("//:workspace_root.bzl", "workspace_root") +load("//llvm:binary_alias.bzl", "binary_alias") +load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") +load("//llvm:tblgen.bzl", "gentbl") +load("defs.bzl", "BUILTIN_HEADERS_GEN_DIR") package( default_visibility = ["//visibility:public"], @@ -1688,14 +1691,17 @@ genrule( name = "builtin_headers_gen", srcs = builtin_headers, - outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in builtin_headers], + outs = [ + hdr.replace("lib/Headers/", BUILTIN_HEADERS_GEN_DIR) + for hdr in builtin_headers + ], cmd = """ for src in $(SRCS); do - relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers} - target=$(@D)/staging/include/$$relsrc + relsrc=$${{src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}} + target=$(@D)/{gen_dir}$$relsrc mkdir -p $$(dirname $$target) cp $$src $$target - done""", + done""".format(gen_dir = BUILTIN_HEADERS_GEN_DIR), output_to_bindir = 1, toolchains = [ ":workspace_root", diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel @@ -369,6 +369,7 @@ cc_binary( name = "clang-tidy", srcs = ["tool/ClangTidyToolMain.cpp"], + data = ["//clang-tools-extra:builtin_headers"], stamp = 0, deps = [":tool"], ) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl b/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/defs.bzl @@ -0,0 +1,5 @@ +# This file is licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +BUILTIN_HEADERS_GEN_DIR = "staging/include/" diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -3,10 +3,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load("//:workspace_root.bzl", "workspace_root") -load("//llvm:tblgen.bzl", "gentbl") -load("//llvm:binary_alias.bzl", "binary_alias") -load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") +load("@rules_python//python:defs.bzl", "py_binary") load( "//:vars.bzl", "LLVM_VERSION", @@ -14,6 +12,11 @@ "LLVM_VERSION_MINOR", "LLVM_VERSION_PATCH", ) +load("//:workspace_root.bzl", "workspace_root") +load("//llvm:binary_alias.bzl", "binary_alias") +load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") +load("//llvm:tblgen.bzl", "gentbl") +load("defs.bzl", "BUILTIN_HEADERS_GEN_DIR") package( default_visibility = ["//visibility:public"], @@ -1688,14 +1691,17 @@ genrule( name = "builtin_headers_gen", srcs = builtin_headers, - outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in builtin_headers], + outs = [ + hdr.replace("lib/Headers/", BUILTIN_HEADERS_GEN_DIR) + for hdr in builtin_headers + ], cmd = """ for src in $(SRCS); do - relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers} - target=$(@D)/staging/include/$$relsrc + relsrc=$${{src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}} + target=$(@D)/{gen_dir}$$relsrc mkdir -p $$(dirname $$target) cp $$src $$target - done""", + done""".format(gen_dir = BUILTIN_HEADERS_GEN_DIR), output_to_bindir = 1, toolchains = [ ":workspace_root", diff --git a/utils/bazel/llvm-project-overlay/clang/defs.bzl b/utils/bazel/llvm-project-overlay/clang/defs.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/clang/defs.bzl @@ -0,0 +1,5 @@ +# This file is licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +BUILTIN_HEADERS_GEN_DIR = "staging/include/"