• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14googletest_dir = "//third_party/googletest/googletest"
15googlemock_dir = "//third_party/googletest/googlemock"
16
17config("gtest_private_config") {
18  visibility = [ ":*" ]
19  include_dirs = [ "$googletest_dir" ]
20}
21
22config("gtest_private_config_rtti") {
23  visibility = [ ":*" ]
24  include_dirs = [ "googletest" ]
25  cflags = [ "-frtti" ]
26  cflags_objcc = [ "-frtti" ]
27  cflags_cc = [ "-frtti" ]
28}
29
30config("gtest_config") {
31  include_dirs = [ "$googletest_dir/include" ]
32  cflags_cc = [
33    "-std=c++17",
34    "-Wno-float-equal",
35    "-Wno-sign-compare",
36    "-Wno-reorder-init-list",
37  ]
38  if (is_mingw) {
39    cflags_cc = [
40      "-Wno-unused-const-variable",
41      "-Wno-unused-private-field",
42    ]
43  }
44}
45
46sources_files = [
47  "$googletest_dir/include/gtest/gtest-death-test.h",
48  "$googletest_dir/include/gtest/gtest-matchers.h",
49  "$googletest_dir/include/gtest/gtest-message.h",
50  "$googletest_dir/include/gtest/gtest-param-test.h",
51  "$googletest_dir/include/gtest/gtest-printers.h",
52  "$googletest_dir/include/gtest/gtest-test-part.h",
53  "$googletest_dir/include/gtest/gtest-typed-test.h",
54  "$googletest_dir/include/gtest/gtest_pred_impl.h",
55  "$googletest_dir/include/gtest/gtest_prod.h",
56  "$googletest_dir/include/gtest/hwext/gtest-ext.h",
57  "$googletest_dir/include/gtest/hwext/gtest-filter.h",
58  "$googletest_dir/include/gtest/hwext/gtest-multithread.h",
59  "$googletest_dir/include/gtest/hwext/gtest-tag.h",
60  "$googletest_dir/include/gtest/hwext/utils.h",
61  "$googletest_dir/include/gtest/internal/custom/gtest-port.h",
62  "$googletest_dir/include/gtest/internal/custom/gtest-printers.h",
63  "$googletest_dir/include/gtest/internal/custom/gtest.h",
64  "$googletest_dir/include/gtest/internal/gtest-death-test-internal.h",
65  "$googletest_dir/include/gtest/internal/gtest-filepath.h",
66  "$googletest_dir/include/gtest/internal/gtest-internal.h",
67  "$googletest_dir/include/gtest/internal/gtest-param-util.h",
68  "$googletest_dir/include/gtest/internal/gtest-port-arch.h",
69  "$googletest_dir/include/gtest/internal/gtest-port.h",
70  "$googletest_dir/include/gtest/internal/gtest-string.h",
71  "$googletest_dir/include/gtest/internal/gtest-type-util.h",
72  "$googletest_dir/src/gtest-all.cc",
73  "$googletest_dir/src/gtest-assertion-result.cc",
74  "$googletest_dir/src/gtest-death-test.cc",
75  "$googletest_dir/src/gtest-filepath.cc",
76  "$googletest_dir/src/gtest-internal-inl.h",
77  "$googletest_dir/src/gtest-matchers.cc",
78  "$googletest_dir/src/gtest-port.cc",
79  "$googletest_dir/src/gtest-printers.cc",
80  "$googletest_dir/src/gtest-test-part.cc",
81  "$googletest_dir/src/gtest-typed-test.cc",
82  "$googletest_dir/src/gtest.cc",
83  "$googletest_dir/src/hwext/gtest-ext.cc",
84  "$googletest_dir/src/hwext/gtest-filter.cc",
85  "$googletest_dir/src/hwext/gtest-multithread.cpp",
86  "$googletest_dir/src/hwext/gtest-tag.cc",
87  "$googletest_dir/src/hwext/gtest-utils.cc",
88]
89
90static_library("gtest") {
91  testonly = true
92  public = [
93    "$googletest_dir/include/gtest/gtest-spi.h",
94    "$googletest_dir/include/gtest/gtest.h",
95  ]
96  sources = sources_files
97  sources -= [ "$googletest_dir/src/gtest-all.cc" ]
98  public_configs = [ ":gtest_config" ]
99  configs += [ ":gtest_private_config" ]
100}
101
102static_library("gtest_rtti") {
103  testonly = true
104  public = [
105    "$googletest_dir/include/gtest/gtest-spi.h",
106    "$googletest_dir/include/gtest/gtest.h",
107  ]
108  sources = sources_files
109  sources -= [ "$googletest_dir/src/gtest-all.cc" ]
110  public_configs = [ ":gtest_config" ]
111  configs += [ ":gtest_private_config_rtti" ]
112}
113
114static_library("gtest_main") {
115  testonly = true
116  sources = [ "$googletest_dir/src/gtest_main.cc" ]
117  public_deps = [ ":gtest" ]
118}
119
120config("gmock_private_config") {
121  visibility = [ ":*" ]
122  include_dirs = [ "$googlemock_dir" ]
123}
124
125config("gmock_private_config_rtti") {
126  visibility = [ ":*" ]
127  include_dirs = [ "googlemock_dir/include" ]
128  cflags = [ "-frtti" ]
129  cflags_objcc = [ "-frtti" ]
130  cflags_cc = [ "-frtti" ]
131}
132
133config("gmock_config") {
134  include_dirs = [ "$googlemock_dir/include" ]
135
136  cflags_cc = [
137    # The MOCK_METHODn() macros do not specify "override", which triggers this
138    # warning in users: "error: 'Method' overrides a member function but is not
139    # marked 'override' [-Werror,-Winconsistent-missing-override]". Suppress
140    # these warnings until https://github.com/google/googletest/issues/533 is
141    # fixed.
142    "-Wno-inconsistent-missing-override",
143  ]
144}
145
146gmock_sources_files = [
147  "$googlemock_dir/include/gmock/gmock-actions.h",
148  "$googlemock_dir/include/gmock/gmock-cardinalities.h",
149  "$googlemock_dir/include/gmock/gmock-function-mocker.h",
150  "$googlemock_dir/include/gmock/gmock-matchers.h",
151  "$googlemock_dir/include/gmock/gmock-more-actions.h",
152  "$googlemock_dir/include/gmock/gmock-more-matchers.h",
153  "$googlemock_dir/include/gmock/gmock-nice-strict.h",
154  "$googlemock_dir/include/gmock/gmock-spec-builders.h",
155  "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h",
156  "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h",
157  "$googlemock_dir/include/gmock/internal/custom/gmock-port.h",
158  "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h",
159  "$googlemock_dir/include/gmock/internal/gmock-port.h",
160  "$googlemock_dir/include/gmock/internal/gmock-pp.h",
161  "$googlemock_dir/src/gmock-all.cc",
162  "$googlemock_dir/src/gmock-cardinalities.cc",
163  "$googlemock_dir/src/gmock-internal-utils.cc",
164  "$googlemock_dir/src/gmock-matchers.cc",
165  "$googlemock_dir/src/gmock-spec-builders.cc",
166  "$googlemock_dir/src/gmock.cc",
167]
168
169static_library("gmock") {
170  testonly = true
171  public = [ "$googlemock_dir/include/gmock/gmock.h" ]
172  sources = gmock_sources_files
173  sources -= [ "$googlemock_dir/src/gmock-all.cc" ]
174  public_configs = [ ":gmock_config" ]
175  configs += [ ":gmock_private_config" ]
176  deps = [ ":gtest" ]
177}
178
179static_library("gmock_rtti") {
180  testonly = true
181  public = [ "$googlemock_dir/include/gmock/gmock.h" ]
182  sources = gmock_sources_files
183  sources -= [ "$googlemock_dir/src/gmock-all.cc" ]
184  public_configs = [ ":gmock_config" ]
185  configs += [ ":gmock_private_config_rtti" ]
186  deps = [ ":gtest_rtti" ]
187}
188
189static_library("gmock_main") {
190  testonly = true
191  sources = [ "$googlemock_dir/src/gmock_main.cc" ]
192  public_deps = [
193    ":gmock",
194    ":gtest",
195  ]
196}
197