blob: c48e02921756a31fceeb1a3b86ad8d54e5825c7e [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 = [
89 "googletest/src/gtest_main.cc",
90 ],
mistergf63e2a12017-08-01 14:36:29 -040091 includes = [
92 "googletest",
93 "googletest/include",
94 ],
misterg88150872017-08-08 15:17:56 -040095 deps = ["//:gtest"],
mistergf63e2a12017-08-01 14:36:29 -040096)
97
misterg6615f7d2017-08-02 14:36:39 -040098# The following rules build samples of how to use gTest.
mistergf63e2a12017-08-01 14:36:29 -040099cc_library(
mistergb3edada2017-08-01 14:50:59 -0400100 name = "gtest_sample_lib",
mistergf63e2a12017-08-01 14:36:29 -0400101 srcs = [
102 "googletest/samples/sample1.cc",
103 "googletest/samples/sample2.cc",
104 "googletest/samples/sample4.cc",
105 ],
106 hdrs = [
107 "googletest/samples/prime_tables.h",
108 "googletest/samples/sample1.h",
109 "googletest/samples/sample2.h",
110 "googletest/samples/sample3-inl.h",
111 "googletest/samples/sample4.h",
112 ],
mistergf63e2a12017-08-01 14:36:29 -0400113)
114
115cc_test(
mistergb3edada2017-08-01 14:50:59 -0400116 name = "gtest_samples",
mistergf63e2a12017-08-01 14:36:29 -0400117 size = "small",
misterg88150872017-08-08 15:17:56 -0400118 #All Samples except:
119 #sample9 ( main )
120 #sample10 (main and takes a command line option and needs to be separate)
121 srcs = [
122 "googletest/samples/sample1_unittest.cc",
123 "googletest/samples/sample2_unittest.cc",
124 "googletest/samples/sample3_unittest.cc",
125 "googletest/samples/sample4_unittest.cc",
126 "googletest/samples/sample5_unittest.cc",
127 "googletest/samples/sample6_unittest.cc",
128 "googletest/samples/sample7_unittest.cc",
129 "googletest/samples/sample8_unittest.cc",
130 ],
mistergf63e2a12017-08-01 14:36:29 -0400131 deps = [
mistergaa31cb62017-08-02 15:40:14 -0400132 "gtest_sample_lib",
mistergb3edada2017-08-01 14:50:59 -0400133 ":gtest_main",
mistergf63e2a12017-08-01 14:36:29 -0400134 ],
135)
136
137cc_test(
mistergaa31cb62017-08-02 15:40:14 -0400138 name = "sample9_unittest",
mistergf63e2a12017-08-01 14:36:29 -0400139 size = "small",
mistergaa31cb62017-08-02 15:40:14 -0400140 srcs = ["googletest/samples/sample9_unittest.cc"],
misterg88150872017-08-08 15:17:56 -0400141 deps = [":gtest"],
mistergaa31cb62017-08-02 15:40:14 -0400142)
143
144cc_test(
145 name = "sample10_unittest",
146 size = "small",
147 srcs = ["googletest/samples/sample10_unittest.cc"],
mistergf63e2a12017-08-01 14:36:29 -0400148 deps = [
misterg88150872017-08-08 15:17:56 -0400149 ":gtest",
mistergf63e2a12017-08-01 14:36:29 -0400150 ],
mistergb98e30b2017-08-10 11:54:46 -0400151)