OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # ============================================================================= | 5 # ============================================================================= |
6 # BUILD FLAGS | 6 # BUILD FLAGS |
7 # ============================================================================= | 7 # ============================================================================= |
8 # | 8 # |
9 # This block lists input arguments to the build, along with their default | 9 # This block lists input arguments to the build, along with their default |
10 # values. GN requires listing them explicitly so it can validate input and have | 10 # values. GN requires listing them explicitly so it can validate input and have |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 # Chromium waterfall. This is not for non-officially-supported platforms | 276 # Chromium waterfall. This is not for non-officially-supported platforms |
277 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases, | 277 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases, |
278 # write a conditional in the target to remove the file(s) from the list when | 278 # write a conditional in the target to remove the file(s) from the list when |
279 # your platform/toolkit/feature doesn't apply. | 279 # your platform/toolkit/feature doesn't apply. |
280 set_sources_assignment_filter(sources_assignment_filter) | 280 set_sources_assignment_filter(sources_assignment_filter) |
281 | 281 |
282 # ============================================================================= | 282 # ============================================================================= |
283 # BUILD OPTIONS | 283 # BUILD OPTIONS |
284 # ============================================================================= | 284 # ============================================================================= |
285 | 285 |
286 if (is_component_build) { | |
287 component_mode = "shared_library" | |
288 } else { | |
289 component_mode = "source_set" | |
290 } | |
291 | |
292 # These Sanitizers all imply using the Clang compiler. On Windows they either | 286 # These Sanitizers all imply using the Clang compiler. On Windows they either |
293 # don't work or work differently. | 287 # don't work or work differently. |
294 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { | 288 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) { |
295 is_clang = true | 289 is_clang = true |
296 } | 290 } |
297 | 291 |
298 # ============================================================================= | 292 # ============================================================================= |
299 # TARGET DEFAULTS | 293 # TARGET DEFAULTS |
300 # ============================================================================= | 294 # ============================================================================= |
301 # | 295 # |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 _windows_linker_configs = [ | 377 _windows_linker_configs = [ |
384 _default_incremental_linking_config, | 378 _default_incremental_linking_config, |
385 "//build/config/win:sdk_link", | 379 "//build/config/win:sdk_link", |
386 "//build/config/win:common_linker_setup", | 380 "//build/config/win:common_linker_setup", |
387 # Default to console-mode apps. Most of our targets are tests and such | 381 # Default to console-mode apps. Most of our targets are tests and such |
388 # that shouldn't use the windows subsystem. | 382 # that shouldn't use the windows subsystem. |
389 "//build/config/win:console", | 383 "//build/config/win:console", |
390 ] | 384 ] |
391 } | 385 } |
392 | 386 |
| 387 # Executable defaults (applies to executables and tests). |
| 388 _executable_configs = _native_compiler_configs + [ |
| 389 "//build/config:default_libs", |
| 390 ] |
| 391 if (is_win) { |
| 392 _executable_configs += _windows_linker_configs |
| 393 } else if (is_mac) { |
| 394 _executable_configs += [ |
| 395 "//build/config/mac:mac_dynamic_flags", |
| 396 "//build/config/mac:mac_executable_flags" ] |
| 397 } else if (is_linux || is_android) { |
| 398 _executable_configs += [ "//build/config/gcc:executable_ldconfig" ] |
| 399 } |
393 set_defaults("executable") { | 400 set_defaults("executable") { |
394 configs = _native_compiler_configs + [ | 401 configs = _executable_configs |
395 "//build/config:default_libs", | 402 } |
396 ] | 403 set_defaults("test") { |
397 if (is_win) { | 404 configs = _executable_configs |
398 configs += _windows_linker_configs | |
399 } else if (is_mac) { | |
400 configs += [ | |
401 "//build/config/mac:mac_dynamic_flags", | |
402 "//build/config/mac:mac_executable_flags" ] | |
403 } else if (is_linux || is_android) { | |
404 configs += [ "//build/config/gcc:executable_ldconfig" ] | |
405 } | |
406 } | 405 } |
407 | 406 |
| 407 # Static library defaults. |
408 set_defaults("static_library") { | 408 set_defaults("static_library") { |
409 configs = _native_compiler_configs | 409 configs = _native_compiler_configs |
410 } | 410 } |
411 | 411 |
| 412 # Shared library defaults (also for components in component mode). |
| 413 _shared_library_configs = _native_compiler_configs + [ |
| 414 "//build/config:default_libs", |
| 415 ] |
| 416 if (is_win) { |
| 417 _shared_library_configs += _windows_linker_configs |
| 418 } else if (is_mac) { |
| 419 _shared_library_configs += [ "//build/config/mac:mac_dynamic_flags" ] |
| 420 } |
412 set_defaults("shared_library") { | 421 set_defaults("shared_library") { |
413 configs = _native_compiler_configs + [ | 422 configs = _shared_library_configs |
414 "//build/config:default_libs", | 423 } |
415 ] | 424 if (is_component_build) { |
416 if (is_win) { | 425 set_defaults("component") { |
417 configs += _windows_linker_configs | 426 configs = _native_compiler_configs |
418 } else if (is_mac) { | |
419 configs += [ "//build/config/mac:mac_dynamic_flags" ] | |
420 } | 427 } |
421 } | 428 } |
422 | 429 |
| 430 # Source set defaults (also for components in non-component mode). |
423 set_defaults("source_set") { | 431 set_defaults("source_set") { |
424 configs = _native_compiler_configs | 432 configs = _native_compiler_configs |
425 } | 433 } |
| 434 if (!is_component_build) { |
| 435 set_defaults("component") { |
| 436 configs = _native_compiler_configs |
| 437 } |
| 438 } |
426 | 439 |
427 # ============================================================================== | 440 # ============================================================================== |
428 # TOOLCHAIN SETUP | 441 # TOOLCHAIN SETUP |
429 # ============================================================================== | 442 # ============================================================================== |
430 # | 443 # |
431 # Here we set the default toolchain, as well as the variable host_toolchain | 444 # Here we set the default toolchain, as well as the variable host_toolchain |
432 # which will identify the toolchain corresponding to the local system when | 445 # which will identify the toolchain corresponding to the local system when |
433 # doing cross-compiles. When not cross-compiling, this will be the same as the | 446 # doing cross-compiles. When not cross-compiling, this will be the same as the |
434 # default toolchain. | 447 # default toolchain. |
435 | 448 |
(...skipping 27 matching lines...) Expand all Loading... |
463 host_toolchain = "//build/toolchain/linux:$build_cpu_arch" | 476 host_toolchain = "//build/toolchain/linux:$build_cpu_arch" |
464 set_default_toolchain("//build/toolchain/linux:$cpu_arch") | 477 set_default_toolchain("//build/toolchain/linux:$cpu_arch") |
465 } | 478 } |
466 } else if (is_mac) { | 479 } else if (is_mac) { |
467 host_toolchain = "//build/toolchain/mac:clang" | 480 host_toolchain = "//build/toolchain/mac:clang" |
468 set_default_toolchain(host_toolchain) | 481 set_default_toolchain(host_toolchain) |
469 } else if (is_ios) { | 482 } else if (is_ios) { |
470 host_toolchain = "//build/toolchain/mac:host_clang" | 483 host_toolchain = "//build/toolchain/mac:host_clang" |
471 set_default_toolchain("//build/toolchain/mac:clang") | 484 set_default_toolchain("//build/toolchain/mac:clang") |
472 } | 485 } |
| 486 |
| 487 # ============================================================================== |
| 488 # COMPONENT SETUP |
| 489 # ============================================================================== |
| 490 |
| 491 # TODO(brettw) erase this once the built-in "component" function is removed. |
| 492 if (is_component_build) { |
| 493 component_mode = "shared_library" |
| 494 } else { |
| 495 component_mode = "source_set" |
| 496 } |
| 497 |
| 498 template("component") { |
| 499 if (is_component_build) { |
| 500 shared_library(target_name) { |
| 501 # Configs will always be defined since we set_defaults for a component |
| 502 # above. We want to use those rather than whatever came with the nested |
| 503 # shared/static library inside the component. |
| 504 configs = [] # Prevent list overwriting warning. |
| 505 configs = invoker.configs |
| 506 |
| 507 if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invo
ker.all_dependent_configs } |
| 508 if (defined(invoker.cflags)) { cflags = invoker.cflags } |
| 509 if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } |
| 510 if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } |
| 511 if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } |
| 512 if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } |
| 513 if (defined(invoker.data)) { data = invoker.data } |
| 514 if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } |
| 515 if (defined(invoker.defines)) { defines = invoker.defines } |
| 516 if (defined(invoker.deps)) { deps = invoker.deps } |
| 517 if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs
= invoker.direct_dependent_configs } |
| 518 if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_c
onfigs_from = invoker.forward_dependent_configs_from } |
| 519 if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } |
| 520 if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } |
| 521 if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } |
| 522 if (defined(invoker.libs)) { libs = invoker.libs } |
| 523 if (defined(invoker.output_extension)) { output_extension = invoker.output
_extension } |
| 524 if (defined(invoker.output_name)) { output_name = invoker.output_name } |
| 525 if (defined(invoker.public)) { public = invoker.public } |
| 526 if (defined(invoker.sources)) { sources = invoker.sources } |
| 527 if (defined(invoker.visibility)) { visibility = invoker.visibility } |
| 528 } |
| 529 } else { |
| 530 source_set(target_name) { |
| 531 # See above. |
| 532 configs = [] # Prevent list overwriting warning. |
| 533 configs = invoker.configs |
| 534 |
| 535 if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invo
ker.all_dependent_configs } |
| 536 if (defined(invoker.cflags)) { cflags = invoker.cflags } |
| 537 if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } |
| 538 if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } |
| 539 if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } |
| 540 if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } |
| 541 if (defined(invoker.data)) { data = invoker.data } |
| 542 if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } |
| 543 if (defined(invoker.defines)) { defines = invoker.defines } |
| 544 if (defined(invoker.deps)) { deps = invoker.deps } |
| 545 if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs
= invoker.direct_dependent_configs } |
| 546 if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_c
onfigs_from = invoker.forward_dependent_configs_from } |
| 547 if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } |
| 548 if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } |
| 549 if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } |
| 550 if (defined(invoker.libs)) { libs = invoker.libs } |
| 551 if (defined(invoker.output_extension)) { output_extension = invoker.output
_extension } |
| 552 if (defined(invoker.output_name)) { output_name = invoker.output_name } |
| 553 if (defined(invoker.public)) { public = invoker.public } |
| 554 if (defined(invoker.sources)) { sources = invoker.sources } |
| 555 if (defined(invoker.visibility)) { visibility = invoker.visibility } |
| 556 } |
| 557 } |
| 558 } |
| 559 |
| 560 # ============================================================================== |
| 561 # TEST SETUP |
| 562 # ============================================================================== |
| 563 |
| 564 # Define a test as an executable. In the future, we'll set "test only" flags |
| 565 # on this (when such flags exist) and do something different for Android. |
| 566 template("test") { |
| 567 executable(target_name) { |
| 568 # Configs will always be defined since we set_defaults for a component |
| 569 # above. We want to use those rather than whatever came with the nested |
| 570 # shared/static library inside the component. |
| 571 configs = [] # Prevent list overwriting warning. |
| 572 configs = invoker.configs |
| 573 |
| 574 if (defined(invoker.all_dependent_configs)) { all_dependent_configs = invoke
r.all_dependent_configs } |
| 575 if (defined(invoker.cflags)) { cflags = invoker.cflags } |
| 576 if (defined(invoker.cflags_c)) { cflags_c = invoker.cflags_c } |
| 577 if (defined(invoker.cflags_cc)) { cflags_cc = invoker.cflags_cc } |
| 578 if (defined(invoker.cflags_objc)) { cflags_objc = invoker.cflags_objc } |
| 579 if (defined(invoker.cflags_objcc)) { cflags_objcc = invoker.cflags_objcc } |
| 580 if (defined(invoker.data)) { data = invoker.data } |
| 581 if (defined(invoker.datadeps)) { datadeps = invoker.datadeps } |
| 582 if (defined(invoker.defines)) { defines = invoker.defines } |
| 583 if (defined(invoker.deps)) { deps = invoker.deps } |
| 584 if (defined(invoker.direct_dependent_configs)) { direct_dependent_configs =
invoker.direct_dependent_configs } |
| 585 if (defined(invoker.forward_dependent_configs_from)) { forward_dependent_con
figs_from = invoker.forward_dependent_configs_from } |
| 586 if (defined(invoker.include_dirs)) { include_dirs = invoker.include_dirs } |
| 587 if (defined(invoker.ldflags)) { ldflags = invoker.ldflags } |
| 588 if (defined(invoker.lib_dirs)) { lib_dirs = invoker.lib_dirs } |
| 589 if (defined(invoker.libs)) { libs = invoker.libs } |
| 590 if (defined(invoker.output_extension)) { output_extension = invoker.output_e
xtension } |
| 591 if (defined(invoker.output_name)) { output_name = invoker.output_name } |
| 592 if (defined(invoker.public)) { public = invoker.public } |
| 593 if (defined(invoker.sources)) { sources = invoker.sources } |
| 594 if (defined(invoker.visibility)) { visibility = invoker.visibility } |
| 595 } |
| 596 } |
OLD | NEW |