BUILD.gn 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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("//testing/test.gni")
  5. import("//third_party/protobuf/proto_library.gni")
  6. proto_library("proto") {
  7. sources = [
  8. "dist/resources/phonemetadata.proto",
  9. "dist/resources/phonenumber.proto",
  10. ]
  11. proto_out_dir = "third_party/libphonenumber/phonenumbers"
  12. }
  13. config("libphonenumber_config") {
  14. include_dirs = [
  15. "dist/cpp/src",
  16. "$root_gen_dir/third_party/libphonenumber",
  17. ]
  18. defines = [
  19. "I18N_PHONENUMBERS_USE_ICU_REGEXP=1",
  20. "I18N_PHONENUMBERS_USE_ALTERNATE_FORMATS=1",
  21. ]
  22. if (!is_android) {
  23. defines += [ "I18N_PHONENUMBERS_NO_THREAD_SAFETY=1" ]
  24. }
  25. }
  26. config("libphonenumber_config_internal") {
  27. if (is_clang) {
  28. cflags = [
  29. # https://github.com/googlei18n/libphonenumber/pull/741
  30. "-Wno-unused-private-field",
  31. ]
  32. }
  33. }
  34. static_library("libphonenumber_without_metadata") {
  35. sources = [
  36. "dist/cpp/src/phonenumbers/alternate_format.cc",
  37. "dist/cpp/src/phonenumbers/asyoutypeformatter.cc",
  38. "dist/cpp/src/phonenumbers/base/strings/string_piece.cc",
  39. "dist/cpp/src/phonenumbers/default_logger.cc",
  40. "dist/cpp/src/phonenumbers/logger.cc",
  41. "dist/cpp/src/phonenumbers/phonenumber.cc",
  42. "dist/cpp/src/phonenumbers/phonenumbermatch.cc",
  43. "dist/cpp/src/phonenumbers/phonenumbermatcher.cc",
  44. "dist/cpp/src/phonenumbers/phonenumberutil.cc",
  45. "dist/cpp/src/phonenumbers/regex_based_matcher.cc",
  46. "dist/cpp/src/phonenumbers/regexp_adapter_icu.cc",
  47. "dist/cpp/src/phonenumbers/regexp_cache.cc",
  48. "dist/cpp/src/phonenumbers/string_byte_sink.cc",
  49. "dist/cpp/src/phonenumbers/stringutil.cc",
  50. "dist/cpp/src/phonenumbers/unicodestring.cc",
  51. "dist/cpp/src/phonenumbers/utf/rune.c",
  52. "dist/cpp/src/phonenumbers/utf/unicodetext.cc",
  53. "dist/cpp/src/phonenumbers/utf/unilib.cc",
  54. ]
  55. # libphonenumber's base/logging.h is a minimal implementation where DCHECKs
  56. # do not consume their arguments. This leads to unused variable warnings in
  57. # release builds.
  58. configs -= [ "//build/config/compiler:chromium_code" ]
  59. configs += [
  60. "//build/config/compiler:no_chromium_code",
  61. ":libphonenumber_config_internal",
  62. ]
  63. public_configs = [ ":libphonenumber_config" ]
  64. public_deps = [ ":proto" ]
  65. deps = [
  66. ":proto",
  67. "//third_party/abseil-cpp:absl",
  68. "//third_party/icu",
  69. "//third_party/protobuf:protobuf_lite",
  70. ]
  71. }
  72. # Library used by clients that includes production metadata.
  73. static_library("libphonenumber") {
  74. sources = [
  75. # Comment next line and uncomment the line after, if complete metadata
  76. # (with examples) is needed.
  77. "dist/cpp/src/phonenumbers/lite_metadata.cc",
  78. #"dist/cpp/src/phonenumbers/metadata.cc",
  79. ]
  80. public_deps = [ ":libphonenumber_without_metadata" ]
  81. }
  82. test("libphonenumber_unittests") {
  83. sources = [
  84. "dist/cpp/src/phonenumbers/test_metadata.cc",
  85. "dist/cpp/test/phonenumbers/asyoutypeformatter_test.cc",
  86. "dist/cpp/test/phonenumbers/phonenumbermatch_test.cc",
  87. "dist/cpp/test/phonenumbers/phonenumbermatcher_test.cc",
  88. "dist/cpp/test/phonenumbers/phonenumberutil_test.cc",
  89. "dist/cpp/test/phonenumbers/regexp_adapter_test.cc",
  90. "dist/cpp/test/phonenumbers/stringutil_test.cc",
  91. "dist/cpp/test/phonenumbers/test_util.cc",
  92. "dist/cpp/test/phonenumbers/unicodestring_test.cc",
  93. ]
  94. configs += [ ":libphonenumber_config_internal" ]
  95. include_dirs = [ "dist/cpp/test" ]
  96. deps = [
  97. ":libphonenumber_without_metadata",
  98. "//base",
  99. "//base/test:run_all_unittests",
  100. "//base/third_party/dynamic_annotations",
  101. "//testing/gmock",
  102. "//testing/gtest",
  103. "//third_party/icu",
  104. ]
  105. }