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
40 # Set to true to compile with the OpenGL ES 2.0 conformance tests.
41 internal_gles2_conform_tests = false
44 # TODO(brettw) Most of these should be removed. Instead of global feature
45 # flags, we should have more modular flags that apply only to a target and its
46 # dependents. For example, depending on the "x11" meta-target should define
47 # USE_X11 for all dependents so that everything that could use X11 gets the
48 # define, but anything that doesn't depend on X11 doesn't see it.
50 # For now we define these globally to match the current GYP build.
51 config("feature_flags") {
52 # TODO(brettw) this probably needs to be parameterized.
54 "V8_DEPRECATION_WARNINGS", # Don't use deprecated V8 APIs anywhere.
55 "CLD_VERSION=$cld_version",
58 defines += [ "ENABLE_MDNS=1" ]
60 if (enable_notifications) {
61 defines += [ "ENABLE_NOTIFICATIONS" ]
63 if (enable_pepper_cdms) {
64 # TODO(brettw) should probably be "=1"
65 defines += [ "ENABLE_PEPPER_CDMS" ]
67 if (enable_browser_cdms) {
68 # TODO(brettw) should probably be "=1"
69 defines += [ "ENABLE_BROWSER_CDMS" ]
72 defines += [ "ENABLE_PLUGINS=1" ]
74 if (enable_basic_printing || enable_print_preview) {
75 # Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
76 defines += [ "ENABLE_PRINTING=1" ]
77 if (enable_basic_printing) {
78 # Enable basic printing support and UI.
79 defines += [ "ENABLE_BASIC_PRINTING=1" ]
81 if (enable_print_preview) {
82 # Enable printing with print preview.
83 # Can be defined without ENABLE_BASIC_PRINTING.
84 defines += [ "ENABLE_PRINT_PREVIEW=1" ]
87 if (enable_spellcheck) {
88 defines += [ "ENABLE_SPELLCHECK=1" ]
90 if (use_browser_spellchecker) {
91 defines += [ "USE_BROWSER_SPELLCHECKER=1" ]
93 if (dont_embed_build_metadata) {
94 defines += [ "DONT_EMBED_BUILD_METADATA" ]
96 if (dcheck_always_on) {
97 defines += [ "DCHECK_ALWAYS_ON=1" ]
100 # TODO(brettw) should probably be "=1".
101 defines += [ "USE_UDEV" ]
103 if (ui_compositor_image_transport) {
104 # TODO(brettw) should probably be "=1".
105 defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ]
108 defines += [ "USE_ASH=1" ]
111 defines += [ "USE_AURA=1" ]
114 defines += [ "USE_PANGO=1" ]
117 defines += [ "USE_CAIRO=1" ]
119 if (use_clipboard_aurax11) {
120 defines += [ "USE_CLIPBOARD_AURAX11=1" ]
122 if (use_default_render_theme) {
123 defines += [ "USE_DEFAULT_RENDER_THEME=1" ]
126 defines += [ "USE_GLIB=1" ]
129 defines += [ "USE_OPENSSL=1" ]
131 if (use_openssl_certs) {
132 defines += [ "USE_OPENSSL_CERTS=1" ]
135 defines += [ "USE_NSS_CERTS=1" ]
138 defines += [ "USE_OZONE=1" ]
141 defines += [ "USE_X11=1" ]
143 if (use_allocator != "tcmalloc") {
144 defines += [ "NO_TCMALLOC" ]
146 if (is_asan || is_lsan || is_tsan || is_msan) {
148 "MEMORY_TOOL_REPLACES_ALLOCATOR",
149 "MEMORY_SANITIZER_INITIAL_SIZE",
153 defines += [ "ADDRESS_SANITIZER" ]
158 "WTF_USE_LEAK_SANITIZER=1",
164 "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
165 "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
169 defines += [ "MEMORY_SANITIZER" ]
172 defines += [ "ENABLE_WEBRTC=1" ]
174 if (disable_ftp_support) {
175 defines += [ "DISABLE_FTP_SUPPORT=1" ]
178 defines += [ "DISABLE_NACL" ]
180 if (enable_extensions) {
181 defines += [ "ENABLE_EXTENSIONS=1" ]
183 if (enable_configuration_policy) {
184 defines += [ "ENABLE_CONFIGURATION_POLICY" ]
186 if (enable_task_manager) {
187 defines += [ "ENABLE_TASK_MANAGER=1" ]
190 defines += [ "ENABLE_THEMES=1" ]
192 if (enable_captive_portal_detection) {
193 defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
195 if (enable_session_service) {
196 defines += [ "ENABLE_SESSION_SERVICE=1" ]
199 defines += [ "ENABLE_RLZ" ]
201 if (enable_plugin_installation) {
202 defines += [ "ENABLE_PLUGIN_INSTALLATION=1" ]
204 if (enable_app_list) {
205 defines += [ "ENABLE_APP_LIST=1" ]
207 if (enable_settings_app) {
208 defines += [ "ENABLE_SETTINGS_APP=1" ]
210 if (enable_supervised_users) {
211 defines += [ "ENABLE_SUPERVISED_USERS=1" ]
213 if (enable_service_discovery) {
214 defines += [ "ENABLE_SERVICE_DISCOVERY=1" ]
216 if (enable_autofill_dialog) {
217 defines += [ "ENABLE_AUTOFILL_DIALOG=1" ]
219 if (enable_wifi_bootstrapping) {
220 defines += [ "ENABLE_WIFI_BOOTSTRAPPING=1" ]
222 if (enable_image_loader_extension) {
223 defines += [ "IMAGE_LOADER_EXTENSION=1" ]
225 if (enable_google_now) {
226 defines += [ "ENABLE_GOOGLE_NOW=1" ]
228 if (enable_one_click_signin) {
229 defines += [ "ENABLE_ONE_CLICK_SIGNIN" ]
232 defines += [ "ENABLE_HIDPI=1" ]
234 if (enable_topchrome_md) {
235 defines += [ "ENABLE_TOPCHROME_MD=1" ]
237 if (proprietary_codecs) {
238 defines += [ "USE_PROPRIETARY_CODECS" ]
240 if (enable_hangout_services_extension) {
241 defines += [ "ENABLE_HANGOUT_SERVICES_EXTENSION=1" ]
243 if (v8_use_external_startup_data) {
244 defines += [ "V8_USE_EXTERNAL_STARTUP_DATA" ]
246 if (enable_background) {
247 defines += [ "ENABLE_BACKGROUND=1" ]
249 if (enable_pre_sync_backup) {
250 defines += [ "ENABLE_PRE_SYNC_BACKUP" ]
252 if (enable_video_hole) {
253 defines += [ "VIDEO_HOLE=1" ]
255 if (safe_browsing_mode == 1) {
256 defines += [ "FULL_SAFE_BROWSING" ]
257 defines += [ "SAFE_BROWSING_CSD" ]
258 defines += [ "SAFE_BROWSING_DB_LOCAL" ]
259 defines += [ "SAFE_BROWSING_SERVICE" ]
260 } else if (safe_browsing_mode == 2) {
261 defines += [ "MOBILE_SAFE_BROWSING" ]
262 defines += [ "SAFE_BROWSING_SERVICE" ]
263 } else if (safe_browsing_mode == 3) {
264 defines += [ "MOBILE_SAFE_BROWSING" ]
265 defines += [ "SAFE_BROWSING_DB_REMOTE" ]
266 defines += [ "SAFE_BROWSING_SERVICE" ]
268 if (is_official_build) {
269 defines += [ "OFFICIAL_BUILD" ]
271 if (is_chrome_branded) {
272 defines += [ "GOOGLE_CHROME_BUILD" ]
274 defines += [ "CHROMIUM_BUILD" ]
276 if (enable_media_router) {
277 defines += [ "ENABLE_MEDIA_ROUTER=1" ]
280 defines += [ "ENABLE_WEBVR" ]
285 "MEMORY_TOOL_REPLACES_ALLOCATOR",
286 "MEMORY_SANITIZER_INITIAL_SIZE",
289 if (!fieldtrial_testing_like_official_build && !is_chrome_branded) {
290 defines += [ "FIELDTRIAL_TESTING_ENABLED" ]
294 # Debug/release ----------------------------------------------------------------
299 "DYNAMIC_ANNOTATIONS_ENABLED=1",
300 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
304 defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
308 if (!enable_iterator_debugging) {
309 # Iterator debugging is enabled by default by the compiler on debug
310 # builds, and we have to tell it to turn it off.
311 defines += [ "_HAS_ITERATOR_DEBUGGING=0" ]
313 } else if (is_linux && current_cpu == "x64" && enable_iterator_debugging) {
314 # Enable libstdc++ debugging facilities to help catch problems early, see
315 # http://crbug.com/65151 .
316 # TODO(phajdan.jr): Should we enable this for all of POSIX?
317 defines += [ "_GLIBCXX_DEBUG=1" ]
322 defines = [ "NDEBUG" ]
325 # TODO(GYP) The GYP build has "release_valgrind_build == 0" for this
326 # condition. When Valgrind is set up, we need to do the same here.
329 "DYNAMIC_ANNOTATIONS_ENABLED=1",
330 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
333 defines += [ "NVALGRIND" ]
335 # NaCl always enables dynamic annotations. Currently this value is set to
337 defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
342 # Default libraries ------------------------------------------------------------
344 # This config defines the default libraries applied to all targets.
345 config("default_libs") {
347 # TODO(brettw) this list of defaults should probably be smaller, and
348 # instead the targets that use the less common ones (e.g. wininet or
349 # winspool) should include those explicitly.
375 # Please don't add more stuff here. We should actually be making this
376 # list smaller, since all common things should be covered. If you need
377 # some extra libraries, please just add a libs = [ "foo.lib" ] to your
378 # target that needs it.
380 } else if (is_android) {
381 # Android uses -nostdlib so we need to add even libc here.
383 # TODO(brettw) write a version of this, hopefully we can express this
384 # without forking out to GCC just to get the library name. The android
385 # toolchain directory should probably be extracted into a .gni file that
386 # this file and the android toolchain .gn file can share.
387 # # Manually link the libgcc.a that the cross compiler uses.
388 # '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
396 "ApplicationServices.framework",
398 "CoreFoundation.framework",
399 "Foundation.framework",
402 "Security.framework",
405 # The libraries listed here will be specified for both the target and the
406 # host. Only the common ones should be listed here.
408 "CoreFoundation.framework",
409 "CoreGraphics.framework",
410 "CoreText.framework",
411 "Foundation.framework",
413 } else if (is_linux) {
418 # Add this config to your target to enable precompiled headers.
420 # On Windows, precompiled headers are done on a per-target basis. If you have
421 # just a couple of files, the time it takes to precompile (~2 seconds) can
422 # actually be longer than the time saved. On a Z620, a 100 file target compiles
423 # about 2 seconds faster with precompiled headers, with greater savings for
426 # Recommend precompiled headers for targets with more than 50 .cc files.
427 config("precompiled_headers") {
428 if (is_win && !is_official_build && !use_goma) {
429 # This is a string rather than a file GN knows about. It has to match
430 # exactly what's in the /FI flag below, and what might appear in the source
431 # code in quotes for an #include directive.
432 precompiled_header = "build/precompile.h"
434 # This is a file that GN will compile with the above header. It will be
435 # implicitly added to the sources (potentially multiple times, with one
436 # variant for each language used in the target).
437 precompiled_source = "//build/precompile.cc"
439 # Force include the header.
440 cflags = [ "/FI$precompiled_header" ]
442 # Disable warning for "this file was empty after preprocessing". This
443 # error is generated only in C mode for ANSI compatibility. It conflicts
444 # with precompiled headers since the source file that's "compiled" for
445 # making the precompiled header is empty.
447 # This error doesn't happen every time. In VS2013, it seems if the .pch
448 # file doesn't exist, no error will be generated (probably MS tested this
449 # case but forgot the other one?). To reproduce this error, do a build,
450 # then delete the precompile.c.obj file, then build again.
451 cflags_c = [ "/wd4206" ]