Update V8 to version 4.6.22.
[chromium-blink-merge.git] / build / config / BUILD.gn
blob56a86e5932783d772e57bf1885f42cbe3ce961c0
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")
13 declare_args() {
14   # When set, turns off the (normally-on) iterator debugging and related stuff
15   # that is normally turned on for Debug builds. These are generally useful for
16   # catching bugs but in some cases may cause conflicts or excessive slowness.
17   disable_iterator_debugging = false
19   # Set to true to not store any build metadata, e.g. ifdef out all __DATE__
20   # and __TIME__. Set to 0 to reenable the use of these macros in the code
21   # base. See http://crbug.com/314403.
22   #
23   # Continue to embed build meta data in Official builds, basically the
24   # time it was built.
25   # TODO(maruel): This decision should be revisited because having an
26   # official deterministic build has high value too but MSVC toolset can't
27   # generate anything deterministic with WPO enabled AFAIK.
28   dont_embed_build_metadata = !is_official_build
30   # Set to true to enable dcheck in Release builds.
31   dcheck_always_on = false
33   # Set to true to compile with the OpenGL ES 2.0 conformance tests.
34   internal_gles2_conform_tests = false
37 # TODO(brettw) Most of these should be removed. Instead of global feature
38 # flags, we should have more modular flags that apply only to a target and its
39 # dependents. For example, depending on the "x11" meta-target should define
40 # USE_X11 for all dependents so that everything that could use X11 gets the
41 # define, but anything that doesn't depend on X11 doesn't see it.
43 # For now we define these globally to match the current GYP build.
44 config("feature_flags") {
45   # TODO(brettw) this probably needs to be parameterized.
46   defines = [ "V8_DEPRECATION_WARNINGS" ]  # Don't use deprecated V8 APIs anywhere.
48   if (cld_version > 0) {
49     defines += [ "CLD_VERSION=$cld_version" ]
50   }
51   if (enable_mdns) {
52     defines += [ "ENABLE_MDNS=1" ]
53   }
54   if (enable_notifications) {
55     defines += [ "ENABLE_NOTIFICATIONS" ]
56   }
57   if (enable_pepper_cdms) {
58     # TODO(brettw) should probably be "=1"
59     defines += [ "ENABLE_PEPPER_CDMS" ]
60   }
61   if (enable_browser_cdms) {
62     # TODO(brettw) should probably be "=1"
63     defines += [ "ENABLE_BROWSER_CDMS" ]
64   }
65   if (enable_plugins) {
66     defines += [ "ENABLE_PLUGINS=1" ]
67   }
68   if (enable_basic_printing || enable_print_preview) {
69     # Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
70     defines += [ "ENABLE_PRINTING=1" ]
71     if (enable_basic_printing) {
72       # Enable basic printing support and UI.
73       defines += [ "ENABLE_BASIC_PRINTING=1" ]
74     }
75     if (enable_print_preview) {
76       # Enable printing with print preview.
77       # Can be defined without ENABLE_BASIC_PRINTING.
78       defines += [ "ENABLE_PRINT_PREVIEW=1" ]
79     }
80   }
81   if (enable_spellcheck) {
82     defines += [ "ENABLE_SPELLCHECK=1" ]
83   }
84   if (use_platform_spellchecker) {
85     defines += [ "USE_PLATFORM_SPELLCHECKER=1" ]
86   }
87   if (dont_embed_build_metadata) {
88     defines += [ "DONT_EMBED_BUILD_METADATA" ]
89   }
90   if (dcheck_always_on) {
91     defines += [ "DCHECK_ALWAYS_ON=1" ]
92   }
93   if (use_udev) {
94     # TODO(brettw) should probably be "=1".
95     defines += [ "USE_UDEV" ]
96   }
97   if (ui_compositor_image_transport) {
98     # TODO(brettw) should probably be "=1".
99     defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ]
100   }
101   if (use_ash) {
102     defines += [ "USE_ASH=1" ]
103   }
104   if (use_aura) {
105     defines += [ "USE_AURA=1" ]
106   }
107   if (use_pango) {
108     defines += [ "USE_PANGO=1" ]
109   }
110   if (use_cairo) {
111     defines += [ "USE_CAIRO=1" ]
112   }
113   if (use_clipboard_aurax11) {
114     defines += [ "USE_CLIPBOARD_AURAX11=1" ]
115   }
116   if (use_default_render_theme) {
117     defines += [ "USE_DEFAULT_RENDER_THEME=1" ]
118   }
119   if (use_glib) {
120     defines += [ "USE_GLIB=1" ]
121   }
122   if (use_openssl) {
123     defines += [ "USE_OPENSSL=1" ]
124   }
125   if (use_openssl_certs) {
126     defines += [ "USE_OPENSSL_CERTS=1" ]
127   }
128   if (use_nss_certs) {
129     defines += [ "USE_NSS_CERTS=1" ]
130   }
131   if (use_ozone) {
132     defines += [ "USE_OZONE=1" ]
133   }
134   if (use_x11) {
135     defines += [ "USE_X11=1" ]
136   }
137   if (use_allocator != "tcmalloc") {
138     defines += [ "NO_TCMALLOC" ]
139   }
140   if (is_asan || is_lsan || is_tsan || is_msan) {
141     defines += [
142       "MEMORY_TOOL_REPLACES_ALLOCATOR",
143       "MEMORY_SANITIZER_INITIAL_SIZE",
144     ]
145   }
146   if (is_asan) {
147     defines += [ "ADDRESS_SANITIZER" ]
148   }
149   if (is_lsan) {
150     defines += [
151       "LEAK_SANITIZER",
152       "WTF_USE_LEAK_SANITIZER=1",
153     ]
154   }
155   if (is_tsan) {
156     defines += [
157       "THREAD_SANITIZER",
158       "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
159       "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
160     ]
161   }
162   if (is_msan) {
163     defines += [ "MEMORY_SANITIZER" ]
164   }
165   if (enable_webrtc) {
166     defines += [ "ENABLE_WEBRTC=1" ]
167   }
168   if (disable_ftp_support) {
169     defines += [ "DISABLE_FTP_SUPPORT=1" ]
170   }
171   if (!enable_nacl) {
172     defines += [ "DISABLE_NACL" ]
173   }
174   if (enable_extensions) {
175     defines += [ "ENABLE_EXTENSIONS=1" ]
176   }
177   if (enable_configuration_policy) {
178     defines += [ "ENABLE_CONFIGURATION_POLICY" ]
179   }
180   if (enable_task_manager) {
181     defines += [ "ENABLE_TASK_MANAGER=1" ]
182   }
183   if (enable_themes) {
184     defines += [ "ENABLE_THEMES=1" ]
185   }
186   if (enable_captive_portal_detection) {
187     defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
188   }
189   if (enable_session_service) {
190     defines += [ "ENABLE_SESSION_SERVICE=1" ]
191   }
192   if (enable_rlz) {
193     defines += [ "ENABLE_RLZ" ]
194   }
195   if (enable_plugin_installation) {
196     defines += [ "ENABLE_PLUGIN_INSTALLATION=1" ]
197   }
198   if (enable_app_list) {
199     defines += [ "ENABLE_APP_LIST=1" ]
200   }
201   if (enable_settings_app) {
202     defines += [ "ENABLE_SETTINGS_APP=1" ]
203   }
204   if (enable_supervised_users) {
205     defines += [ "ENABLE_SUPERVISED_USERS=1" ]
206   }
207   if (enable_service_discovery) {
208     defines += [ "ENABLE_SERVICE_DISCOVERY=1" ]
209   }
210   if (enable_autofill_dialog) {
211     defines += [ "ENABLE_AUTOFILL_DIALOG=1" ]
212   }
213   if (enable_wifi_bootstrapping) {
214     defines += [ "ENABLE_WIFI_BOOTSTRAPPING=1" ]
215   }
216   if (enable_image_loader_extension) {
217     defines += [ "IMAGE_LOADER_EXTENSION=1" ]
218   }
219   if (enable_remoting) {
220     defines += [ "ENABLE_REMOTING=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   }
288 # Debug/release ----------------------------------------------------------------
290 config("debug") {
291   defines = [
292     "_DEBUG",
293     "DYNAMIC_ANNOTATIONS_ENABLED=1",
294     "WTF_USE_DYNAMIC_ANNOTATIONS=1",
295   ]
297   if (is_nacl) {
298     defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
299   }
301   if (is_win) {
302     if (disable_iterator_debugging) {
303       # Iterator debugging is enabled by the compiler on debug builds, and we
304       # have to tell it to turn it off.
305       defines += [ "_HAS_ITERATOR_DEBUGGING=0" ]
306     }
307   } else if (is_linux && !is_android && current_cpu == "x64" &&
308              !disable_iterator_debugging) {
309     # Enable libstdc++ debugging facilities to help catch problems early, see
310     # http://crbug.com/65151 .
311     # TODO(phajdan.jr): Should we enable this for all of POSIX?
312     defines += [ "_GLIBCXX_DEBUG=1" ]
313   }
316 config("release") {
317   defines = [ "NDEBUG" ]
319   # Sanitizers.
320   # TODO(GYP) The GYP build has "release_valgrind_build == 0" for this
321   # condition. When Valgrind is set up, we need to do the same here.
322   if (is_tsan) {
323     defines += [
324       "DYNAMIC_ANNOTATIONS_ENABLED=1",
325       "WTF_USE_DYNAMIC_ANNOTATIONS=1",
326     ]
327   } else {
328     defines += [ "NVALGRIND" ]
329     if (!is_nacl) {
330       # NaCl always enables dynamic annotations. Currently this value is set to
331       # 1 for all .nexes.
332       defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
333     }
334   }
337 # Default libraries ------------------------------------------------------------
339 # This config defines the default libraries applied to all targets.
340 config("default_libs") {
341   if (is_win) {
342     # TODO(brettw) this list of defaults should probably be smaller, and
343     # instead the targets that use the less common ones (e.g. wininet or
344     # winspool) should include those explicitly.
345     libs = [
346       "advapi32.lib",
347       "comdlg32.lib",
348       "dbghelp.lib",
349       "delayimp.lib",
350       "dnsapi.lib",
351       "gdi32.lib",
352       "kernel32.lib",
353       "msimg32.lib",
354       "odbc32.lib",
355       "odbccp32.lib",
356       "ole32.lib",
357       "oleaut32.lib",
358       "psapi.lib",
359       "shell32.lib",
360       "shlwapi.lib",
361       "user32.lib",
362       "usp10.lib",
363       "uuid.lib",
364       "version.lib",
365       "wininet.lib",
366       "winmm.lib",
367       "winspool.lib",
368       "ws2_32.lib",
370       # Please don't add more stuff here. We should actually be making this
371       # list smaller, since all common things should be covered. If you need
372       # some extra libraries, please just add a libs = [ "foo.lib" ] to your
373       # target that needs it.
374     ]
375   } else if (is_android) {
376     # Android uses -nostdlib so we need to add even libc here.
377     libs = [
378       # TODO(brettw) write a version of this, hopefully we can express this
379       # without forking out to GCC just to get the library name. The android
380       # toolchain directory should probably be extracted into a .gni file that
381       # this file and the android toolchain .gn file can share.
382       #   # Manually link the libgcc.a that the cross compiler uses.
383       #   '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
384       "c",
385       "dl",
386       "m",
387     ]
388   } else if (is_mac) {
389     libs = [
390       "AppKit.framework",
391       "ApplicationServices.framework",
392       "Carbon.framework",
393       "CoreFoundation.framework",
394       "Foundation.framework",
395       "IOKit.framework",
396       "Security.framework",
397     ]
398   } else if (is_ios) {
399     libs = [
400       "CoreFoundation.framework",
401       "CoreGraphics.framework",
402       "CoreText.framework",
403       "Foundation.framework",
404       "UIKit.framework",
405     ]
406   } else if (is_linux) {
407     libs = [ "dl" ]
408   }
411 # Add this config to your target to enable precompiled headers.
413 # On Windows, precompiled headers are done on a per-target basis. If you have
414 # just a couple of files, the time it takes to precompile (~2 seconds) can
415 # actually be longer than the time saved. On a Z620, a 100 file target compiles
416 # about 2 seconds faster with precompiled headers, with greater savings for
417 # larger targets.
419 # Recommend precompiled headers for targets with more than 50 .cc files.
420 config("precompiled_headers") {
421   # TODO(brettw) enable this when GN support in the binary has been rolled.
422   #if (is_win) {
423   if (false) {
424     # This is a string rather than a file GN knows about. It has to match
425     # exactly what's in the /FI flag below, and what might appear in the source
426     # code in quotes for an #include directive.
427     precompiled_header = "build/precompile.h"
429     # This is a file that GN will compile with the above header. It will be
430     # implicitly added to the sources (potentially multiple times, with one
431     # variant for each language used in the target).
432     precompiled_source = "//build/precompile.cc"
434     # Force include the header.
435     cflags = [ "/FI$precompiled_header" ]
436   }