Roll src/third_party/WebKit 318ad17:e6ddb0d (svn 202527:202532)
[chromium-blink-merge.git] / third_party / cld_2 / BUILD.gn
blobbd3a181e5d7d33c17aede02de7795cd4dd2325c6
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.
5 import("//build/config/features.gni")
7 gypi_values = exec_script("//build/gypi_to_gn.py",
8                           [ rebase_path("cld_2.gyp") ],
9                           "scope",
10                           [ "cld_2.gyp" ])
12 # This variable controls which dependency is resolved by the pass-through
13 # target 'cld2_platform_impl', and allows the embedder to choose which
14 # kind of CLD2 support is required at build time:
16 # - If the value is 'static', then the cld2_platform_impl target will depend
17 #   upon the cld2_static target
18 # - If the value is 'dynamic', then the cld2_platform_impl target will
19 #   depend upon the cld2_dynamic target.
21 # High-level targets for Chromium unit tests hard-code a dependency upon
22 # cld2_static because doing so makes sense for use cases that aren't
23 # affected by the loading of language detection data; however, most other
24 # targets (e.g. the final executables and interactive UI tests) should be
25 # linked against whatever the embedder needs.
27 # Maintainers:
28 # This value may be reasonably tweaked on a per-platform basis.
29 # Don't forget to update this file as well to match:
30 #   components/translate/content/browser/browser_cld_utils.cc
31 #   components/translate/content/renderer/renderer_cld_utils.cc
32 cld2_platform_support = "static"
34 cld2_table_size = 2
36 config("cld2_data_warnings") {
37   visibility = [ ":*" ]
38   if (is_clang) {
39     # The generated files don't have braces around subobject initializers.
40     cflags = [ "-Wno-missing-braces" ]
41   }
44 source_set("cld2_data") {
45   sources = gypi_values.cld2_data_sources
46   if (cld2_table_size == 0) {
47     sources += gypi_values.cld2_data_smallest_sources
48   } else if (cld2_table_size == 2) {
49     sources += gypi_values.cld2_data_largest_sources
50   }
52   include_dirs = [
53     "src/internal",
54     "src/public",
55   ]
57   configs -= [ "//build/config/compiler:chromium_code" ]
58   configs += [
59     "//build/config/compiler:no_chromium_code",
61     # Must be after no_chromium_code for warning flags to be ordered correctly.
62     ":cld2_data_warnings",
63   ]
66 # As in the corresponding gyp file, this just builds the core interfaces for
67 # CLD2. You must still declare a dependency on a specific data set, either
68 # cld2_dynamic or cld2_static.
69 source_set("cld_2") {
70   sources = gypi_values.cld2_core_sources
71   include_dirs = [
72     "src/internal",
73     "src/public",
74   ]
76   configs -= [ "//build/config/compiler:chromium_code" ]
77   configs += [ "//build/config/compiler:no_chromium_code" ]
80 source_set("cld2_platform_impl") {
81   deps = []
82   if (cld2_platform_support == "static") {
83     deps += [ ":cld2_static" ]
84   } else if (cld2_platform_support == "dynamic") {
85     deps += [ ":cld2_dynamic" ]
86   }
89 config("cld2_warnings") {
90   if (is_clang) {
91     cflags = [
92       # cld_2 contains unused private fields.
93       # https://code.google.com/p/cld2/issues/detail?id=37
94       "-Wno-unused-private-field",
95     ]
96   }
99 static_library("cld2_static") {
100   sources = gypi_values.cld2_core_impl_sources
101   include_dirs = [
102     "src/internal",
103     "src/public",
104   ]
106   deps = [
107     ":cld_2",
108     ":cld2_data",
109   ]
110   configs -= [ "//build/config/compiler:chromium_code" ]
111   configs += [
112     "//build/config/compiler:no_chromium_code",
113     ":cld2_warnings",
114   ]
117 config("cld2_dynamic_mode_config") {
118   defines = [ "CLD2_DYNAMIC_MODE" ]
121 static_library("cld2_dynamic") {
122   sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources +
123             gypi_values.cld2_dynamic_data_loader_sources
124   include_dirs = [
125     "src/internal",
126     "src/public",
127   ]
129   configs -= [ "//build/config/compiler:chromium_code" ]
130   configs += [
131     ":cld2_dynamic_mode_config",
132     "//build/config/compiler:no_chromium_code",
133     ":cld2_warnings",
134   ]
137 # Does not build on Windows.
138 if (!is_win) {
139   executable("cld_2_dynamic_data_tool") {
140     sources = [
141       "src/internal/cld2_dynamic_data_extractor.cc",
142       "src/internal/cld2_dynamic_data_extractor.h",
143       "src/internal/cld2_dynamic_data_tool.cc",
144     ]
146     include_dirs = [
147       "src/internal",
148       "src/public",
149     ]
151     deps = [
152       ":cld2_data",
153       ":cld2_dynamic",
154       "//build/config/sanitizers:deps",
155     ]
157     configs -= [ "//build/config/compiler:chromium_code" ]
158     configs += [
159       ":cld2_dynamic_mode_config",
160       "//build/config/compiler:no_chromium_code",
161     ]
162   }