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