tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BUILD.bazel (7422B)


      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 #   Bazel Build for Google C++ Testing Framework(Google Test)
     32 
     33 load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
     34 
     35 package(default_visibility = ["//visibility:public"])
     36 
     37 licenses(["notice"])
     38 
     39 exports_files(["LICENSE"])
     40 
     41 config_setting(
     42    name = "qnx",
     43    constraint_values = ["@platforms//os:qnx"],
     44 )
     45 
     46 config_setting(
     47    name = "windows",
     48    constraint_values = ["@platforms//os:windows"],
     49 )
     50 
     51 config_setting(
     52    name = "freebsd",
     53    constraint_values = ["@platforms//os:freebsd"],
     54 )
     55 
     56 config_setting(
     57    name = "openbsd",
     58    constraint_values = ["@platforms//os:openbsd"],
     59 )
     60 
     61 # NOTE: Fuchsia is not an officially supported platform.
     62 config_setting(
     63    name = "fuchsia",
     64    constraint_values = ["@platforms//os:fuchsia"],
     65 )
     66 
     67 config_setting(
     68    name = "msvc_compiler",
     69    flag_values = {
     70        "@bazel_tools//tools/cpp:compiler": "msvc-cl",
     71    },
     72    visibility = [":__subpackages__"],
     73 )
     74 
     75 config_setting(
     76    name = "has_absl",
     77    values = {"define": "absl=1"},
     78 )
     79 
     80 # Library that defines the FRIEND_TEST macro.
     81 cc_library(
     82    name = "gtest_prod",
     83    hdrs = ["googletest/include/gtest/gtest_prod.h"],
     84    includes = ["googletest/include"],
     85 )
     86 
     87 # Google Test including Google Mock
     88 
     89 # For an actual test, use `gtest` and also `gtest_main` if you depend on gtest's
     90 # main(). For a library, use `gtest_for_library` instead if the library can be
     91 # testonly.
     92 cc_library(
     93    name = "gtest",
     94    srcs = glob(
     95        include = [
     96            "googletest/src/*.cc",
     97            "googletest/src/*.h",
     98            "googletest/include/gtest/**/*.h",
     99            "googlemock/src/*.cc",
    100            "googlemock/include/gmock/**/*.h",
    101        ],
    102        exclude = [
    103            "googletest/src/gtest-all.cc",
    104            "googletest/src/gtest_main.cc",
    105            "googlemock/src/gmock-all.cc",
    106            "googlemock/src/gmock_main.cc",
    107        ],
    108    ),
    109    hdrs = glob([
    110        "googletest/include/gtest/*.h",
    111        "googlemock/include/gmock/*.h",
    112    ]),
    113    copts = select({
    114        ":qnx": [],
    115        ":windows": [],
    116        "//conditions:default": ["-pthread"],
    117    }),
    118    defines = select({
    119        ":has_absl": ["GTEST_HAS_ABSL=1"],
    120        "//conditions:default": [],
    121    }),
    122    features = select({
    123        ":windows": ["windows_export_all_symbols"],
    124        "//conditions:default": [],
    125    }),
    126    includes = [
    127        "googlemock",
    128        "googlemock/include",
    129        "googletest",
    130        "googletest/include",
    131    ],
    132    linkopts = select({
    133        ":qnx": ["-lregex"],
    134        ":windows": [],
    135        ":freebsd": [
    136            "-lm",
    137            "-pthread",
    138        ],
    139        ":openbsd": [
    140            "-lm",
    141            "-pthread",
    142        ],
    143        "//conditions:default": ["-pthread"],
    144    }),
    145    deps = select({
    146        ":has_absl": [
    147            "@abseil-cpp//absl/container:flat_hash_set",
    148            "@abseil-cpp//absl/debugging:failure_signal_handler",
    149            "@abseil-cpp//absl/debugging:stacktrace",
    150            "@abseil-cpp//absl/debugging:symbolize",
    151            "@abseil-cpp//absl/flags:flag",
    152            "@abseil-cpp//absl/flags:parse",
    153            "@abseil-cpp//absl/flags:reflection",
    154            "@abseil-cpp//absl/flags:usage",
    155            "@abseil-cpp//absl/strings",
    156            "@re2",
    157        ],
    158        "//conditions:default": [],
    159    }) + select({
    160        # `gtest-death-test.cc` has `EXPECT_DEATH` that spawns a process,
    161        # expects it to crash and inspects its logs with the given matcher,
    162        # so that's why these libraries are needed.
    163        # Otherwise, builds targeting Fuchsia would fail to compile.
    164        ":fuchsia": [
    165            "@fuchsia_sdk//pkg/fdio",
    166            "@fuchsia_sdk//pkg/zx",
    167        ],
    168        "//conditions:default": [],
    169    }),
    170 )
    171 
    172 # `gtest`, but testonly. See guidance on `gtest` for when to use this.
    173 alias(
    174    name = "gtest_for_library",
    175    testonly = True,
    176    actual = ":gtest",
    177 )
    178 
    179 # Implements main() for tests using gtest. Prefer to depend on `gtest` as well
    180 # to ensure compliance with the layering_check Bazel feature where only the
    181 # direct hdrs values are available.
    182 cc_library(
    183    name = "gtest_main",
    184    srcs = ["googlemock/src/gmock_main.cc"],
    185    features = select({
    186        ":windows": ["windows_export_all_symbols"],
    187        "//conditions:default": [],
    188    }),
    189    deps = [":gtest"],
    190 )
    191 
    192 # The following rules build samples of how to use gTest.
    193 cc_library(
    194    name = "gtest_sample_lib",
    195    srcs = [
    196        "googletest/samples/sample1.cc",
    197        "googletest/samples/sample2.cc",
    198        "googletest/samples/sample4.cc",
    199    ],
    200    hdrs = [
    201        "googletest/samples/prime_tables.h",
    202        "googletest/samples/sample1.h",
    203        "googletest/samples/sample2.h",
    204        "googletest/samples/sample3-inl.h",
    205        "googletest/samples/sample4.h",
    206    ],
    207    features = select({
    208        ":windows": ["windows_export_all_symbols"],
    209        "//conditions:default": [],
    210    }),
    211 )
    212 
    213 cc_test(
    214    name = "gtest_samples",
    215    size = "small",
    216    # All Samples except:
    217    #   sample9 (main)
    218    #   sample10 (main and takes a command line option and needs to be separate)
    219    srcs = [
    220        "googletest/samples/sample1_unittest.cc",
    221        "googletest/samples/sample2_unittest.cc",
    222        "googletest/samples/sample3_unittest.cc",
    223        "googletest/samples/sample4_unittest.cc",
    224        "googletest/samples/sample5_unittest.cc",
    225        "googletest/samples/sample6_unittest.cc",
    226        "googletest/samples/sample7_unittest.cc",
    227        "googletest/samples/sample8_unittest.cc",
    228    ],
    229    linkstatic = 0,
    230    deps = [
    231        "gtest_sample_lib",
    232        ":gtest_main",
    233    ],
    234 )
    235 
    236 cc_test(
    237    name = "sample9_unittest",
    238    size = "small",
    239    srcs = ["googletest/samples/sample9_unittest.cc"],
    240    deps = [":gtest"],
    241 )
    242 
    243 cc_test(
    244    name = "sample10_unittest",
    245    size = "small",
    246    srcs = ["googletest/samples/sample10_unittest.cc"],
    247    deps = [":gtest"],
    248 )