blob: a44237409e2fb71aabf8265de8042ba845a19ad3 [file] [log] [blame]
mistergcb5b0542017-08-10 12:03:27 -04001# 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#
misterg88150872017-08-08 15:17:56 -040031# Author: misterg@google.com (Gennadiy Civil)
32#
mistergcb5b0542017-08-10 12:03:27 -040033# Bazel Build for Google C++ Testing Framework(Google Test)
34
mistergf63e2a12017-08-01 14:36:29 -040035package(default_visibility = ["//visibility:public"])
36
37licenses(["notice"])
38
misterg88150872017-08-08 15:17:56 -040039config_setting(
40 name = "win",
41 values = {"cpu": "x64_windows_msvc"},
42)
43
misterg66a03692017-08-09 14:37:58 -040044# Google Test including Google Mock
mistergf63e2a12017-08-01 14:36:29 -040045cc_library(
46 name = "gtest",
47 srcs = glob(
48 include = [
49 "googletest/src/*.cc",
50 "googletest/src/*.h",
51 "googletest/include/gtest/**/*.h",
mistergac885f32017-08-09 11:47:54 -040052 "googlemock/src/*.cc",
53 "googlemock/include/gmock/**/*.h",
mistergf63e2a12017-08-01 14:36:29 -040054 ],
55 exclude = [
56 "googletest/src/gtest-all.cc",
57 "googletest/src/gtest_main.cc",
mistergac885f32017-08-09 11:47:54 -040058 "googlemock/src/gmock-all.cc",
misterg66a03692017-08-09 14:37:58 -040059 "googlemock/src/gmock_main.cc",
mistergf63e2a12017-08-01 14:36:29 -040060 ],
61 ),
misterg66a03692017-08-09 14:37:58 -040062 hdrs =glob([
63 "googletest/include/gtest/*.h",
64 "googlemock/include/gmock/*.h",
65 ]),
mistergf63e2a12017-08-01 14:36:29 -040066 copts = select(
67 {
68 ":win": [],
69 "//conditions:default": ["-pthread"],
70 },
71 ),
72 includes = [
mistergac885f32017-08-09 11:47:54 -040073 "googlemock",
74 "googlemock/include",
misterg88150872017-08-08 15:17:56 -040075 "googletest",
76 "googletest/include",
77 ],
78 linkopts = select({
79 ":win": [],
80 "//conditions:default": [
81 "-pthread",
82 ],
83 }),
84)
85
mistergf63e2a12017-08-01 14:36:29 -040086cc_library(
87 name = "gtest_main",
mistergac885f32017-08-09 11:47:54 -040088 srcs = [
mistergc3f65332017-08-10 15:33:09 -040089 "googlemock/src/gmock_main.cc",
mistergf63e2a12017-08-01 14:36:29 -040090 ],
misterg88150872017-08-08 15:17:56 -040091 deps = ["//:gtest"],
mistergf63e2a12017-08-01 14:36:29 -040092)
93
misterg6615f7d2017-08-02 14:36:39 -040094# The following rules build samples of how to use gTest.
mistergf63e2a12017-08-01 14:36:29 -040095cc_library(
mistergb3edada2017-08-01 14:50:59 -040096 name = "gtest_sample_lib",
mistergf63e2a12017-08-01 14:36:29 -040097 srcs = [
98 "googletest/samples/sample1.cc",
99 "googletest/samples/sample2.cc",
100 "googletest/samples/sample4.cc",
101 ],
102 hdrs = [
103 "googletest/samples/prime_tables.h",
104 "googletest/samples/sample1.h",
105 "googletest/samples/sample2.h",
106 "googletest/samples/sample3-inl.h",
107 "googletest/samples/sample4.h",
108 ],
mistergf63e2a12017-08-01 14:36:29 -0400109)
110
111cc_test(
mistergb3edada2017-08-01 14:50:59 -0400112 name = "gtest_samples",
mistergf63e2a12017-08-01 14:36:29 -0400113 size = "small",
misterg88150872017-08-08 15:17:56 -0400114 #All Samples except:
115 #sample9 ( main )
116 #sample10 (main and takes a command line option and needs to be separate)
117 srcs = [
118 "googletest/samples/sample1_unittest.cc",
119 "googletest/samples/sample2_unittest.cc",
120 "googletest/samples/sample3_unittest.cc",
121 "googletest/samples/sample4_unittest.cc",
122 "googletest/samples/sample5_unittest.cc",
123 "googletest/samples/sample6_unittest.cc",
124 "googletest/samples/sample7_unittest.cc",
125 "googletest/samples/sample8_unittest.cc",
126 ],
mistergf63e2a12017-08-01 14:36:29 -0400127 deps = [
mistergaa31cb62017-08-02 15:40:14 -0400128 "gtest_sample_lib",
mistergb3edada2017-08-01 14:50:59 -0400129 ":gtest_main",
mistergf63e2a12017-08-01 14:36:29 -0400130 ],
131)
132
133cc_test(
mistergaa31cb62017-08-02 15:40:14 -0400134 name = "sample9_unittest",
mistergf63e2a12017-08-01 14:36:29 -0400135 size = "small",
mistergaa31cb62017-08-02 15:40:14 -0400136 srcs = ["googletest/samples/sample9_unittest.cc"],
misterg88150872017-08-08 15:17:56 -0400137 deps = [":gtest"],
mistergaa31cb62017-08-02 15:40:14 -0400138)
139
140cc_test(
141 name = "sample10_unittest",
142 size = "small",
143 srcs = ["googletest/samples/sample10_unittest.cc"],
mistergf63e2a12017-08-01 14:36:29 -0400144 deps = [
misterg88150872017-08-08 15:17:56 -0400145 ":gtest",
mistergf63e2a12017-08-01 14:36:29 -0400146 ],
mistergb98e30b2017-08-10 11:54:46 -0400147)