]>
Commit | Line | Data |
---|---|---|
1e59de90 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 | # Author: misterg@google.com (Gennadiy Civil) | |
32 | # | |
33 | # Bazel Build for Google C++ Testing Framework(Google Test) | |
34 | ||
35 | package(default_visibility = ["//visibility:public"]) | |
36 | ||
37 | licenses(["notice"]) | |
38 | ||
39 | config_setting( | |
40 | name = "windows", | |
41 | values = { "cpu": "x64_windows" }, | |
42 | ) | |
43 | ||
44 | config_setting( | |
45 | name = "windows_msvc", | |
46 | values = {"cpu": "x64_windows_msvc"}, | |
47 | ) | |
48 | ||
49 | config_setting( | |
50 | name = "has_absl", | |
51 | values = {"define": "absl=1"}, | |
52 | ) | |
53 | ||
54 | ||
55 | # Google Test including Google Mock | |
56 | cc_library( | |
57 | name = "gtest", | |
58 | srcs = glob( | |
59 | include = [ | |
60 | "googletest/src/*.cc", | |
61 | "googletest/src/*.h", | |
62 | "googletest/include/gtest/**/*.h", | |
63 | "googlemock/src/*.cc", | |
64 | "googlemock/include/gmock/**/*.h", | |
65 | ], | |
66 | exclude = [ | |
67 | "googletest/src/gtest-all.cc", | |
68 | "googletest/src/gtest_main.cc", | |
69 | "googlemock/src/gmock-all.cc", | |
70 | "googlemock/src/gmock_main.cc", | |
71 | ], | |
72 | ), | |
73 | hdrs =glob([ | |
74 | "googletest/include/gtest/*.h", | |
75 | "googlemock/include/gmock/*.h", | |
76 | ]), | |
77 | copts = select( | |
78 | { | |
79 | ":windows": [], | |
80 | ":windows_msvc": [], | |
81 | "//conditions:default": ["-pthread"], | |
82 | }, | |
83 | ), | |
84 | includes = [ | |
85 | "googlemock", | |
86 | "googlemock/include", | |
87 | "googletest", | |
88 | "googletest/include", | |
89 | ], | |
90 | linkopts = select({ | |
91 | ":windows": [], | |
92 | ":windows_msvc": [], | |
93 | "//conditions:default": [ | |
94 | "-pthread", | |
95 | ], | |
96 | }), | |
97 | defines = select ({ | |
98 | ":has_absl": [ | |
99 | "GTEST_HAS_ABSL=1", | |
100 | ], | |
101 | "//conditions:default": [], | |
102 | } | |
103 | ), | |
104 | deps = select ({ | |
105 | ":has_absl": [ | |
106 | "@com_google_absl//absl/types:optional", | |
107 | "@com_google_absl//absl/strings" | |
108 | ], | |
109 | "//conditions:default": [], | |
110 | } | |
111 | ) | |
112 | ) | |
113 | ||
114 | cc_library( | |
115 | name = "gtest_main", | |
116 | srcs = [ | |
117 | "googlemock/src/gmock_main.cc", | |
118 | ], | |
119 | deps = [":gtest"], | |
120 | ) | |
121 | ||
122 | # The following rules build samples of how to use gTest. | |
123 | cc_library( | |
124 | name = "gtest_sample_lib", | |
125 | srcs = [ | |
126 | "googletest/samples/sample1.cc", | |
127 | "googletest/samples/sample2.cc", | |
128 | "googletest/samples/sample4.cc", | |
129 | ], | |
130 | hdrs = [ | |
131 | "googletest/samples/prime_tables.h", | |
132 | "googletest/samples/sample1.h", | |
133 | "googletest/samples/sample2.h", | |
134 | "googletest/samples/sample3-inl.h", | |
135 | "googletest/samples/sample4.h", | |
136 | ], | |
137 | ) | |
138 | ||
139 | cc_test( | |
140 | name = "gtest_samples", | |
141 | size = "small", | |
142 | #All Samples except: | |
143 | #sample9 ( main ) | |
144 | #sample10 (main and takes a command line option and needs to be separate) | |
145 | srcs = [ | |
146 | "googletest/samples/sample1_unittest.cc", | |
147 | "googletest/samples/sample2_unittest.cc", | |
148 | "googletest/samples/sample3_unittest.cc", | |
149 | "googletest/samples/sample4_unittest.cc", | |
150 | "googletest/samples/sample5_unittest.cc", | |
151 | "googletest/samples/sample6_unittest.cc", | |
152 | "googletest/samples/sample7_unittest.cc", | |
153 | "googletest/samples/sample8_unittest.cc", | |
154 | ], | |
155 | deps = [ | |
156 | "gtest_sample_lib", | |
157 | ":gtest_main", | |
158 | ], | |
159 | ) | |
160 | ||
161 | cc_test( | |
162 | name = "sample9_unittest", | |
163 | size = "small", | |
164 | srcs = ["googletest/samples/sample9_unittest.cc"], | |
165 | deps = [":gtest"], | |
166 | ) | |
167 | ||
168 | cc_test( | |
169 | name = "sample10_unittest", | |
170 | size = "small", | |
171 | srcs = ["googletest/samples/sample10_unittest.cc"], | |
172 | deps = [ | |
173 | ":gtest", | |
174 | ], | |
175 | ) |