Home | History | Annotate | Download | only in googletest
      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 (a] 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 = "win",
     41     values = {"cpu": "x64_windows_msvc"},
     42 )
     43 
     44 # Google Test including Google Mock 
     45 cc_library(
     46     name = "gtest",
     47     srcs = glob(
     48         include = [
     49             "googletest/src/*.cc",
     50             "googletest/src/*.h",
     51             "googletest/include/gtest/**/*.h",
     52             "googlemock/src/*.cc",
     53             "googlemock/include/gmock/**/*.h",
     54         ],
     55         exclude = [
     56             "googletest/src/gtest-all.cc",
     57             "googletest/src/gtest_main.cc",
     58             "googlemock/src/gmock-all.cc",
     59             "googlemock/src/gmock_main.cc",
     60         ],
     61     ),
     62     hdrs =glob([
     63         "googletest/include/gtest/*.h",
     64         "googlemock/include/gmock/*.h",
     65     ]),
     66     copts = select(
     67         {
     68             ":win": [],
     69             "//conditions:default": ["-pthread"],
     70         },
     71     ),
     72     includes = [
     73         "googlemock",
     74         "googlemock/include",
     75         "googletest",
     76         "googletest/include",
     77     ],
     78     linkopts = select({
     79         ":win": [],
     80         "//conditions:default": [
     81             "-pthread",
     82         ],
     83     }),
     84 )
     85 
     86 cc_library(
     87     name = "gtest_main",
     88     srcs = [
     89         "googlemock/src/gmock_main.cc",
     90     ],
     91     deps = ["//:gtest"],
     92 )
     93 
     94 # The following rules build samples of how to use gTest.
     95 cc_library(
     96     name = "gtest_sample_lib",
     97     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     ],
    109 )
    110 
    111 cc_test(
    112     name = "gtest_samples",
    113     size = "small",
    114     #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     ],
    127     deps = [
    128         "gtest_sample_lib",
    129         ":gtest_main",
    130     ],
    131 )
    132 
    133 cc_test(
    134     name = "sample9_unittest",
    135     size = "small",
    136     srcs = ["googletest/samples/sample9_unittest.cc"],
    137     deps = [":gtest"],
    138 )
    139 
    140 cc_test(
    141     name = "sample10_unittest",
    142     size = "small",
    143     srcs = ["googletest/samples/sample10_unittest.cc"],
    144     deps = [
    145         ":gtest",
    146     ],
    147 )
    148