summaryrefslogtreecommitdiffstats
path: root/third_party/libphonenumber/BUILD.gn
blob: edd808a66d741d87e43a68671c0b84bc35de18e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//testing/test.gni")
import("//third_party/protobuf/proto_library.gni")

proto_library("proto") {
  sources = [
    "src/resources/phonemetadata.proto",
    "src/resources/phonenumber.proto",
  ]
  proto_out_dir = "third_party/libphonenumber/phonenumbers"
}

config("libphonenumber_config") {
  include_dirs = [
    "src",
    "$root_gen_dir/third_party/libphonenumber",
  ]
  defines = [ "I18N_PHONENUMBERS_USE_ICU_REGEXP=1" ]
  if (!is_android) {
    defines += [ "I18N_PHONENUMBERS_NO_THREAD_SAFETY=1" ]
  }
}

config("libphonenumber_config_internal") {
  if (is_clang) {
    cflags = [
      # https://github.com/googlei18n/libphonenumber/pull/741
      "-Wno-unused-private-field",
    ]
  }
}

# GYP version: third_party/libphonenumber/libphonenumber.gyp:libphonenumber_without_metadata
static_library("libphonenumber_without_metadata") {
  sources = [
    "src/phonenumbers/asyoutypeformatter.cc",
    "src/phonenumbers/base/strings/string_piece.cc",
    "src/phonenumbers/default_logger.cc",
    "src/phonenumbers/logger.cc",
    "src/phonenumbers/phonenumber.cc",
    "src/phonenumbers/phonenumbermatch.cc",
    "src/phonenumbers/phonenumbermatcher.cc",
    "src/phonenumbers/phonenumberutil.cc",
    "src/phonenumbers/regexp_adapter_icu.cc",
    "src/phonenumbers/regexp_cache.cc",
    "src/phonenumbers/string_byte_sink.cc",
    "src/phonenumbers/stringutil.cc",
    "src/phonenumbers/unicodestring.cc",
    "src/phonenumbers/utf/rune.c",
    "src/phonenumbers/utf/unicodetext.cc",
    "src/phonenumbers/utf/unilib.cc",
  ]

  # libphonenumber's base/logging.h is a minimal implementation where DCHECKs
  # do not consume their arguments. This leads to unused variable warnings in
  # release builds.
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    ":libphonenumber_config_internal",
  ]

  public_configs = [ ":libphonenumber_config" ]

  public_deps = [
    ":proto",
  ]
  deps = [
    ":proto",
    "//third_party/icu",
    "//third_party/protobuf:protobuf_lite",
  ]
}

# Library used by clients that includes production metadata.
# GYP version: third_party/libphonenumber/libphonenumber.gyp:libphonenumber
static_library("libphonenumber") {
  sources = [
    # Comment next line and uncomment the line after, if complete metadata
    # (with examples) is needed.
    "src/phonenumbers/lite_metadata.cc",
    #"src/phonenumbers/metadata.cc",
  ]

  public_deps = [
    ":libphonenumber_without_metadata",
  ]
}

# GYP version: third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests
test("libphonenumber_unittests") {
  sources = [
    "src/phonenumbers/test_metadata.cc",
    "src/test/phonenumbers/asyoutypeformatter_test.cc",
    "src/test/phonenumbers/phonenumbermatch_test.cc",
    "src/test/phonenumbers/phonenumbermatcher_test.cc",
    "src/test/phonenumbers/phonenumberutil_test.cc",
    "src/test/phonenumbers/regexp_adapter_test.cc",
    "src/test/phonenumbers/stringutil_test.cc",
    "src/test/phonenumbers/test_util.cc",
    "src/test/phonenumbers/unicodestring_test.cc",
  ]

  configs += [ ":libphonenumber_config_internal" ]

  include_dirs = [ "src/test" ]

  deps = [
    ":libphonenumber_without_metadata",
    "//base",
    "//base/test:run_all_unittests",
    "//base/third_party/dynamic_annotations",
    "//third_party/icu",
    "//testing/gmock",
    "//testing/gtest",
  ]
}