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