mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 09:26:07 +00:00

This required substantially more invasive changes. We need to handle some of the LLVM `config.h` changes differently from the old pattern. These aren't always safe on the commandline, and the Windows ones specifically break Clang. Instead, use conditional defines in the header itself. This more closely matches how CMake builds see the definitions. I think this is also just cleaner and we should maybe move more of the macros out of Bazel. The config defines for Windows that I've kept in Bazel are the ones that LLVM's CMake does at the commandline as well. I've also added numerous ones that CMake uses and we didn't replicate in Bazel. I also needed a different approach to get `libclang` working well. This, IMO, improves things on all platforms. Now we build the plugin and actually wrap it back up with `cc_import`. We have to use a collection of manually tagged `cc_binary` rules to get the naming to work out the right way, but this isn't too different from the prior approach. By directly having a `cc_binary` rule for each platform spelling of `libclang`, we can actually extract the interface library from it and correctly depend on it with `cc_import`. I think the result now is much closer to the intent and to the CMake build for libclang. Sadly, some tests also needed disabling. This is actually narrower than what CMake does. The issue isn't indicative of anything serious -- the test just assumes Unix-style paths. I also have cleaned up the Windows flags in `.bazelrc` to much more closely match what CMake does. Differential Revision: https://reviews.llvm.org/D112399
498 lines
11 KiB
Python
498 lines
11 KiB
Python
# 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
|
|
|
|
package(
|
|
default_visibility = ["//visibility:public"],
|
|
licenses = ["notice"],
|
|
)
|
|
|
|
cc_test(
|
|
name = "ast_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
[
|
|
"AST/*.cpp",
|
|
"AST/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
shard_count = 20,
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:ast_matchers",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:testing",
|
|
"//clang:tooling",
|
|
"//llvm:Core",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "ast_matchers_tests_hdrs",
|
|
testonly = 1,
|
|
hdrs = glob(
|
|
["ASTMatchers/*.h"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:ast_matchers",
|
|
"//clang:frontend",
|
|
"//clang:testing",
|
|
"//clang:tooling",
|
|
"//llvm:gtest",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "ast_matchers_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
["ASTMatchers/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
shard_count = 20,
|
|
deps = [
|
|
":ast_matchers_tests_hdrs",
|
|
"//clang:ast",
|
|
"//clang:ast_matchers",
|
|
"//clang:frontend",
|
|
"//clang:tooling",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "ast_matchers_dynamic_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["ASTMatchers/Dynamic/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
":ast_matchers_tests_hdrs",
|
|
"//clang:ast_matchers",
|
|
"//clang:ast_matchers_dynamic",
|
|
"//clang:frontend",
|
|
"//clang:tooling",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "analysis_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
[
|
|
"Analysis/*.cpp",
|
|
"Analysis/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:analysis",
|
|
"//clang:ast",
|
|
"//clang:ast_matchers",
|
|
"//clang:basic",
|
|
"//clang:lex",
|
|
"//clang:parse",
|
|
"//clang:tooling",
|
|
"//llvm:Support",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "basic_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["Basic/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:config",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "codegen_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
[
|
|
"CodeGen/*.cpp",
|
|
"CodeGen/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:codegen",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:parse",
|
|
"//clang:sema",
|
|
"//llvm:Core",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "format_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
[
|
|
"Format/*.cpp",
|
|
"Format/*.h",
|
|
"Tooling/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
copts = ["$(STACK_FRAME_UNLIMITED)"],
|
|
shard_count = 20,
|
|
deps = [
|
|
"//clang:basic",
|
|
"//clang:format",
|
|
"//clang:frontend",
|
|
"//clang:tooling_core",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "frontend_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["Frontend/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:codegen",
|
|
"//clang:driver_options_inc_gen",
|
|
"//clang:frontend",
|
|
"//clang:frontend_tool",
|
|
"//clang:lex",
|
|
"//clang:sema",
|
|
"//clang:serialization",
|
|
"//llvm:Support",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "lex_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
[
|
|
"Lex/*.cpp",
|
|
"Lex/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
copts = ["$(STACK_FRAME_UNLIMITED)"],
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:lex",
|
|
"//clang:parse",
|
|
"//clang:sema",
|
|
"//clang:serialization",
|
|
"//llvm:Support",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
# A library to carefully expose the tooling headers using the include prefix
|
|
# expected by the `rename_tests`.
|
|
cc_library(
|
|
name = "rename_tests_tooling_hdrs",
|
|
testonly = 1,
|
|
hdrs = glob(
|
|
["Tooling/*.h"],
|
|
allow_empty = False,
|
|
),
|
|
include_prefix = "unittests",
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:rewrite",
|
|
"//clang:tooling",
|
|
"//clang:tooling_core",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "rename_tests",
|
|
size = "small",
|
|
timeout = "moderate",
|
|
srcs = glob(
|
|
[
|
|
"Rename/*.cpp",
|
|
"Rename/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
shard_count = 20,
|
|
deps = [
|
|
":rename_tests_tooling_hdrs",
|
|
"//clang:ast_matchers",
|
|
"//clang:basic",
|
|
"//clang:format",
|
|
"//clang:frontend",
|
|
"//clang:tooling",
|
|
"//clang:tooling_refactoring",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "rewrite_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["Rewrite/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:rewrite",
|
|
"//clang:tooling",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "sema_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["Sema/*.cpp"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
":ast_matchers_tests_hdrs",
|
|
"//clang:ast",
|
|
"//clang:ast_matchers",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:parse",
|
|
"//clang:sema",
|
|
"//clang:tooling",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "static_analyzer_test_headers",
|
|
testonly = 1,
|
|
hdrs = glob(
|
|
["StaticAnalyzer/*.h"],
|
|
allow_empty = False,
|
|
),
|
|
deps = [
|
|
"//clang:ast_matchers",
|
|
"//clang:crosstu",
|
|
"//clang:frontend",
|
|
"//clang:static_analyzer_core",
|
|
"//clang:static_analyzer_frontend",
|
|
"//clang:tooling",
|
|
"//llvm:gtest",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "static_analyzer_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["StaticAnalyzer/*.cpp"],
|
|
allow_empty = False,
|
|
exclude = [
|
|
# New test has unused-variable warnings.
|
|
"StaticAnalyzer/ParamRegionTest.cpp",
|
|
],
|
|
),
|
|
deps = [
|
|
":static_analyzer_test_headers",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:static_analyzer_core",
|
|
"//clang:static_analyzer_frontend",
|
|
"//clang:tooling",
|
|
"//llvm:Support",
|
|
"//llvm:config",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "tooling_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
[
|
|
"Tooling/*.cpp",
|
|
"Tooling/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
shard_count = 20,
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:ast_matchers",
|
|
"//clang:basic",
|
|
"//clang:format",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:rewrite",
|
|
"//clang:tooling",
|
|
"//clang:tooling_core",
|
|
"//clang:tooling_dependency_scanning",
|
|
"//clang:tooling_inclusions",
|
|
"//clang:tooling_refactoring",
|
|
"//clang:transformer",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
# A library to carefully expose the tooling headers using the include prefix
|
|
# expected by the `tooling_recursive_ast_visitor_tests`.
|
|
cc_library(
|
|
name = "tooling_recursive_ast_visitor_tests_tooling_hdrs",
|
|
testonly = 1,
|
|
hdrs = glob(
|
|
["Tooling/*.h"],
|
|
allow_empty = False,
|
|
),
|
|
strip_include_prefix = "Tooling",
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:rewrite",
|
|
"//clang:tooling",
|
|
"//clang:tooling_core",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "tooling_recursive_ast_visitor_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
["Tooling/RecursiveASTVisitorTests/*.cpp"],
|
|
allow_empty = False,
|
|
) + [
|
|
"Tooling/RecursiveASTVisitorTests/CallbacksCommon.h",
|
|
],
|
|
deps = [
|
|
":tooling_recursive_ast_visitor_tests_tooling_hdrs",
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:tooling",
|
|
"//clang:tooling_syntax",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "tooling_syntax_tests",
|
|
size = "medium",
|
|
srcs = glob(
|
|
[
|
|
"Tooling/Syntax/*.cpp",
|
|
"Tooling/Syntax/*.h",
|
|
],
|
|
allow_empty = False,
|
|
),
|
|
shard_count = 20,
|
|
deps = [
|
|
"//clang:ast",
|
|
"//clang:basic",
|
|
"//clang:frontend",
|
|
"//clang:lex",
|
|
"//clang:testing",
|
|
"//clang:tooling",
|
|
"//clang:tooling_core",
|
|
"//clang:tooling_syntax",
|
|
"//llvm:Support",
|
|
"//llvm:TestingSupport",
|
|
"//llvm:gmock",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "libclang_tests",
|
|
size = "small",
|
|
srcs = glob(
|
|
["libclang/*.cpp"],
|
|
allow_empty = False,
|
|
) + [
|
|
"libclang/TestUtils.h",
|
|
],
|
|
args = select({
|
|
"@bazel_tools//src/conditions:windows": [
|
|
# Need to disable the VFS tests that don't use Windows friendly
|
|
# paths. These are also disabled on Windows in the CMake build.
|
|
"--gtest_filter=-*VirtualFileOverlay*",
|
|
],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = [
|
|
"//clang:libclang",
|
|
"//llvm:Support",
|
|
"//llvm:gtest",
|
|
"//llvm:gtest_main",
|
|
],
|
|
)
|