1 # Copyright 2017 Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 # Bazel Build for Google C++ Testing Framework(Google Test)
33 load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
35 package(default_visibility = ["//visibility:public"])
39 exports_files(["LICENSE"])
43 constraint_values = ["@platforms//os:windows"],
47 name = "msvc_compiler",
49 "@bazel_tools//tools/cpp:compiler": "msvc-cl",
51 visibility = [":__subpackages__"],
56 values = {"define": "absl=1"},
59 # Library that defines the FRIEND_TEST macro.
62 hdrs = ["googletest/include/gtest/gtest_prod.h"],
63 includes = ["googletest/include"],
66 # Google Test including Google Mock
71 "googletest/src/*.cc",
73 "googletest/include/gtest/**/*.h",
74 "googlemock/src/*.cc",
75 "googlemock/include/gmock/**/*.h",
78 "googletest/src/gtest-all.cc",
79 "googletest/src/gtest_main.cc",
80 "googlemock/src/gmock-all.cc",
81 "googlemock/src/gmock_main.cc",
85 "googletest/include/gtest/*.h",
86 "googlemock/include/gmock/*.h",
90 "//conditions:default": ["-pthread"],
93 ":has_absl": ["GTEST_HAS_ABSL=1"],
94 "//conditions:default": [],
97 ":windows": ["windows_export_all_symbols"],
98 "//conditions:default": [],
102 "googlemock/include",
104 "googletest/include",
108 "//conditions:default": ["-pthread"],
112 "@com_google_absl//absl/debugging:failure_signal_handler",
113 "@com_google_absl//absl/debugging:stacktrace",
114 "@com_google_absl//absl/debugging:symbolize",
115 "@com_google_absl//absl/strings",
116 "@com_google_absl//absl/types:any",
117 "@com_google_absl//absl/types:optional",
118 "@com_google_absl//absl/types:variant",
120 "//conditions:default": [],
126 srcs = ["googlemock/src/gmock_main.cc"],
128 ":windows": ["windows_export_all_symbols"],
129 "//conditions:default": [],
134 # The following rules build samples of how to use gTest.
136 name = "gtest_sample_lib",
138 "googletest/samples/sample1.cc",
139 "googletest/samples/sample2.cc",
140 "googletest/samples/sample4.cc",
143 "googletest/samples/prime_tables.h",
144 "googletest/samples/sample1.h",
145 "googletest/samples/sample2.h",
146 "googletest/samples/sample3-inl.h",
147 "googletest/samples/sample4.h",
150 ":windows": ["windows_export_all_symbols"],
151 "//conditions:default": [],
156 name = "gtest_samples",
158 # All Samples except:
160 # sample10 (main and takes a command line option and needs to be separate)
162 "googletest/samples/sample1_unittest.cc",
163 "googletest/samples/sample2_unittest.cc",
164 "googletest/samples/sample3_unittest.cc",
165 "googletest/samples/sample4_unittest.cc",
166 "googletest/samples/sample5_unittest.cc",
167 "googletest/samples/sample6_unittest.cc",
168 "googletest/samples/sample7_unittest.cc",
169 "googletest/samples/sample8_unittest.cc",
179 name = "sample9_unittest",
181 srcs = ["googletest/samples/sample9_unittest.cc"],
186 name = "sample10_unittest",
188 srcs = ["googletest/samples/sample10_unittest.cc"],