OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 import("//build/config/allocator.gni") |
| 6 import("//build/config/chrome_build.gni") |
| 7 import("//build/config/chromecast_build.gni") |
| 8 import("//build/config/crypto.gni") |
| 9 import("//build/config/dcheck_always_on.gni") |
| 10 import("//build/config/features.gni") |
| 11 import("//build/config/sanitizers/sanitizers.gni") |
| 12 import("//build/config/ui.gni") |
| 13 import("//build/toolchain/goma.gni") |
| 14 |
| 15 # One common error that happens is that GYP-generated headers within gen/ get |
| 16 # included rather than the GN-generated ones within gen/ subdirectories. |
| 17 # TODO(GYP_GONE): Remove once GYP is gone (as well as exec_script exception). |
| 18 assert( |
| 19 exec_script("//build/dir_exists.py", [ "obj.host" ], "string") == "False", |
| 20 "GYP artifacts detected in $root_build_dir.$0x0A" + |
| 21 "You must wipe this directory before building with GN.") |
| 22 |
| 23 declare_args() { |
| 24 # When set (the default) enables C++ iterator debugging in debug builds. |
| 25 # Iterator debugging is always off in release builds (technically, this flag |
| 26 # affects the "debug" config, which is always available but applied by |
| 27 # default only in debug builds). |
| 28 # |
| 29 # Iterator debugging is generally useful for catching bugs. But it can |
| 30 # introduce extra locking to check the state of an iterator against the state |
| 31 # of the current object. For iterator- and thread-heavy code, this can |
| 32 # significantly slow execution. |
| 33 enable_iterator_debugging = true |
| 34 |
| 35 # Normally we try to decide whether to use precompiled headers or |
| 36 # not based on the other build arguments, but in some cases it is |
| 37 # easiest to force them off explicitly. |
| 38 disable_precompiled_headers = false |
| 39 } |
| 40 |
| 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. |
| 46 # |
| 47 # For now we define these globally to match the current GYP build. |
| 48 config("feature_flags") { |
| 49 # Don't use deprecated V8 APIs anywhere. |
| 50 defines = [ "V8_DEPRECATION_WARNINGS" ] |
| 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_pdf) { |
| 69 defines += [ "ENABLE_PDF=1" ] |
| 70 } |
| 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" ] |
| 77 } |
| 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" ] |
| 82 } |
| 83 if ((enable_basic_printing && is_win) || enable_print_preview) { |
| 84 # Windows basic printing or print preview requires pdf enabled. |
| 85 assert(enable_pdf, |
| 86 "Windows basic printing or print preview needs pdf: " + |
| 87 "set enable_pdf=true.") |
| 88 } |
| 89 } |
| 90 if (enable_spellcheck) { |
| 91 defines += [ "ENABLE_SPELLCHECK=1" ] |
| 92 } |
| 93 if (use_browser_spellchecker) { |
| 94 defines += [ "USE_BROWSER_SPELLCHECKER=1" ] |
| 95 } |
| 96 if (dcheck_always_on) { |
| 97 defines += [ "DCHECK_ALWAYS_ON=1" ] |
| 98 } |
| 99 if (use_udev) { |
| 100 # TODO(brettw) should probably be "=1". |
| 101 defines += [ "USE_UDEV" ] |
| 102 } |
| 103 if (ui_compositor_image_transport) { |
| 104 # TODO(brettw) should probably be "=1". |
| 105 defines += [ "UI_COMPOSITOR_IMAGE_TRANSPORT" ] |
| 106 } |
| 107 if (use_ash) { |
| 108 defines += [ "USE_ASH=1" ] |
| 109 } |
| 110 if (use_aura) { |
| 111 defines += [ "USE_AURA=1" ] |
| 112 } |
| 113 if (use_pango) { |
| 114 defines += [ "USE_PANGO=1" ] |
| 115 } |
| 116 if (use_cairo) { |
| 117 defines += [ "USE_CAIRO=1" ] |
| 118 } |
| 119 if (use_clipboard_aurax11) { |
| 120 defines += [ "USE_CLIPBOARD_AURAX11=1" ] |
| 121 } |
| 122 if (use_default_render_theme) { |
| 123 defines += [ "USE_DEFAULT_RENDER_THEME=1" ] |
| 124 } |
| 125 if (use_glib) { |
| 126 defines += [ "USE_GLIB=1" ] |
| 127 } |
| 128 if (use_openssl_certs) { |
| 129 defines += [ "USE_OPENSSL_CERTS=1" ] |
| 130 } |
| 131 if (use_nss_certs) { |
| 132 defines += [ "USE_NSS_CERTS=1" ] |
| 133 } |
| 134 if (use_ozone) { |
| 135 defines += [ "USE_OZONE=1" ] |
| 136 } |
| 137 if (use_x11) { |
| 138 defines += [ "USE_X11=1" ] |
| 139 } |
| 140 if (use_allocator != "tcmalloc") { |
| 141 defines += [ "NO_TCMALLOC" ] |
| 142 } |
| 143 if (is_asan || is_lsan || is_tsan || is_msan) { |
| 144 defines += [ |
| 145 "MEMORY_TOOL_REPLACES_ALLOCATOR", |
| 146 "MEMORY_SANITIZER_INITIAL_SIZE", |
| 147 ] |
| 148 } |
| 149 if (is_asan) { |
| 150 defines += [ "ADDRESS_SANITIZER" ] |
| 151 } |
| 152 if (is_lsan) { |
| 153 defines += [ |
| 154 "LEAK_SANITIZER", |
| 155 "WTF_USE_LEAK_SANITIZER=1", |
| 156 ] |
| 157 } |
| 158 if (is_tsan) { |
| 159 defines += [ |
| 160 "THREAD_SANITIZER", |
| 161 "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1", |
| 162 "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1", |
| 163 ] |
| 164 } |
| 165 if (is_msan) { |
| 166 defines += [ "MEMORY_SANITIZER" ] |
| 167 } |
| 168 if (is_ubsan || is_ubsan_vptr || is_ubsan_security) { |
| 169 defines += [ "UNDEFINED_SANITIZER" ] |
| 170 } |
| 171 if (enable_webrtc) { |
| 172 defines += [ "ENABLE_WEBRTC=1" ] |
| 173 } |
| 174 if (!enable_nacl) { |
| 175 defines += [ "DISABLE_NACL" ] |
| 176 } |
| 177 if (enable_extensions) { |
| 178 defines += [ "ENABLE_EXTENSIONS=1" ] |
| 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_image_loader_extension) { |
| 211 defines += [ "IMAGE_LOADER_EXTENSION=1" ] |
| 212 } |
| 213 if (enable_wayland_server) { |
| 214 defines += [ "ENABLE_WAYLAND_SERVER=1" ] |
| 215 } |
| 216 if (enable_wifi_display) { |
| 217 defines += [ "ENABLE_WIFI_DISPLAY=1" ] |
| 218 } |
| 219 if (proprietary_codecs) { |
| 220 defines += [ "USE_PROPRIETARY_CODECS" ] |
| 221 } |
| 222 if (enable_hangout_services_extension) { |
| 223 defines += [ "ENABLE_HANGOUT_SERVICES_EXTENSION=1" ] |
| 224 } |
| 225 if (enable_video_hole) { |
| 226 defines += [ "VIDEO_HOLE=1" ] |
| 227 } |
| 228 if (safe_browsing_mode == 1) { |
| 229 defines += [ "FULL_SAFE_BROWSING" ] |
| 230 defines += [ "SAFE_BROWSING_CSD" ] |
| 231 defines += [ "SAFE_BROWSING_DB_LOCAL" ] |
| 232 } else if (safe_browsing_mode == 2) { |
| 233 defines += [ "SAFE_BROWSING_DB_REMOTE" ] |
| 234 } |
| 235 if (is_official_build) { |
| 236 defines += [ "OFFICIAL_BUILD" ] |
| 237 } |
| 238 if (is_chrome_branded) { |
| 239 defines += [ "GOOGLE_CHROME_BUILD" ] |
| 240 } else { |
| 241 defines += [ "CHROMIUM_BUILD" ] |
| 242 } |
| 243 if (enable_media_router) { |
| 244 defines += [ "ENABLE_MEDIA_ROUTER=1" ] |
| 245 } |
| 246 if (enable_webvr) { |
| 247 defines += [ "ENABLE_WEBVR" ] |
| 248 } |
| 249 if (is_syzyasan) { |
| 250 defines += [ |
| 251 "SYZYASAN", |
| 252 "MEMORY_TOOL_REPLACES_ALLOCATOR", |
| 253 "MEMORY_SANITIZER_INITIAL_SIZE", |
| 254 ] |
| 255 } |
| 256 if (!fieldtrial_testing_like_official_build && !is_chrome_branded) { |
| 257 defines += [ "FIELDTRIAL_TESTING_ENABLED" ] |
| 258 } |
| 259 } |
| 260 |
| 261 # Debug/release ---------------------------------------------------------------- |
| 262 |
| 263 config("debug") { |
| 264 defines = [ |
| 265 "_DEBUG", |
| 266 "DYNAMIC_ANNOTATIONS_ENABLED=1", |
| 267 "WTF_USE_DYNAMIC_ANNOTATIONS=1", |
| 268 ] |
| 269 |
| 270 if (is_nacl) { |
| 271 defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ] |
| 272 } |
| 273 |
| 274 if (is_win) { |
| 275 if (!enable_iterator_debugging) { |
| 276 # Iterator debugging is enabled by default by the compiler on debug |
| 277 # builds, and we have to tell it to turn it off. |
| 278 defines += [ "_HAS_ITERATOR_DEBUGGING=0" ] |
| 279 } |
| 280 } else if (is_linux && current_cpu == "x64" && enable_iterator_debugging) { |
| 281 # Enable libstdc++ debugging facilities to help catch problems early, see |
| 282 # http://crbug.com/65151 . |
| 283 # TODO(phajdan.jr): Should we enable this for all of POSIX? |
| 284 defines += [ "_GLIBCXX_DEBUG=1" ] |
| 285 } |
| 286 } |
| 287 |
| 288 config("release") { |
| 289 defines = [ "NDEBUG" ] |
| 290 |
| 291 # Sanitizers. |
| 292 if (is_tsan) { |
| 293 defines += [ |
| 294 "DYNAMIC_ANNOTATIONS_ENABLED=1", |
| 295 "WTF_USE_DYNAMIC_ANNOTATIONS=1", |
| 296 ] |
| 297 } else { |
| 298 defines += [ "NVALGRIND" ] |
| 299 if (!is_nacl) { |
| 300 # NaCl always enables dynamic annotations. Currently this value is set to |
| 301 # 1 for all .nexes. |
| 302 defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ] |
| 303 } |
| 304 } |
| 305 } |
| 306 |
| 307 # Default libraries ------------------------------------------------------------ |
| 308 |
| 309 # This config defines the default libraries applied to all targets. |
| 310 config("default_libs") { |
| 311 if (is_win) { |
| 312 # TODO(brettw) this list of defaults should probably be smaller, and |
| 313 # instead the targets that use the less common ones (e.g. wininet or |
| 314 # winspool) should include those explicitly. |
| 315 libs = [ |
| 316 "advapi32.lib", |
| 317 "comdlg32.lib", |
| 318 "dbghelp.lib", |
| 319 "delayimp.lib", |
| 320 "dnsapi.lib", |
| 321 "gdi32.lib", |
| 322 "kernel32.lib", |
| 323 "msimg32.lib", |
| 324 "odbc32.lib", |
| 325 "odbccp32.lib", |
| 326 "ole32.lib", |
| 327 "oleaut32.lib", |
| 328 "psapi.lib", |
| 329 "shell32.lib", |
| 330 "shlwapi.lib", |
| 331 "user32.lib", |
| 332 "usp10.lib", |
| 333 "uuid.lib", |
| 334 "version.lib", |
| 335 "wininet.lib", |
| 336 "winmm.lib", |
| 337 "winspool.lib", |
| 338 "ws2_32.lib", |
| 339 |
| 340 # Please don't add more stuff here. We should actually be making this |
| 341 # list smaller, since all common things should be covered. If you need |
| 342 # some extra libraries, please just add a libs = [ "foo.lib" ] to your |
| 343 # target that needs it. |
| 344 ] |
| 345 } else if (is_android) { |
| 346 libs = [ |
| 347 "dl", |
| 348 "m", |
| 349 ] |
| 350 } else if (is_mac) { |
| 351 # Targets should choose to explicitly link frameworks they require. Since |
| 352 # linking can have run-time side effects, nothing should be listed here. |
| 353 libs = [] |
| 354 } else if (is_ios) { |
| 355 # The libraries listed here will be specified for both the target and the |
| 356 # host. Only the common ones should be listed here. |
| 357 libs = [ |
| 358 "CoreFoundation.framework", |
| 359 "CoreGraphics.framework", |
| 360 "CoreText.framework", |
| 361 "Foundation.framework", |
| 362 ] |
| 363 } else if (is_linux) { |
| 364 libs = [ |
| 365 "dl", |
| 366 "rt", |
| 367 ] |
| 368 } |
| 369 } |
| 370 |
| 371 # Executable configs ----------------------------------------------------------- |
| 372 |
| 373 # Windows linker setup for EXEs and DLLs. |
| 374 if (is_win) { |
| 375 _windows_linker_configs = [ |
| 376 "//build/config/win:sdk_link", |
| 377 "//build/config/win:common_linker_setup", |
| 378 ] |
| 379 } |
| 380 |
| 381 # This config defines the configs applied to all executables. |
| 382 config("executable_config") { |
| 383 configs = [] |
| 384 |
| 385 if (is_win) { |
| 386 configs += _windows_linker_configs |
| 387 } else if (is_mac) { |
| 388 configs += [ |
| 389 "//build/config/mac:mac_dynamic_flags", |
| 390 "//build/config/mac:mac_executable_flags", |
| 391 ] |
| 392 } else if (is_linux || is_android) { |
| 393 configs += [ "//build/config/gcc:executable_ldconfig" ] |
| 394 if (is_android) { |
| 395 configs += [ "//build/config/android:executable_config" ] |
| 396 } else if (is_chromecast) { |
| 397 configs += [ "//build/config/chromecast:executable_config" ] |
| 398 } |
| 399 } |
| 400 } |
| 401 |
| 402 # Shared library configs ------------------------------------------------------- |
| 403 |
| 404 # This config defines the configs applied to all shared libraries. |
| 405 config("shared_library_config") { |
| 406 configs = [] |
| 407 |
| 408 if (is_win) { |
| 409 configs += _windows_linker_configs |
| 410 } else if (is_mac) { |
| 411 configs += [ "//build/config/mac:mac_dynamic_flags" ] |
| 412 } else if (is_chromecast) { |
| 413 configs += [ "//build/config/chromecast:shared_library_config" ] |
| 414 } |
| 415 } |
| 416 |
| 417 # Add this config to your target to enable precompiled headers. |
| 418 # |
| 419 # Precompiled headers are done on a per-target basis. If you have just a couple |
| 420 # of files, the time it takes to precompile (~2 seconds) can actually be longer |
| 421 # than the time saved. On a Z620, a 100 file target compiles about 2 seconds |
| 422 # faster with precompiled headers, with greater savings for larger targets. |
| 423 # |
| 424 # Recommend precompiled headers for targets with more than 50 .cc files. |
| 425 config("precompiled_headers") { |
| 426 if (!is_official_build && !use_goma && !disable_precompiled_headers) { |
| 427 if (is_win) { |
| 428 # This is a string rather than a file GN knows about. It has to match |
| 429 # exactly what's in the /FI flag below, and what might appear in the |
| 430 # source code in quotes for an #include directive. |
| 431 precompiled_header = "build/precompile.h" |
| 432 |
| 433 # This is a file that GN will compile with the above header. It will be |
| 434 # implicitly added to the sources (potentially multiple times, with one |
| 435 # variant for each language used in the target). |
| 436 precompiled_source = "//build/precompile.cc" |
| 437 |
| 438 # Force include the header. |
| 439 cflags = [ "/FI$precompiled_header" ] |
| 440 |
| 441 # Disable warning for "this file was empty after preprocessing". This |
| 442 # error is generated only in C mode for ANSI compatibility. It conflicts |
| 443 # with precompiled headers since the source file that's "compiled" for |
| 444 # making the precompiled header is empty. |
| 445 # |
| 446 # This error doesn't happen every time. In VS2013, it seems if the .pch |
| 447 # file doesn't exist, no error will be generated (probably MS tested this |
| 448 # case but forgot the other one?). To reproduce this error, do a build, |
| 449 # then delete the precompile.c.obj file, then build again. |
| 450 cflags_c = [ "/wd4206" ] |
| 451 } else if (is_mac) { |
| 452 precompiled_header = "build/precompile.h" |
| 453 precompiled_source = "//build/precompile.h" |
| 454 } |
| 455 } |
| 456 } |
OLD | NEW |