1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
6 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
7 load("//llvm:lit_test.bzl", "lit_test", "package_path")
10 default_visibility = ["//visibility:public"],
11 features = ["layering_check"],
17 name = "include_cleaner",
22 hdrs = glob(["include/clang-include-cleaner/*.h"]),
23 includes = ["include/"],
30 "//clang:tooling_core",
31 "//clang:tooling_inclusions",
37 name = "include_cleaner_internal",
38 hdrs = glob(["lib/*.h"]),
40 visibility = [":__subpackages__"],
47 "//clang:tooling_inclusions",
53 name = "clang-include-cleaner",
59 ":include_cleaner_internal",
69 srcs = glob(["unittests/*.cpp"]),
72 ":include_cleaner_internal",
78 "//clang:serialization",
81 "//clang:tooling_inclusions",
83 "//llvm:TestingAnnotations",
84 "//third-party/unittest:gmock",
85 "//third-party/unittest:gtest",
89 LLVM_LIT_PATH_FUNCTION = " " + \
90 "# Allow generated file to be relocatable.\n" + \
91 "from pathlib import Path\n" + \
94 " if p.exists: return str(p.resolve())\n" + \
95 " if not p: return ''\n" + \
96 " return str((Path(__file__).parent / p).resolve())\n"
98 LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit." + LLVM_LIT_PATH_FUNCTION
101 name = "lit_site_cfg_py",
103 out = "test/lit.site.cfg.py",
105 "@CMAKE_CURRENT_BINARY_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
106 "@CMAKE_CURRENT_SOURCE_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
107 "@CURRENT_TOOLS_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD"),
108 "@LIT_SITE_CFG_IN_HEADER@": LIT_SITE_CFG_IN_HEADER,
109 "@LLVM_LIBS_DIR@": package_path("//llvm:BUILD"),
110 "@LLVM_LIT_TOOLS_DIR@": package_path("//llvm:BUILD"),
111 "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
112 "@TARGET_TRIPLE@": "",
113 '"@Python3_EXECUTABLE@"': "sys.executable",
115 template = "test/lit.site.cfg.py.in",
120 name = "%s.test" % src,
122 data = glob(["test/Inputs/**/*"]) + [
124 "test/lit.site.cfg.py",
125 ":clang-include-cleaner",
132 for src in glob(["test/*.cpp"])