BUILD.gn 2.8 KB

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