hunspell: Cleanup to fix the header include guards under google/ directory.
[chromium-blink-merge.git] / build / config / BUILD.gn
blob278baec69a0544f76b20f6844dade8d78a80de0e
1 # Copyright (c) 2013 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/allocator.gni")
6 import("//build/config/chrome_build.gni")
7 import("//build/config/crypto.gni")
8 import("//build/config/features.gni")
9 import("//build/config/sanitizers/sanitizers.gni")
10 import("//build/config/ui.gni")
11 import("//build/module_args/v8.gni")
12 import("//build/toolchain/goma.gni")
14 declare_args() {
15   # When set (the default) enables C++ iterator debugging in debug builds.
16   # Iterator debugging is always off in release builds (technically, this flag
17   # affects the "debug" config, which is always available but applied by
18   # default only in debug builds).
19   #
20   # Iterator debugging is generally useful for catching bugs. But it can
21   # introduce extra locking to check the state of an iterator against the state
22   # of the current object. For iterator- and thread-heavy code, this can
23   # significantly slow execution.
24   enable_iterator_debugging = true
26   # Set to true to not store any build metadata, e.g. ifdef out all __DATE__
27   # and __TIME__. Set to 0 to reenable the use of these macros in the code
28   # base. See http://crbug.com/314403.
29   #
30   # Continue to embed build meta data in Official builds, basically the
31   # time it was built.
32   # TODO(maruel): This decision should be revisited because having an
33   # official deterministic build has high value too but MSVC toolset can't
34   # generate anything deterministic with WPO enabled AFAIK.
35   dont_embed_build_metadata = !is_official_build
37   # Set to true to enable dcheck in Release builds.
38   dcheck_always_on = false
41 # TODO(brettw) Most of these should be removed. Instead of global feature
42 # flags, we should have more modular flags that apply only to a target and its
43 # dependents. For example, depending on the "x11" meta-target should define
44 # USE_X11 for all dependents so that everything that could use X11 gets the
45 # define, but anything that doesn't depend on X11 doesn't see it.
47 # For now we define these globally to match the current GYP build.
48 config("feature_flags") {
49   # TODO(brettw) this probably needs to be parameterized.
50   defines = [
51     "V8_DEPRECATION_WARNINGS",  # Don't use deprecated V8 APIs anywhere.
52     "CLD_VERSION=$cld_version",
53   ]
54   if (enable_mdns) {
55     defines += [ "ENABLE_MDNS=1" ]
56   }
57   if (enable_notifications) {
58     defines += [ "ENABLE_NOTIFICATIONS" ]
59   }
60   if (enable_pepper_cdms) {
61     # TODO(brettw) should probably be "=1"
62     defines += [ "ENABLE_PEPPER_CDMS" ]
63   }
64   if (enable_browser_cdms) {
65     # TODO(brettw) should probably be "=1"
66     defines += [ "ENABLE_BROWSER_CDMS" ]
67   }
68   if (enable_plugins) {
69     defines += [ "ENABLE_PLUGINS=1" ]
70   }
71   if (enable_basic_printing || enable_print_preview) {
72     # Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
73     defines += [ "ENABLE_PRINTING=1" ]
74     if (enable_basic_printing) {
75       # Enable basic printing support and UI.
76       defines += [ "ENABLE_BASIC_PRINTING=1" ]
77     }
78     if (enable_print_preview) {
79       # Enable printing with print preview.
80       # Can be defined without ENABLE_BASIC_PRINTING.
81       defines += [ "ENABLE_PRINT_PREVIEW=1" ]
82     }
83   }
84   if (enable_spellcheck) {
85     defines += [ "ENABLE_SPELLCHECK=1" ]
86   }
87   if (use_browser_spellchecker) {
88     defines += [ "USE_BROWSER_SPELLCHECKER=1" ]
89   }
90   if (dont_embed_build_metadata) {
91     defines += [ "DONT_EMBED_BUILD_METADATA" ]
92   }
93   if (dcheck_always_on) {
94     defines += [ "DCHECK_ALWAYS_ON=1" ]
95   }
96   if (use_udev) {
97     # TODO(brettw) should probably be "=1".
98     defines += [ "USE_UDEV" ]
99   }
100   if (ui_compositor_image_transport) {
101     # TODO(brettw) should probably be "=1".
102     defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ]
103   }
104   if (use_ash) {
105     defines += [ "USE_ASH=1" ]
106   }
107   if (use_aura) {
108     defines += [ "USE_AURA=1" ]
109   }
110   if (use_pango) {
111     defines += [ "USE_PANGO=1" ]
112   }
113   if (use_cairo) {
114     defines += [ "USE_CAIRO=1" ]
115   }
116   if (use_clipboard_aurax11) {
117     defines += [ "USE_CLIPBOARD_AURAX11=1" ]
118   }
119   if (use_default_render_theme) {
120     defines += [ "USE_DEFAULT_RENDER_THEME=1" ]
121   }
122   if (use_glib) {
123     defines += [ "USE_GLIB=1" ]
124   }
125   if (use_openssl) {
126     defines += [ "USE_OPENSSL=1" ]
127   }
128   if (use_openssl_certs) {
129     defines += [ "USE_OPENSSL_CERTS=1" ]
130   }
131   if (use_nss_certs) {
132     defines += [ "USE_NSS_CERTS=1" ]
133   }
134   if (use_ozone) {
135     defines += [ "USE_OZONE=1" ]
136   }
137   if (use_x11) {
138     defines += [ "USE_X11=1" ]
139   }
140   if (use_allocator != "tcmalloc") {
141     defines += [ "NO_TCMALLOC" ]
142   }
143   if (is_asan || is_lsan || is_tsan || is_msan) {
144     defines += [
145       "MEMORY_TOOL_REPLACES_ALLOCATOR",
146       "MEMORY_SANITIZER_INITIAL_SIZE",
147     ]
148   }
149   if (is_asan) {
150     defines += [ "ADDRESS_SANITIZER" ]
151   }
152   if (is_lsan) {
153     defines += [
154       "LEAK_SANITIZER",
155       "WTF_USE_LEAK_SANITIZER=1",
156     ]
157   }
158   if (is_tsan) {
159     defines += [
160       "THREAD_SANITIZER",
161       "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
162       "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
163     ]
164   }
165   if (is_msan) {
166     defines += [ "MEMORY_SANITIZER" ]
167   }
168   if (enable_webrtc) {
169     defines += [ "ENABLE_WEBRTC=1" ]
170   }
171   if (disable_ftp_support) {
172     defines += [ "DISABLE_FTP_SUPPORT=1" ]
173   }
174   if (!enable_nacl) {
175     defines += [ "DISABLE_NACL" ]
176   }
177   if (enable_extensions) {
178     defines += [ "ENABLE_EXTENSIONS=1" ]
179   }
180   if (enable_configuration_policy) {
181     defines += [ "ENABLE_CONFIGURATION_POLICY" ]
182   }
183   if (enable_task_manager) {
184     defines += [ "ENABLE_TASK_MANAGER=1" ]
185   }
186   if (enable_themes) {
187     defines += [ "ENABLE_THEMES=1" ]
188   }
189   if (enable_captive_portal_detection) {
190     defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
191   }
192   if (enable_session_service) {
193     defines += [ "ENABLE_SESSION_SERVICE=1" ]
194   }
195   if (enable_rlz) {
196     defines += [ "ENABLE_RLZ" ]
197   }
198   if (enable_plugin_installation) {
199     defines += [ "ENABLE_PLUGIN_INSTALLATION=1" ]
200   }
201   if (enable_app_list) {
202     defines += [ "ENABLE_APP_LIST=1" ]
203   }
204   if (enable_settings_app) {
205     defines += [ "ENABLE_SETTINGS_APP=1" ]
206   }
207   if (enable_supervised_users) {
208     defines += [ "ENABLE_SUPERVISED_USERS=1" ]
209   }
210   if (enable_service_discovery) {
211     defines += [ "ENABLE_SERVICE_DISCOVERY=1" ]
212   }
213   if (enable_autofill_dialog) {
214     defines += [ "ENABLE_AUTOFILL_DIALOG=1" ]
215   }
216   if (enable_wifi_bootstrapping) {
217     defines += [ "ENABLE_WIFI_BOOTSTRAPPING=1" ]
218   }
219   if (enable_image_loader_extension) {
220     defines += [ "IMAGE_LOADER_EXTENSION=1" ]
221   }
222   if (enable_google_now) {
223     defines += [ "ENABLE_GOOGLE_NOW=1" ]
224   }
225   if (enable_one_click_signin) {
226     defines += [ "ENABLE_ONE_CLICK_SIGNIN" ]
227   }
228   if (enable_hidpi) {
229     defines += [ "ENABLE_HIDPI=1" ]
230   }
231   if (enable_topchrome_md) {
232     defines += [ "ENABLE_TOPCHROME_MD=1" ]
233   }
234   if (proprietary_codecs) {
235     defines += [ "USE_PROPRIETARY_CODECS" ]
236   }
237   if (enable_hangout_services_extension) {
238     defines += [ "ENABLE_HANGOUT_SERVICES_EXTENSION=1" ]
239   }
240   if (v8_use_external_startup_data) {
241     defines += [ "V8_USE_EXTERNAL_STARTUP_DATA" ]
242   }
243   if (enable_background) {
244     defines += [ "ENABLE_BACKGROUND=1" ]
245   }
246   if (enable_pre_sync_backup) {
247     defines += [ "ENABLE_PRE_SYNC_BACKUP" ]
248   }
249   if (enable_video_hole) {
250     defines += [ "VIDEO_HOLE=1" ]
251   }
252   if (safe_browsing_mode == 1) {
253     defines += [ "FULL_SAFE_BROWSING" ]
254     defines += [ "SAFE_BROWSING_CSD" ]
255     defines += [ "SAFE_BROWSING_DB_LOCAL" ]
256     defines += [ "SAFE_BROWSING_SERVICE" ]
257   } else if (safe_browsing_mode == 2) {
258     defines += [ "MOBILE_SAFE_BROWSING" ]
259     defines += [ "SAFE_BROWSING_SERVICE" ]
260   } else if (safe_browsing_mode == 3) {
261     defines += [ "MOBILE_SAFE_BROWSING" ]
262     defines += [ "SAFE_BROWSING_DB_REMOTE" ]
263     defines += [ "SAFE_BROWSING_SERVICE" ]
264   }
265   if (is_official_build) {
266     defines += [ "OFFICIAL_BUILD" ]
267   }
268   if (is_chrome_branded) {
269     defines += [ "GOOGLE_CHROME_BUILD" ]
270   } else {
271     defines += [ "CHROMIUM_BUILD" ]
272   }
273   if (enable_media_router) {
274     defines += [ "ENABLE_MEDIA_ROUTER=1" ]
275   }
276   if (enable_webvr) {
277     defines += [ "ENABLE_WEBVR" ]
278   }
279   if (is_syzyasan) {
280     defines += [
281       "SYZYASAN",
282       "MEMORY_TOOL_REPLACES_ALLOCATOR",
283       "MEMORY_SANITIZER_INITIAL_SIZE",
284     ]
285   }
286   if (!fieldtrial_testing_like_official_build && !is_chrome_branded) {
287     defines += [ "FIELDTRIAL_TESTING_ENABLED" ]
288   }
291 # Debug/release ----------------------------------------------------------------
293 config("debug") {
294   defines = [
295     "_DEBUG",
296     "DYNAMIC_ANNOTATIONS_ENABLED=1",
297     "WTF_USE_DYNAMIC_ANNOTATIONS=1",
298   ]
300   if (is_nacl) {
301     defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
302   }
304   if (is_win) {
305     if (!enable_iterator_debugging) {
306       # Iterator debugging is enabled by default by the compiler on debug
307       # builds, and we have to tell it to turn it off.
308       defines += [ "_HAS_ITERATOR_DEBUGGING=0" ]
309     }
310   } else if (is_linux && current_cpu == "x64" && enable_iterator_debugging) {
311     # Enable libstdc++ debugging facilities to help catch problems early, see
312     # http://crbug.com/65151 .
313     # TODO(phajdan.jr): Should we enable this for all of POSIX?
314     defines += [ "_GLIBCXX_DEBUG=1" ]
315   }
318 config("release") {
319   defines = [ "NDEBUG" ]
321   # Sanitizers.
322   # TODO(GYP) The GYP build has "release_valgrind_build == 0" for this
323   # condition. When Valgrind is set up, we need to do the same here.
324   if (is_tsan) {
325     defines += [
326       "DYNAMIC_ANNOTATIONS_ENABLED=1",
327       "WTF_USE_DYNAMIC_ANNOTATIONS=1",
328     ]
329   } else {
330     defines += [ "NVALGRIND" ]
331     if (!is_nacl) {
332       # NaCl always enables dynamic annotations. Currently this value is set to
333       # 1 for all .nexes.
334       defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
335     }
336   }
339 # Default libraries ------------------------------------------------------------
341 # This config defines the default libraries applied to all targets.
342 config("default_libs") {
343   if (is_win) {
344     # TODO(brettw) this list of defaults should probably be smaller, and
345     # instead the targets that use the less common ones (e.g. wininet or
346     # winspool) should include those explicitly.
347     libs = [
348       "advapi32.lib",
349       "comdlg32.lib",
350       "dbghelp.lib",
351       "delayimp.lib",
352       "dnsapi.lib",
353       "gdi32.lib",
354       "kernel32.lib",
355       "msimg32.lib",
356       "odbc32.lib",
357       "odbccp32.lib",
358       "ole32.lib",
359       "oleaut32.lib",
360       "psapi.lib",
361       "shell32.lib",
362       "shlwapi.lib",
363       "user32.lib",
364       "usp10.lib",
365       "uuid.lib",
366       "version.lib",
367       "wininet.lib",
368       "winmm.lib",
369       "winspool.lib",
370       "ws2_32.lib",
372       # Please don't add more stuff here. We should actually be making this
373       # list smaller, since all common things should be covered. If you need
374       # some extra libraries, please just add a libs = [ "foo.lib" ] to your
375       # target that needs it.
376     ]
377   } else if (is_android) {
378     # Android uses -nostdlib so we need to add even libc here.
379     libs = [
380       # TODO(brettw) write a version of this, hopefully we can express this
381       # without forking out to GCC just to get the library name. The android
382       # toolchain directory should probably be extracted into a .gni file that
383       # this file and the android toolchain .gn file can share.
384       #   # Manually link the libgcc.a that the cross compiler uses.
385       #   '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
386       "c",
387       "dl",
388       "m",
389     ]
390   } else if (is_mac) {
391     libs = [
392       "AppKit.framework",
393       "ApplicationServices.framework",
394       "Carbon.framework",
395       "CoreFoundation.framework",
396       "Foundation.framework",
397       "IOKit.framework",
398       "OpenGL.framework",
399       "Security.framework",
400     ]
401   } else if (is_ios) {
402     # The libraries listed here will be specified for both the target and the
403     # host. Only the common ones should be listed here.
404     libs = [
405       "CoreFoundation.framework",
406       "CoreGraphics.framework",
407       "CoreText.framework",
408       "Foundation.framework",
409     ]
410   } else if (is_linux) {
411     libs = [ "dl" ]
412   }
415 # Add this config to your target to enable precompiled headers.
417 # On Windows, precompiled headers are done on a per-target basis. If you have
418 # just a couple of files, the time it takes to precompile (~2 seconds) can
419 # actually be longer than the time saved. On a Z620, a 100 file target compiles
420 # about 2 seconds faster with precompiled headers, with greater savings for
421 # larger targets.
423 # Recommend precompiled headers for targets with more than 50 .cc files.
424 config("precompiled_headers") {
425   if (is_win && !is_official_build && !use_goma) {
426     # This is a string rather than a file GN knows about. It has to match
427     # exactly what's in the /FI flag below, and what might appear in the source
428     # code in quotes for an #include directive.
429     precompiled_header = "build/precompile.h"
431     # This is a file that GN will compile with the above header. It will be
432     # implicitly added to the sources (potentially multiple times, with one
433     # variant for each language used in the target).
434     precompiled_source = "//build/precompile.cc"
436     # Force include the header.
437     cflags = [ "/FI$precompiled_header" ]
439     # Disable warning for "this file was empty after preprocessing". This
440     # error is generated only in C mode for ANSI compatibility. It conflicts
441     # with precompiled headers since the source file that's "compiled" for
442     # making the precompiled header is empty.
443     #
444     # This error doesn't happen every time. In VS2013, it seems if the .pch
445     # file doesn't exist, no error will be generated (probably MS tested this
446     # case but forgot the other one?). To reproduce this error, do a build,
447     # then delete the precompile.c.obj file, then build again.
448     cflags_c = [ "/wd4206" ]
449   }