summaryrefslogtreecommitdiffstats
path: root/build/secondary/testing/gtest/BUILD.gn
blob: a9f5007b2670a8619048c58e451396c26cc8f69f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

config("gtest_config") {
  visibility = [
    ":*",
    "//testing/gmock:*",  # gmock also shares this config.
  ]

  defines = [
    # In order to allow regex matches in gtest to be shared between Windows
    # and other systems, we tell gtest to always use it's internal engine.
    "GTEST_HAS_POSIX_RE=0",

    # Chrome doesn't support / require C++11, yet.
    "GTEST_LANG_CXX11=0",
  ]

  # Gtest headers need to be able to find themselves.
  include_dirs = [ "include" ]

  if (is_win) {
    cflags = [ "/wd4800" ]  # Unused variable warning.
  }

  if (is_posix) {
    defines += [
      # gtest isn't able to figure out when RTTI is disabled for gcc
      # versions older than 4.3.2, and assumes it's enabled.  Our Mac
      # and Linux builds disable RTTI, and cannot guarantee that the
      # compiler will be 4.3.2. or newer.  The Mac, for example, uses
      # 4.2.1 as that is the latest available on that platform.  gtest
      # must be instructed that RTTI is disabled here, and for any
      # direct dependents that might include gtest headers.
      "GTEST_HAS_RTTI=0",
    ]
  }

  if (is_android) {
    defines += [
      # We want gtest features that use tr1::tuple, but we currently
      # don't support the variadic templates used by libstdc++'s
      # implementation. gtest supports this scenario by providing its
      # own implementation but we must opt in to it.
      "GTEST_USE_OWN_TR1_TUPLE=1",

      # GTEST_USE_OWN_TR1_TUPLE only works if GTEST_HAS_TR1_TUPLE is set.
      # gtest r625 made it so that GTEST_HAS_TR1_TUPLE is set to 0
      # automatically on android, so it has to be set explicitly here.
      "GTEST_HAS_TR1_TUPLE=1",
    ]
  }
}

config("gtest_direct_config") {
  visibility = [ ":*" ]
  defines = [ "UNIT_TEST" ]
}

static_library("gtest") {
  # TODO http://crbug.com/412064 enable this flag all the time.
  testonly = !is_component_build
  sources = [
    "include/gtest/gtest-death-test.h",
    "include/gtest/gtest-message.h",
    "include/gtest/gtest-param-test.h",
    "include/gtest/gtest-printers.h",
    "include/gtest/gtest-spi.h",
    "include/gtest/gtest-test-part.h",
    "include/gtest/gtest-typed-test.h",
    "include/gtest/gtest.h",
    "include/gtest/gtest_pred_impl.h",
    "include/gtest/internal/gtest-death-test-internal.h",
    "include/gtest/internal/gtest-filepath.h",
    "include/gtest/internal/gtest-internal.h",
    "include/gtest/internal/gtest-linked_ptr.h",
    "include/gtest/internal/gtest-param-util-generated.h",
    "include/gtest/internal/gtest-param-util.h",
    "include/gtest/internal/gtest-port.h",
    "include/gtest/internal/gtest-string.h",
    "include/gtest/internal/gtest-tuple.h",
    "include/gtest/internal/gtest-type-util.h",

    #"gtest/src/gtest-all.cc",  # Not needed by our build.
    "../multiprocess_func_list.cc",
    "../multiprocess_func_list.h",
    "../platform_test.h",
    "src/gtest-death-test.cc",
    "src/gtest-filepath.cc",
    "src/gtest-internal-inl.h",
    "src/gtest-port.cc",
    "src/gtest-printers.cc",
    "src/gtest-test-part.cc",
    "src/gtest-typed-test.cc",
    "src/gtest.cc",
  ]

  if (is_mac || is_ios) {
    if (is_ios) {
      set_sources_assignment_filter([])
    }
    sources += [
      "../gtest_mac.h",
      "../gtest_mac.mm",
      "../platform_test_mac.mm",
    ]
    set_sources_assignment_filter(sources_assignment_filter)
  }

  if (is_ios) {
    sources += [
      "../coverage_util_ios.cc",
      "../coverage_util_ios.h",
    ]
  }

  include_dirs = [ "." ]

  all_dependent_configs = [ ":gtest_config" ]
  public_configs = [ ":gtest_direct_config" ]

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]

  config("gtest_warnings") {
    if (is_win && is_clang) {
      # The Mutex constructor initializer list in gtest-port.cc is incorrectly
      # ordered. See
      # https://groups.google.com/d/msg/googletestframework/S5uSV8L2TX8/U1FaTDa6J6sJ.
      cflags = [ "-Wno-reorder" ]
    }
  }
  configs += [ ":gtest_warnings" ]
}

source_set("gtest_main") {
  # TODO http://crbug.com/412064 enable this flag all the time.
  testonly = !is_component_build
  sources = [
    "src/gtest_main.cc",
  ]
  deps = [
    ":gtest",
  ]
}