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")
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).
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.
30 # Continue to embed build meta data in Official builds, basically the
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.
51 "V8_DEPRECATION_WARNINGS", # Don't use deprecated V8 APIs anywhere.
52 "CLD_VERSION=$cld_version",
55 defines += [ "ENABLE_MDNS=1" ]
57 if (enable_notifications) {
58 defines += [ "ENABLE_NOTIFICATIONS" ]
60 if (enable_pepper_cdms) {
61 # TODO(brettw) should probably be "=1"
62 defines += [ "ENABLE_PEPPER_CDMS" ]
64 if (enable_browser_cdms) {
65 # TODO(brettw) should probably be "=1"
66 defines += [ "ENABLE_BROWSER_CDMS" ]
69 defines += [ "ENABLE_PLUGINS=1" ]
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" ]
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" ]
84 if (enable_spellcheck) {
85 defines += [ "ENABLE_SPELLCHECK=1" ]
87 if (use_browser_spellchecker) {
88 defines += [ "USE_BROWSER_SPELLCHECKER=1" ]
90 if (dont_embed_build_metadata) {
91 defines += [ "DONT_EMBED_BUILD_METADATA" ]
93 if (dcheck_always_on) {
94 defines += [ "DCHECK_ALWAYS_ON=1" ]
97 # TODO(brettw) should probably be "=1".
98 defines += [ "USE_UDEV" ]
100 if (ui_compositor_image_transport) {
101 # TODO(brettw) should probably be "=1".
102 defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ]
105 defines += [ "USE_ASH=1" ]
108 defines += [ "USE_AURA=1" ]
111 defines += [ "USE_PANGO=1" ]
114 defines += [ "USE_CAIRO=1" ]
116 if (use_clipboard_aurax11) {
117 defines += [ "USE_CLIPBOARD_AURAX11=1" ]
119 if (use_default_render_theme) {
120 defines += [ "USE_DEFAULT_RENDER_THEME=1" ]
123 defines += [ "USE_GLIB=1" ]
126 defines += [ "USE_OPENSSL=1" ]
128 if (use_openssl_certs) {
129 defines += [ "USE_OPENSSL_CERTS=1" ]
132 defines += [ "USE_NSS_CERTS=1" ]
135 defines += [ "USE_OZONE=1" ]
138 defines += [ "USE_X11=1" ]
140 if (use_allocator != "tcmalloc") {
141 defines += [ "NO_TCMALLOC" ]
143 if (is_asan || is_lsan || is_tsan || is_msan) {
145 "MEMORY_TOOL_REPLACES_ALLOCATOR",
146 "MEMORY_SANITIZER_INITIAL_SIZE",
150 defines += [ "ADDRESS_SANITIZER" ]
155 "WTF_USE_LEAK_SANITIZER=1",
161 "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
162 "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
166 defines += [ "MEMORY_SANITIZER" ]
169 defines += [ "ENABLE_WEBRTC=1" ]
171 if (disable_ftp_support) {
172 defines += [ "DISABLE_FTP_SUPPORT=1" ]
175 defines += [ "DISABLE_NACL" ]
177 if (enable_extensions) {
178 defines += [ "ENABLE_EXTENSIONS=1" ]
180 if (enable_configuration_policy) {
181 defines += [ "ENABLE_CONFIGURATION_POLICY" ]
183 if (enable_task_manager) {
184 defines += [ "ENABLE_TASK_MANAGER=1" ]
187 defines += [ "ENABLE_THEMES=1" ]
189 if (enable_captive_portal_detection) {
190 defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
192 if (enable_session_service) {
193 defines += [ "ENABLE_SESSION_SERVICE=1" ]
196 defines += [ "ENABLE_RLZ" ]
198 if (enable_plugin_installation) {
199 defines += [ "ENABLE_PLUGIN_INSTALLATION=1" ]
201 if (enable_app_list) {
202 defines += [ "ENABLE_APP_LIST=1" ]
204 if (enable_settings_app) {
205 defines += [ "ENABLE_SETTINGS_APP=1" ]
207 if (enable_supervised_users) {
208 defines += [ "ENABLE_SUPERVISED_USERS=1" ]
210 if (enable_service_discovery) {
211 defines += [ "ENABLE_SERVICE_DISCOVERY=1" ]
213 if (enable_autofill_dialog) {
214 defines += [ "ENABLE_AUTOFILL_DIALOG=1" ]
216 if (enable_wifi_bootstrapping) {
217 defines += [ "ENABLE_WIFI_BOOTSTRAPPING=1" ]
219 if (enable_image_loader_extension) {
220 defines += [ "IMAGE_LOADER_EXTENSION=1" ]
222 if (enable_google_now) {
223 defines += [ "ENABLE_GOOGLE_NOW=1" ]
225 if (enable_one_click_signin) {
226 defines += [ "ENABLE_ONE_CLICK_SIGNIN" ]
229 defines += [ "ENABLE_HIDPI=1" ]
231 if (enable_topchrome_md) {
232 defines += [ "ENABLE_TOPCHROME_MD=1" ]
234 if (proprietary_codecs) {
235 defines += [ "USE_PROPRIETARY_CODECS" ]
237 if (enable_hangout_services_extension) {
238 defines += [ "ENABLE_HANGOUT_SERVICES_EXTENSION=1" ]
240 if (v8_use_external_startup_data) {
241 defines += [ "V8_USE_EXTERNAL_STARTUP_DATA" ]
243 if (enable_background) {
244 defines += [ "ENABLE_BACKGROUND=1" ]
246 if (enable_pre_sync_backup) {
247 defines += [ "ENABLE_PRE_SYNC_BACKUP" ]
249 if (enable_video_hole) {
250 defines += [ "VIDEO_HOLE=1" ]
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" ]
265 if (is_official_build) {
266 defines += [ "OFFICIAL_BUILD" ]
268 if (is_chrome_branded) {
269 defines += [ "GOOGLE_CHROME_BUILD" ]
271 defines += [ "CHROMIUM_BUILD" ]
273 if (enable_media_router) {
274 defines += [ "ENABLE_MEDIA_ROUTER=1" ]
277 defines += [ "ENABLE_WEBVR" ]
282 "MEMORY_TOOL_REPLACES_ALLOCATOR",
283 "MEMORY_SANITIZER_INITIAL_SIZE",
286 if (!fieldtrial_testing_like_official_build && !is_chrome_branded) {
287 defines += [ "FIELDTRIAL_TESTING_ENABLED" ]
291 # Debug/release ----------------------------------------------------------------
296 "DYNAMIC_ANNOTATIONS_ENABLED=1",
297 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
301 defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
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" ]
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" ]
319 defines = [ "NDEBUG" ]
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.
326 "DYNAMIC_ANNOTATIONS_ENABLED=1",
327 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
330 defines += [ "NVALGRIND" ]
332 # NaCl always enables dynamic annotations. Currently this value is set to
334 defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
339 # Default libraries ------------------------------------------------------------
341 # This config defines the default libraries applied to all targets.
342 config("default_libs") {
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.
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.
377 } else if (is_android) {
378 # Android uses -nostdlib so we need to add even libc here.
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)',
393 "ApplicationServices.framework",
395 "CoreFoundation.framework",
396 "Foundation.framework",
399 "Security.framework",
402 # The libraries listed here will be specified for both the target and the
403 # host. Only the common ones should be listed here.
405 "CoreFoundation.framework",
406 "CoreGraphics.framework",
407 "CoreText.framework",
408 "Foundation.framework",
410 } else if (is_linux) {
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
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.
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" ]