xref: /aosp_15_r20/external/cronet/testing/gtest/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2014 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build_overrides/gtest.gni")
6if (is_ios) {
7  import("//build/buildflag_header.gni")
8  import("//build/config/coverage/coverage.gni")
9  import("//build/config/ios/ios_sdk.gni")
10}
11
12config("gtest_direct_config") {
13  visibility = [ ":*" ]
14  defines = [ "UNIT_TEST" ]
15}
16
17# The file/directory layout of Google Test is not yet considered stable. Until
18# it stabilizes, Chromium code MUST use this target instead of reaching directly
19# into //third_party/googletest.
20static_library("gtest") {
21  testonly = true
22
23  sources = [
24    "include/gtest/gtest-death-test.h",
25    "include/gtest/gtest-message.h",
26    "include/gtest/gtest-param-test.h",
27    "include/gtest/gtest-spi.h",
28    "include/gtest/gtest.h",
29    "include/gtest/gtest_prod.h",
30
31    # This is a workaround for the issues below.
32    #
33    # 1) This target needs to be a static_library (not a source set) on Mac to
34    #    avoid the build errors in
35    #    https://codereview.chromium.org/2779193002#msg82.
36    # 2) A static_library must have at least one source file, to avoid build
37    #    errors on Mac and Windows. https://crbug.com/710334
38    # 3) A static_library with complete_static_lib = true, which would not
39    #    require adding the empty file, will result in duplicate symbols on
40    #    Android. https://codereview.chromium.org/2852613002/#ps20001
41    "empty.cc",
42  ]
43  public_deps = [ "//third_party/googletest:gtest" ]
44
45  public_configs = [ ":gtest_direct_config" ]
46
47  if (gtest_include_multiprocess) {
48    sources += [
49      "../multiprocess_func_list.cc",
50      "../multiprocess_func_list.h",
51    ]
52  }
53
54  if (gtest_include_platform_test) {
55    sources += [ "../platform_test.h" ]
56  }
57
58  if (is_apple && gtest_include_objc_support) {
59    sources += [
60      "../gtest_mac.h",
61      "../gtest_mac.mm",
62    ]
63    if (gtest_include_platform_test) {
64      sources += [ "../platform_test_mac.mm" ]
65    }
66  }
67
68  if (is_ios && gtest_include_ios_coverage) {
69    public_deps += [ ":ios_coverage_utils" ]
70  }
71}
72
73# The file/directory layout of Google Test is not yet considered stable. Until
74# it stabilizes, Chromium code MUST use this target instead of reaching directly
75# into //third_party/googletest.
76source_set("gtest_main") {
77  testonly = true
78  deps = [ "//third_party/googletest:gtest_main" ]
79}
80
81if (is_ios) {
82  # These headers are needed in some non test targets for iOS code coverage. So
83  # can not be testonly.
84  source_set("ios_coverage_utils") {
85    sources = [
86      "../coverage_util_ios.h",
87      "../coverage_util_ios.mm",
88    ]
89    deps = [ ":ios_enable_coverage" ]
90  }
91
92  buildflag_header("ios_enable_coverage") {
93    header = "ios_enable_coverage.h"
94    flags = [ "IOS_ENABLE_COVERAGE=$use_clang_coverage" ]
95  }
96}
97