]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | # Copyright 2017 Google Inc. |
2 | # All Rights Reserved. | |
3 | # | |
4 | # | |
5 | # Redistribution and use in source and binary forms, with or without | |
6 | # modification, are permitted provided that the following conditions are | |
7 | # met: | |
8 | # | |
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 | |
14 | # distribution. | |
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. | |
18 | # | |
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. | |
30 | # | |
31 | # Bazel Build for Google C++ Testing Framework(Google Test) | |
32 | ||
33 | load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") | |
34 | ||
35 | package(default_visibility = ["//visibility:public"]) | |
36 | ||
37 | licenses(["notice"]) | |
38 | ||
f67539c2 TL |
39 | exports_files(["LICENSE"]) |
40 | ||
9f95a23c TL |
41 | config_setting( |
42 | name = "windows", | |
43 | constraint_values = ["@bazel_tools//platforms:windows"], | |
44 | ) | |
45 | ||
46 | config_setting( | |
47 | name = "has_absl", | |
48 | values = {"define": "absl=1"}, | |
49 | ) | |
50 | ||
51 | # Library that defines the FRIEND_TEST macro. | |
52 | cc_library( | |
53 | name = "gtest_prod", | |
54 | hdrs = ["googletest/include/gtest/gtest_prod.h"], | |
55 | includes = ["googletest/include"], | |
56 | ) | |
57 | ||
58 | # Google Test including Google Mock | |
59 | cc_library( | |
60 | name = "gtest", | |
61 | srcs = glob( | |
62 | include = [ | |
63 | "googletest/src/*.cc", | |
64 | "googletest/src/*.h", | |
65 | "googletest/include/gtest/**/*.h", | |
66 | "googlemock/src/*.cc", | |
67 | "googlemock/include/gmock/**/*.h", | |
68 | ], | |
69 | exclude = [ | |
70 | "googletest/src/gtest-all.cc", | |
71 | "googletest/src/gtest_main.cc", | |
72 | "googlemock/src/gmock-all.cc", | |
73 | "googlemock/src/gmock_main.cc", | |
74 | ], | |
75 | ), | |
76 | hdrs = glob([ | |
77 | "googletest/include/gtest/*.h", | |
78 | "googlemock/include/gmock/*.h", | |
79 | ]), | |
80 | copts = select({ | |
81 | ":windows": [], | |
82 | "//conditions:default": ["-pthread"], | |
83 | }), | |
84 | defines = select({ | |
85 | ":has_absl": ["GTEST_HAS_ABSL=1"], | |
86 | "//conditions:default": [], | |
87 | }), | |
88 | features = select({ | |
89 | ":windows": ["windows_export_all_symbols"], | |
90 | "//conditions:default": [], | |
91 | }), | |
92 | includes = [ | |
93 | "googlemock", | |
94 | "googlemock/include", | |
95 | "googletest", | |
96 | "googletest/include", | |
97 | ], | |
98 | linkopts = select({ | |
99 | ":windows": [], | |
100 | "//conditions:default": ["-pthread"], | |
101 | }), | |
102 | deps = select({ | |
103 | ":has_absl": [ | |
104 | "@com_google_absl//absl/debugging:failure_signal_handler", | |
105 | "@com_google_absl//absl/debugging:stacktrace", | |
106 | "@com_google_absl//absl/debugging:symbolize", | |
107 | "@com_google_absl//absl/strings", | |
f67539c2 | 108 | "@com_google_absl//absl/types:any", |
9f95a23c TL |
109 | "@com_google_absl//absl/types:optional", |
110 | "@com_google_absl//absl/types:variant", | |
111 | ], | |
112 | "//conditions:default": [], | |
113 | }), | |
114 | ) | |
115 | ||
116 | cc_library( | |
117 | name = "gtest_main", | |
118 | srcs = ["googlemock/src/gmock_main.cc"], | |
119 | features = select({ | |
120 | ":windows": ["windows_export_all_symbols"], | |
121 | "//conditions:default": [], | |
122 | }), | |
123 | deps = [":gtest"], | |
124 | ) | |
125 | ||
126 | # The following rules build samples of how to use gTest. | |
127 | cc_library( | |
128 | name = "gtest_sample_lib", | |
129 | srcs = [ | |
130 | "googletest/samples/sample1.cc", | |
131 | "googletest/samples/sample2.cc", | |
132 | "googletest/samples/sample4.cc", | |
133 | ], | |
134 | hdrs = [ | |
135 | "googletest/samples/prime_tables.h", | |
136 | "googletest/samples/sample1.h", | |
137 | "googletest/samples/sample2.h", | |
138 | "googletest/samples/sample3-inl.h", | |
139 | "googletest/samples/sample4.h", | |
140 | ], | |
141 | features = select({ | |
142 | ":windows": ["windows_export_all_symbols"], | |
143 | "//conditions:default": [], | |
144 | }), | |
145 | ) | |
146 | ||
147 | cc_test( | |
148 | name = "gtest_samples", | |
149 | size = "small", | |
150 | # All Samples except: | |
151 | # sample9 (main) | |
152 | # sample10 (main and takes a command line option and needs to be separate) | |
153 | srcs = [ | |
154 | "googletest/samples/sample1_unittest.cc", | |
155 | "googletest/samples/sample2_unittest.cc", | |
156 | "googletest/samples/sample3_unittest.cc", | |
157 | "googletest/samples/sample4_unittest.cc", | |
158 | "googletest/samples/sample5_unittest.cc", | |
159 | "googletest/samples/sample6_unittest.cc", | |
160 | "googletest/samples/sample7_unittest.cc", | |
161 | "googletest/samples/sample8_unittest.cc", | |
162 | ], | |
163 | linkstatic = 0, | |
164 | deps = [ | |
165 | "gtest_sample_lib", | |
166 | ":gtest_main", | |
167 | ], | |
168 | ) | |
169 | ||
170 | cc_test( | |
171 | name = "sample9_unittest", | |
172 | size = "small", | |
173 | srcs = ["googletest/samples/sample9_unittest.cc"], | |
174 | deps = [":gtest"], | |
175 | ) | |
176 | ||
177 | cc_test( | |
178 | name = "sample10_unittest", | |
179 | size = "small", | |
180 | srcs = ["googletest/samples/sample10_unittest.cc"], | |
181 | deps = [":gtest"], | |
182 | ) |