Debian Codegraph @

llvm-project/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel

raw
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
4
5 package(default_visibility = ["//visibility:public"])
6
7 licenses(["notice"])
8
9 exports_files(["LICENSE.TXT"])
10
11 # It may be tempting to add compiler flags here, but that should be avoided.
12 # The necessary warnings and other compile flags should be provided by the
13 # toolchain or the `.bazelrc` file. This is just a workaround until we have a
14 # widely available feature to enable unlimited stack frame instead of using
15 # this `Make` variable.
16 llvm_copts = [
17 "$(STACK_FRAME_UNLIMITED)",
18 ]
19
20 # A hacky library to expose some internal headers of gtest to its own
21 # implementation source files using a stripped include prefix rather than
22 # file-relative-inclusion.
23 #
24 # FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but
25 # unfortunately that doesn't work with `strip_include_prefix`:
26 # https://github.com/bazelbuild/bazel/issues/12424
27 #
28 # For now, simply disable parsing and header modules.
29 cc_library(
30 name = "gtest_internal_headers",
31 testonly = True,
32 hdrs = ["googletest/src/gtest-internal-inl.h"],
33 features = [
34 "-parse_headers",
35 "-header_modules",
36 ],
37 strip_include_prefix = "googletest",
38 )
39
40 cc_library(
41 name = "gtest",
42 testonly = True,
43 srcs = glob(
44 [
45 "googletest/include/**/*.h",
46 "googletest/src/*.cc",
47 ],
48 exclude = [
49 "googletest/src/gtest-all.cc",
50 "googletest/include/gtest/gtest_pred_impl.h",
51 ],
52 ) + [
53 ],
54 hdrs = ["googletest/include/gtest/gtest.h", "googletest/include/gtest/gtest-spi.h"],
55 copts = llvm_copts,
56 defines = [
57 "GTEST_HAS_RTTI=0",
58 "__STDC_LIMIT_MACROS",
59 "__STDC_CONSTANT_MACROS",
60 ] + select({
61 "@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"],
62 "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"],
63 }),
64 includes = [
65 "googletest/include",
66 "include",
67 ],
68 textual_hdrs = [
69 "googletest/include/gtest/gtest_pred_impl.h",
70 ],
71 deps = [
72 ":gtest_internal_headers",
73 "//llvm:Support",
74 ],
75 )
76
77 cc_library(
78 name = "gtest_main",
79 testonly = True,
80 srcs = ["UnitTestMain/TestMain.cpp"],
81 copts = llvm_copts,
82 deps = [
83 ":gmock",
84 ":gtest",
85 "//llvm:Support",
86 ],
87 )
88
89 cc_library(
90 name = "gmock",
91 testonly = True,
92 srcs = glob(
93 [
94 "googlemock/include/**/*.h",
95 "googlemock/src/*.cc",
96 ],
97 exclude = ["googlemock/src/gmock-all.cc"],
98 ),
99 hdrs = [
100 "googlemock/include/gmock/gmock.h",
101 "googlemock/include/gmock/gmock-matchers.h",
102 ],
103 copts = llvm_copts,
104 includes = [
105 "googlemock/include",
106 "include",
107 ],
108 deps = [":gtest"],
109 )