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_dir" ] 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_rtti_main") { # ADD 115 testonly = true 116 sources = [ "$googletest_dir/src/gtest_main.cc" ] 117 public_deps = [ ":gtest_rtti" ] 118} 119 120static_library("gtest_main") { 121 testonly = true 122 sources = [ "$googletest_dir/src/gtest_main.cc" ] 123 public_deps = [ ":gtest" ] 124} 125 126config("gmock_private_config") { 127 visibility = [ ":*" ] 128 include_dirs = [ "$googlemock_dir" ] 129} 130 131config("gmock_private_config_rtti") { 132 visibility = [ ":*" ] 133 include_dirs = [ "googlemock_dir/include" ] 134 cflags = [ "-frtti" ] 135 cflags_objcc = [ "-frtti" ] 136 cflags_cc = [ "-frtti" ] 137} 138 139config("gmock_config") { 140 include_dirs = [ "$googlemock_dir/include" ] 141 142 cflags_cc = [ 143 # The MOCK_METHODn() macros do not specify "override", which triggers this 144 # warning in users: "error: 'Method' overrides a member function but is not 145 # marked 'override' [-Werror,-Winconsistent-missing-override]". Suppress 146 # these warnings until https://github.com/google/googletest/issues/533 is 147 # fixed. 148 "-Wno-inconsistent-missing-override", 149 ] 150} 151 152gmock_sources_files = [ 153 "$googlemock_dir/include/gmock/gmock-actions.h", 154 "$googlemock_dir/include/gmock/gmock-cardinalities.h", 155 "$googlemock_dir/include/gmock/gmock-function-mocker.h", 156 "$googlemock_dir/include/gmock/gmock-matchers.h", 157 "$googlemock_dir/include/gmock/gmock-more-actions.h", 158 "$googlemock_dir/include/gmock/gmock-more-matchers.h", 159 "$googlemock_dir/include/gmock/gmock-nice-strict.h", 160 "$googlemock_dir/include/gmock/gmock-spec-builders.h", 161 "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h", 162 "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h", 163 "$googlemock_dir/include/gmock/internal/custom/gmock-port.h", 164 "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h", 165 "$googlemock_dir/include/gmock/internal/gmock-port.h", 166 "$googlemock_dir/include/gmock/internal/gmock-pp.h", 167 "$googlemock_dir/src/gmock-all.cc", 168 "$googlemock_dir/src/gmock-cardinalities.cc", 169 "$googlemock_dir/src/gmock-internal-utils.cc", 170 "$googlemock_dir/src/gmock-matchers.cc", 171 "$googlemock_dir/src/gmock-spec-builders.cc", 172 "$googlemock_dir/src/gmock.cc", 173] 174 175static_library("gmock") { 176 testonly = true 177 public = [ "$googlemock_dir/include/gmock/gmock.h" ] 178 sources = gmock_sources_files 179 sources -= [ "$googlemock_dir/src/gmock-all.cc" ] 180 public_configs = [ ":gmock_config" ] 181 configs += [ ":gmock_private_config" ] 182 deps = [ ":gtest" ] 183} 184 185static_library("gmock_rtti") { 186 testonly = true 187 public = [ "$googlemock_dir/include/gmock/gmock.h" ] 188 sources = gmock_sources_files 189 sources -= [ "$googlemock_dir/src/gmock-all.cc" ] 190 public_configs = [ ":gmock_config" ] 191 configs += [ ":gmock_private_config_rtti" ] 192 deps = [ ":gtest_rtti" ] 193} 194 195static_library("gmock_main") { 196 testonly = true 197 sources = [ "$googlemock_dir/src/gmock_main.cc" ] 198 public_deps = [ 199 ":gmock", 200 ":gtest", 201 ] 202} 203