Debian Codegraph @

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 = [
55 "googletest/include/gtest/gtest.h",
56 "googletest/include/gtest/gtest-spi.h",
57 "googletest/include/gtest/internal/gtest-port.h",
58 ],
59 copts = llvm_copts,
60 defines = [
61 "GTEST_HAS_RTTI=0",
62 "__STDC_LIMIT_MACROS",
63 "__STDC_CONSTANT_MACROS",
64 ] + select({
65 "@platforms//os:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"],
66 "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"],
67 }),
68 includes = [
69 "googletest/include",
70 "include",
71 ],
72 textual_hdrs = [
73 "googletest/include/gtest/gtest_pred_impl.h",
74 ],
75 deps = [
76 ":gtest_internal_headers",
77 "//llvm:Support",
78 ],
79 )
80
81 cc_library(
82 name = "gtest_main",
83 testonly = True,
84 srcs = ["UnitTestMain/TestMain.cpp"],
85 copts = llvm_copts,
86 deps = [
87 ":gmock",
88 ":gtest",
89 "//llvm:Support",
90 ],
91 )
92
93 cc_library(
94 name = "gmock",
95 testonly = True,
96 srcs = glob(
97 [
98 "googlemock/include/**/*.h",
99 "googlemock/src/*.cc",
100 ],
101 exclude = ["googlemock/src/gmock-all.cc"],
102 ),
103 hdrs = [
104 "googlemock/include/gmock/gmock.h",
105 "googlemock/include/gmock/gmock-matchers.h",
106 ],
107 copts = llvm_copts,
108 includes = [
109 "googlemock/include",
110 "include",
111 ],
112 deps = [":gtest"],
113 )