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, 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.
24 # Continue to embed build meta data in Official builds, basically the
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" ]
53 defines += [ "ENABLE_MDNS=1" ]
55 if (enable_notifications) {
56 defines += [ "ENABLE_NOTIFICATIONS" ]
58 if (enable_pepper_cdms) {
59 # TODO(brettw) should probably be "=1"
60 defines += [ "ENABLE_PEPPER_CDMS" ]
62 if (enable_browser_cdms) {
63 # TODO(brettw) should probably be "=1"
64 defines += [ "ENABLE_BROWSER_CDMS" ]
67 defines += [ "ENABLE_PLUGINS=1" ]
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" ]
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" ]
82 if (enable_spellcheck) {
83 defines += [ "ENABLE_SPELLCHECK=1" ]
85 if (use_platform_spellchecker) {
86 defines += [ "USE_PLATFORM_SPELLCHECKER=1" ]
88 if (dont_embed_build_metadata) {
89 defines += [ "DONT_EMBED_BUILD_METADATA" ]
91 if (dcheck_always_on) {
92 defines += [ "DCHECK_ALWAYS_ON=1" ]
95 # TODO(brettw) should probably be "=1".
96 defines += [ "USE_UDEV" ]
98 if (ui_compositor_image_transport) {
99 # TODO(brettw) should probably be "=1".
100 defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ]
103 defines += [ "USE_ASH=1" ]
106 defines += [ "USE_AURA=1" ]
109 defines += [ "USE_PANGO=1" ]
112 defines += [ "USE_CAIRO=1" ]
114 if (use_clipboard_aurax11) {
115 defines += [ "USE_CLIPBOARD_AURAX11=1" ]
117 if (use_default_render_theme) {
118 defines += [ "USE_DEFAULT_RENDER_THEME=1" ]
121 defines += [ "USE_GLIB=1" ]
124 defines += [ "USE_OPENSSL=1" ]
126 if (use_openssl_certs) {
127 defines += [ "USE_OPENSSL_CERTS=1" ]
130 defines += [ "USE_NSS_CERTS=1" ]
133 defines += [ "USE_OZONE=1" ]
136 defines += [ "USE_X11=1" ]
138 if (use_allocator != "tcmalloc") {
139 defines += [ "NO_TCMALLOC" ]
141 if (is_asan || is_lsan || is_tsan || is_msan) {
143 "MEMORY_TOOL_REPLACES_ALLOCATOR",
144 "MEMORY_SANITIZER_INITIAL_SIZE",
148 defines += [ "ADDRESS_SANITIZER" ]
153 "WTF_USE_LEAK_SANITIZER=1",
159 "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
160 "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
164 defines += [ "MEMORY_SANITIZER" ]
167 defines += [ "ENABLE_WEBRTC=1" ]
169 if (disable_ftp_support) {
170 defines += [ "DISABLE_FTP_SUPPORT=1" ]
173 defines += [ "DISABLE_NACL" ]
175 if (enable_extensions) {
176 defines += [ "ENABLE_EXTENSIONS=1" ]
178 if (enable_configuration_policy) {
179 defines += [ "ENABLE_CONFIGURATION_POLICY" ]
181 if (enable_task_manager) {
182 defines += [ "ENABLE_TASK_MANAGER=1" ]
185 defines += [ "ENABLE_THEMES=1" ]
187 if (enable_captive_portal_detection) {
188 defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
190 if (enable_session_service) {
191 defines += [ "ENABLE_SESSION_SERVICE=1" ]
194 defines += [ "ENABLE_RLZ" ]
196 if (enable_plugin_installation) {
197 defines += [ "ENABLE_PLUGIN_INSTALLATION=1" ]
199 if (enable_app_list) {
200 defines += [ "ENABLE_APP_LIST=1" ]
202 if (enable_settings_app) {
203 defines += [ "ENABLE_SETTINGS_APP=1" ]
205 if (enable_supervised_users) {
206 defines += [ "ENABLE_SUPERVISED_USERS=1" ]
208 if (enable_service_discovery) {
209 defines += [ "ENABLE_SERVICE_DISCOVERY=1" ]
211 if (enable_autofill_dialog) {
212 defines += [ "ENABLE_AUTOFILL_DIALOG=1" ]
214 if (enable_wifi_bootstrapping) {
215 defines += [ "ENABLE_WIFI_BOOTSTRAPPING=1" ]
217 if (enable_image_loader_extension) {
218 defines += [ "IMAGE_LOADER_EXTENSION=1" ]
220 if (enable_remoting) {
221 defines += [ "ENABLE_REMOTING=1" ]
223 if (enable_google_now) {
224 defines += [ "ENABLE_GOOGLE_NOW=1" ]
226 if (enable_one_click_signin) {
227 defines += [ "ENABLE_ONE_CLICK_SIGNIN" ]
230 defines += [ "ENABLE_HIDPI=1" ]
232 if (enable_topchrome_md) {
233 defines += [ "ENABLE_TOPCHROME_MD=1" ]
235 if (proprietary_codecs) {
236 defines += [ "USE_PROPRIETARY_CODECS" ]
238 if (enable_hangout_services_extension) {
239 defines += [ "ENABLE_HANGOUT_SERVICES_EXTENSION=1" ]
241 if (v8_use_external_startup_data) {
242 defines += [ "V8_USE_EXTERNAL_STARTUP_DATA" ]
244 if (enable_background) {
245 defines += [ "ENABLE_BACKGROUND=1" ]
247 if (enable_pre_sync_backup) {
248 defines += [ "ENABLE_PRE_SYNC_BACKUP" ]
250 if (enable_video_hole) {
251 defines += [ "VIDEO_HOLE=1" ]
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" ]
266 if (is_official_build) {
267 defines += [ "OFFICIAL_BUILD" ]
269 if (is_chrome_branded) {
270 defines += [ "GOOGLE_CHROME_BUILD" ]
272 defines += [ "CHROMIUM_BUILD" ]
274 if (enable_media_router) {
275 defines += [ "ENABLE_MEDIA_ROUTER=1" ]
278 defines += [ "ENABLE_WEBVR" ]
283 "MEMORY_TOOL_REPLACES_ALLOCATOR",
284 "MEMORY_SANITIZER_INITIAL_SIZE",
289 # Debug/release ----------------------------------------------------------------
294 "DYNAMIC_ANNOTATIONS_ENABLED=1",
295 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
299 defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
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" ]
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" ]
318 defines = [ "NDEBUG" ]
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.
325 "DYNAMIC_ANNOTATIONS_ENABLED=1",
326 "WTF_USE_DYNAMIC_ANNOTATIONS=1",
329 defines += [ "NVALGRIND" ]
331 # NaCl always enables dynamic annotations. Currently this value is set to
333 defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
338 # Default libraries ------------------------------------------------------------
340 # This config defines the default libraries applied to all targets.
341 config("default_libs") {
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.
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.
376 } else if (is_android) {
377 # Android uses -nostdlib so we need to add even libc here.
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)',
392 "ApplicationServices.framework",
394 "CoreFoundation.framework",
395 "Foundation.framework",
397 "Security.framework",
401 "CoreFoundation.framework",
402 "CoreGraphics.framework",
403 "CoreText.framework",
404 "Foundation.framework",
407 } else if (is_linux) {
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
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.
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" ]