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