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 gypi_values = exec_script( | 7 gypi_values = exec_script("//build/gypi_to_gn.py", |
8 "//build/gypi_to_gn.py", | 8 [ rebase_path("cld_2.gyp") ], |
9 [ rebase_path("cld_2.gyp") ], | 9 "scope", |
10 "scope", | 10 [ "cld_2.gyp" ]) |
11 [ "cld_2.gyp" ]) | |
12 | 11 |
13 # This variable controls which dependency is resolved by the pass-through | 12 # This variable controls which dependency is resolved by the pass-through |
14 # target 'cld2_platform_impl', and allows the embedder to choose which | 13 # target 'cld2_platform_impl', and allows the embedder to choose which |
15 # kind of CLD2 support is required at build time: | 14 # kind of CLD2 support is required at build time: |
16 # | 15 # |
17 # - If the value is 'static', then the cld2_platform_impl target will depend | 16 # - If the value is 'static', then the cld2_platform_impl target will depend |
18 # upon the cld2_static target | 17 # upon the cld2_static target |
19 # - If the value is 'dynamic', then the cld2_platform_impl target will | 18 # - If the value is 'dynamic', then the cld2_platform_impl target will |
20 # depend upon the cld2_dynamic target. | 19 # depend upon the cld2_dynamic target. |
21 # | 20 # |
22 # High-level targets for Chromium unit tests hard-code a dependency upon | 21 # High-level targets for Chromium unit tests hard-code a dependency upon |
23 # cld2_static because doing so makes sense for use cases that aren't | 22 # cld2_static because doing so makes sense for use cases that aren't |
24 # affected by the loading of language detection data; however, most other | 23 # affected by the loading of language detection data; however, most other |
25 # targets (e.g. the final executables and interactive UI tests) should be | 24 # targets (e.g. the final executables and interactive UI tests) should be |
26 # linked against whatever the embedder needs. | 25 # linked against whatever the embedder needs. |
27 # | 26 # |
28 # Maintainers: | 27 # Maintainers: |
29 # This value may be reasonably tweaked on a per-platform basis. | 28 # This value may be reasonably tweaked on a per-platform basis. |
30 # Don't forget to update this file as well to match: | 29 # Don't forget to update this file as well to match: |
31 # components/translate/content/browser/browser_cld_utils.cc | 30 # components/translate/content/browser/browser_cld_utils.cc |
32 # components/translate/content/renderer/renderer_cld_utils.cc | 31 # components/translate/content/renderer/renderer_cld_utils.cc |
33 cld2_platform_support = "static" | 32 cld2_platform_support = "static" |
34 | 33 |
35 | |
36 cld2_table_size = 2 | 34 cld2_table_size = 2 |
37 | 35 |
38 source_set("cld2_data") { | 36 source_set("cld2_data") { |
39 sources = gypi_values.cld2_data_sources | 37 sources = gypi_values.cld2_data_sources |
40 if (cld2_table_size == 0) { | 38 if (cld2_table_size == 0) { |
41 sources += gypi_values.cld2_data_smallest_sources | 39 sources += gypi_values.cld2_data_smallest_sources |
42 } else if (cld2_table_size == 2) { | 40 } else if (cld2_table_size == 2) { |
43 sources += gypi_values.cld2_data_largest_sources | 41 sources += gypi_values.cld2_data_largest_sources |
44 } | 42 } |
45 | 43 |
46 include_dirs = [ | 44 include_dirs = [ |
47 "src/internal", | 45 "src/internal", |
48 "src/public", | 46 "src/public", |
49 ] | 47 ] |
50 | 48 |
51 configs -= [ "//build/config/compiler:chromium_code" ] | 49 configs -= [ "//build/config/compiler:chromium_code" ] |
52 configs += [ "//build/config/compiler:no_chromium_code" ] | 50 configs += [ "//build/config/compiler:no_chromium_code" ] |
53 | 51 |
54 if (is_win) { | 52 if (is_win) { |
55 cflags = [ "/wd4267" ] # size_t -> int conversion. | 53 cflags = [ "/wd4267" ] # size_t -> int conversion. |
56 } | 54 } |
57 } | 55 } |
58 | 56 |
59 # As in the corresponding gyp file, this just builds the core interfaces for | 57 # As in the corresponding gyp file, this just builds the core interfaces for |
60 # CLD2. You must still declare a dependency on a specific data set, either | 58 # CLD2. You must still declare a dependency on a specific data set, either |
61 # cld2_dynamic or cld2_static. | 59 # cld2_dynamic or cld2_static. |
62 source_set("cld_2") { | 60 source_set("cld_2") { |
63 sources = gypi_values.cld2_core_sources | 61 sources = gypi_values.cld2_core_sources |
64 include_dirs = [ | 62 include_dirs = [ |
65 "src/internal", | 63 "src/internal", |
66 "src/public", | 64 "src/public", |
67 ] | 65 ] |
68 | 66 |
69 configs -= [ "//build/config/compiler:chromium_code" ] | 67 configs -= [ "//build/config/compiler:chromium_code" ] |
70 configs += [ "//build/config/compiler:no_chromium_code" ] | 68 configs += [ "//build/config/compiler:no_chromium_code" ] |
71 | 69 |
72 if (is_win) { | 70 if (is_win) { |
73 cflags = [ "/wd4267" ] # size_t -> int conversion. | 71 cflags = [ "/wd4267" ] # size_t -> int conversion. |
74 } | 72 } |
75 } | 73 } |
76 | 74 |
77 | |
78 source_set("cld2_platform_impl") { | 75 source_set("cld2_platform_impl") { |
79 deps = [] | 76 deps = [] |
80 if (cld2_platform_support == "static") { | 77 if (cld2_platform_support == "static") { |
81 deps += [ ":cld2_static" ] | 78 deps += [ ":cld2_static" ] |
82 } else if (cld2_platform_support == "dynamic") { | 79 } else if (cld2_platform_support == "dynamic") { |
83 deps += [ ":cld2_dynamic" ] | 80 deps += [ ":cld2_dynamic" ] |
84 } | 81 } |
85 } | 82 } |
86 | 83 |
87 static_library("cld2_static") { | 84 static_library("cld2_static") { |
88 sources = gypi_values.cld2_core_impl_sources | 85 sources = gypi_values.cld2_core_impl_sources |
89 include_dirs = [ | 86 include_dirs = [ |
90 "src/internal", | 87 "src/internal", |
91 "src/public", | 88 "src/public", |
92 ] | 89 ] |
93 | 90 |
94 deps = [ ":cld_2", ":cld2_data" ] | 91 deps = [ |
| 92 ":cld_2", |
| 93 ":cld2_data", |
| 94 ] |
95 configs -= [ "//build/config/compiler:chromium_code" ] | 95 configs -= [ "//build/config/compiler:chromium_code" ] |
96 configs += [ "//build/config/compiler:no_chromium_code" ] | 96 configs += [ "//build/config/compiler:no_chromium_code" ] |
97 | 97 |
98 if (is_win) { | 98 if (is_win) { |
99 cflags = [ "/wd4267" ] # size_t -> int conversion. | 99 cflags = [ "/wd4267" ] # size_t -> int conversion. |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 config("cld2_dynamic_mode_config") { | 103 config("cld2_dynamic_mode_config") { |
104 defines = [ "CLD2_DYNAMIC_MODE" ] | 104 defines = [ "CLD2_DYNAMIC_MODE" ] |
105 } | 105 } |
106 | 106 |
107 static_library("cld2_dynamic") { | 107 static_library("cld2_dynamic") { |
108 sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources +
gypi_values.cld2_dynamic_data_loader_sources | 108 sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources + |
| 109 gypi_values.cld2_dynamic_data_loader_sources |
109 include_dirs = [ | 110 include_dirs = [ |
110 "src/internal", | 111 "src/internal", |
111 "src/public", | 112 "src/public", |
112 ] | 113 ] |
113 | 114 |
114 configs -= [ "//build/config/compiler:chromium_code" ] | 115 configs -= [ "//build/config/compiler:chromium_code" ] |
115 configs += [ "//build/config/compiler:no_chromium_code", ":cld2_dynamic_mode_c
onfig" ] | 116 configs += [ |
| 117 "//build/config/compiler:no_chromium_code", |
| 118 ":cld2_dynamic_mode_config", |
| 119 ] |
116 | 120 |
117 if (is_win) { | 121 if (is_win) { |
118 cflags = [ "/wd4267" ] # size_t -> int conversion. | 122 cflags = [ "/wd4267" ] # size_t -> int conversion. |
119 } | 123 } |
120 } | 124 } |
121 | 125 |
122 # Does not build on Windows. | 126 # Does not build on Windows. |
123 if (!is_win) { | 127 if (!is_win) { |
124 executable("cld_2_dynamic_data_tool") { | 128 executable("cld_2_dynamic_data_tool") { |
125 sources = [ | 129 sources = [ |
126 "src/internal/cld2_dynamic_data_extractor.h", | 130 "src/internal/cld2_dynamic_data_extractor.h", |
127 "src/internal/cld2_dynamic_data_extractor.cc", | 131 "src/internal/cld2_dynamic_data_extractor.cc", |
128 "src/internal/cld2_dynamic_data_tool.cc", | 132 "src/internal/cld2_dynamic_data_tool.cc", |
129 ] | 133 ] |
130 | 134 |
131 include_dirs = [ | 135 include_dirs = [ |
132 "src/internal", | 136 "src/internal", |
133 "src/public", | 137 "src/public", |
134 ] | 138 ] |
135 | 139 |
136 deps = [ ":cld2_data", ":cld2_dynamic" ] | 140 deps = [ |
| 141 ":cld2_data", |
| 142 ":cld2_dynamic", |
| 143 ] |
137 | 144 |
138 configs -= [ "//build/config/compiler:chromium_code" ] | 145 configs -= [ "//build/config/compiler:chromium_code" ] |
139 configs += [ "//build/config/compiler:no_chromium_code", ":cld2_dynamic_mode
_config" ] | 146 configs += [ |
| 147 "//build/config/compiler:no_chromium_code", |
| 148 ":cld2_dynamic_mode_config", |
| 149 ] |
140 | 150 |
141 if (is_win) { | 151 if (is_win) { |
142 cflags = [ "/wd4267" ] # size_t -> int conversion. | 152 cflags = [ "/wd4267" ] # size_t -> int conversion. |
143 } | 153 } |
144 } | 154 } |
145 } | 155 } |
OLD | NEW |