OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/features.gni") | 5 import("//build/config/features.gni") |
6 | 6 |
7 declare_args() { | 7 declare_args() { |
8 if (is_android || is_ios) { | 8 if (is_android || is_ios) { |
9 cld2_table_size = 0 # Small, accurate tables | 9 cld2_table_size = 0 # Small, accurate tables |
10 } else { | 10 } else { |
11 cld2_table_size = 2 # Larger, more accurate tables | 11 cld2_table_size = 2 # Larger, more accurate tables |
12 } | 12 } |
13 } | 13 } |
14 | 14 |
15 gypi_values = exec_script("//build/gypi_to_gn.py", | 15 gypi_values = exec_script("//build/gypi_to_gn.py", |
16 [ rebase_path("cld_2.gyp") ], | 16 [ rebase_path("cld_2.gyp") ], |
17 "scope", | 17 "scope", |
18 [ "cld_2.gyp" ]) | 18 [ "cld_2.gyp" ]) |
19 | 19 |
20 # This variable controls which dependency is resolved by the pass-through | |
21 # target 'cld2_platform_impl', and allows the embedder to choose which | |
22 # kind of CLD2 support is required at build time: | |
23 # | |
24 # - If the value is 'static', then the cld2_platform_impl target will depend | |
25 # upon the cld2_static target | |
26 # - If the value is 'dynamic', then the cld2_platform_impl target will | |
27 # depend upon the cld2_dynamic target. | |
28 # | |
29 # High-level targets for Chromium unit tests hard-code a dependency upon | |
30 # cld2_static because doing so makes sense for use cases that aren't | |
31 # affected by the loading of language detection data; however, most other | |
32 # targets (e.g. the final executables and interactive UI tests) should be | |
33 # linked against whatever the embedder needs. | |
34 # | |
35 # Maintainers: | |
36 # This value may be reasonably tweaked on a per-platform basis. | |
37 # Don't forget to update this file as well to match: | |
38 # components/translate/content/browser/browser_cld_utils.cc | |
39 # components/translate/content/renderer/renderer_cld_utils.cc | |
40 cld2_platform_support = "static" | |
41 | |
42 config("cld2_data_warnings") { | 20 config("cld2_data_warnings") { |
43 visibility = [ ":*" ] | 21 visibility = [ ":*" ] |
44 if (is_clang) { | 22 if (is_clang) { |
45 # The generated files don't have braces around subobject initializers. | 23 # The generated files don't have braces around subobject initializers. |
46 cflags = [ "-Wno-missing-braces" ] | 24 cflags = [ "-Wno-missing-braces" ] |
47 } | 25 } |
48 } | 26 } |
49 | 27 |
50 source_set("cld2_data") { | 28 source_set("cld2_data") { |
51 sources = gypi_values.cld2_data_sources | 29 sources = gypi_values.cld2_data_sources |
(...skipping 10 matching lines...) Expand all Loading... |
62 | 40 |
63 configs -= [ "//build/config/compiler:chromium_code" ] | 41 configs -= [ "//build/config/compiler:chromium_code" ] |
64 configs += [ | 42 configs += [ |
65 "//build/config/compiler:no_chromium_code", | 43 "//build/config/compiler:no_chromium_code", |
66 | 44 |
67 # Must be after no_chromium_code for warning flags to be ordered correctly. | 45 # Must be after no_chromium_code for warning flags to be ordered correctly. |
68 ":cld2_data_warnings", | 46 ":cld2_data_warnings", |
69 ] | 47 ] |
70 } | 48 } |
71 | 49 |
72 # As in the corresponding gyp file, this just builds the core interfaces for | |
73 # CLD2. You must still declare a dependency on a specific data set, either | |
74 # cld2_dynamic or cld2_static. | |
75 source_set("cld_2") { | |
76 sources = gypi_values.cld2_core_sources | |
77 include_dirs = [ | |
78 "src/internal", | |
79 "src/public", | |
80 ] | |
81 | |
82 configs -= [ "//build/config/compiler:chromium_code" ] | |
83 configs += [ "//build/config/compiler:no_chromium_code" ] | |
84 } | |
85 | |
86 source_set("cld2_platform_impl") { | |
87 public_deps = [] | |
88 if (cld2_platform_support == "static") { | |
89 public_deps += [ ":cld2_static" ] | |
90 } else if (cld2_platform_support == "dynamic") { | |
91 public_deps += [ ":cld2_dynamic" ] | |
92 } | |
93 } | |
94 | |
95 config("cld2_warnings") { | 50 config("cld2_warnings") { |
96 if (is_clang) { | 51 if (is_clang) { |
97 cflags = [ | 52 cflags = [ |
98 # cld_2 contains unused private fields. | 53 # cld_2 contains unused private fields. |
99 # https://code.google.com/p/cld2/issues/detail?id=37 | 54 # https://code.google.com/p/cld2/issues/detail?id=37 |
100 "-Wno-unused-private-field", | 55 "-Wno-unused-private-field", |
101 | 56 |
102 # offsetmap.cc uses a char as a subscript. | 57 # offsetmap.cc uses a char as a subscript. |
103 "-Wno-char-subscripts", | 58 "-Wno-char-subscripts", |
104 ] | 59 ] |
105 } | 60 } |
106 } | 61 } |
107 | 62 |
108 static_library("cld2_static") { | 63 static_library("cld_2") { |
109 sources = gypi_values.cld2_core_impl_sources | 64 sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources |
110 include_dirs = [ | 65 include_dirs = [ |
111 "src/internal", | 66 "src/internal", |
112 "src/public", | 67 "src/public", |
113 ] | 68 ] |
114 | 69 |
115 public_deps = [ | 70 public_deps = [ |
116 ":cld2_data", | 71 ":cld2_data", |
117 ":cld_2", | |
118 ] | 72 ] |
119 configs -= [ "//build/config/compiler:chromium_code" ] | 73 configs -= [ "//build/config/compiler:chromium_code" ] |
120 configs += [ | 74 configs += [ |
121 "//build/config/compiler:no_chromium_code", | 75 "//build/config/compiler:no_chromium_code", |
122 ":cld2_warnings", | 76 ":cld2_warnings", |
123 ] | 77 ] |
124 } | 78 } |
125 | |
126 config("cld2_dynamic_mode_config") { | |
127 defines = [ "CLD2_DYNAMIC_MODE" ] | |
128 } | |
129 | |
130 static_library("cld2_dynamic") { | |
131 sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources + | |
132 gypi_values.cld2_dynamic_data_loader_sources | |
133 include_dirs = [ | |
134 "src/internal", | |
135 "src/public", | |
136 ] | |
137 | |
138 configs -= [ "//build/config/compiler:chromium_code" ] | |
139 configs += [ | |
140 ":cld2_dynamic_mode_config", | |
141 "//build/config/compiler:no_chromium_code", | |
142 ":cld2_warnings", | |
143 ] | |
144 } | |
145 | |
146 # Does not build on Windows, Android or iOS. | |
147 if (!is_win && !is_android && !is_ios) { | |
148 executable("cld_2_dynamic_data_tool") { | |
149 sources = [ | |
150 "src/internal/cld2_dynamic_data_extractor.cc", | |
151 "src/internal/cld2_dynamic_data_extractor.h", | |
152 "src/internal/cld2_dynamic_data_tool.cc", | |
153 ] | |
154 | |
155 include_dirs = [ | |
156 "src/internal", | |
157 "src/public", | |
158 ] | |
159 | |
160 deps = [ | |
161 ":cld2_data", | |
162 ":cld2_dynamic", | |
163 "//build/config/sanitizers:deps", | |
164 ] | |
165 | |
166 configs -= [ "//build/config/compiler:chromium_code" ] | |
167 configs += [ | |
168 ":cld2_dynamic_mode_config", | |
169 "//build/config/compiler:no_chromium_code", | |
170 ] | |
171 } | |
172 } | |
OLD | NEW |