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 # PLATFORM SELECTION | 6 # PLATFORM SELECTION |
7 # ============================================================================= | 7 # ============================================================================= |
8 # | 8 # |
9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name | 9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name |
10 # of the GN thing that encodes combinations of these things. | 10 # of the GN thing that encodes combinations of these things. |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 } else { | 589 } else { |
590 configs = _executable_configs | 590 configs = _executable_configs |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 # ============================================================================== | 594 # ============================================================================== |
595 # COMPONENT SETUP | 595 # COMPONENT SETUP |
596 # ============================================================================== | 596 # ============================================================================== |
597 | 597 |
598 # Defines a component, which equates to a shared_library when | 598 # Defines a component, which equates to a shared_library when |
599 # is_component_build == true and a static_library otherwise. | 599 # is_component_build == true and a source_set / static_library otherwise. |
600 # | 600 # |
601 # Use static libraries for the static build rather than source sets because | 601 # Arguments are the same as a normal library with this addition: |
602 # many of of our test binaries link many large dependencies but often don't | 602 # component_never_use_source_set: Whether to use static_library instead of |
603 # use large portions of them. The static libraries are much more efficient to | 603 # source_set for non-component builds. Some targets (e.g. //base) should |
604 # link in this situation since only the necessary object files are linked. | 604 # use static_library rather than source_set to avoid linking unused object |
605 # | 605 # files. |
606 # The invoker can override the type of the target in the non-component-build | |
607 # case by setting static_component_type to either "source_set" or | |
608 # "static_library". If unset, the default will be used. | |
609 template("component") { | 606 template("component") { |
| 607 _never_use_source_set = defined(invoker.component_never_use_source_set) && |
| 608 invoker.component_never_use_source_set |
| 609 assert(_never_use_source_set || true) # Mark as used. |
610 if (is_component_build) { | 610 if (is_component_build) { |
611 _component_mode = "shared_library" | 611 _component_mode = "shared_library" |
612 } else if (defined(invoker.static_component_type)) { | 612 } else if (_never_use_source_set) { |
613 assert(invoker.static_component_type == "static_library" || | 613 _component_mode = "static_library" |
614 invoker.static_component_type == "source_set") | 614 } else { |
615 _component_mode = invoker.static_component_type | |
616 } else if (!defined(invoker.sources) || is_mac) { | |
617 # When there are no sources defined, use a source set to avoid creating | |
618 # an empty static library (which generally don't work). | |
619 # | |
620 # TODO(brettw) bug 618797: On Mac making these as static_library causes | |
621 # crashes. Remove the mac condition above when this is fixed. | |
622 _component_mode = "source_set" | 615 _component_mode = "source_set" |
623 } else { | |
624 _component_mode = "static_library" | |
625 } | 616 } |
626 target(_component_mode, target_name) { | 617 target(_component_mode, target_name) { |
627 # Explicitly forward visibility, implicitly forward everything else. | 618 # Explicitly forward visibility, implicitly forward everything else. |
628 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all | 619 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all |
629 # globals into each template invocation), so won't pick up file-scoped | 620 # globals into each template invocation), so won't pick up file-scoped |
630 # variables. Normally this isn't too bad, but visibility is commonly | 621 # variables. Normally this isn't too bad, but visibility is commonly |
631 # defined at the file scope. Explicitly forwarding visibility and then | 622 # defined at the file scope. Explicitly forwarding visibility and then |
632 # excluding it from the "*" set works around this problem. | 623 # excluding it from the "*" set works around this problem. |
633 # See http://crbug.com/594610 | 624 # See http://crbug.com/594610 |
634 forward_variables_from(invoker, [ "visibility" ]) | 625 forward_variables_from(invoker, [ "visibility" ]) |
635 forward_variables_from(invoker, "*", [ "visibility" ]) | 626 forward_variables_from(invoker, "*", [ "visibility" ]) |
636 | 627 |
637 # All shared libraries must have the sanitizer deps to properly link in | 628 # All shared libraries must have the sanitizer deps to properly link in |
638 # asan mode (this target will be empty in other cases). | 629 # asan mode (this target will be empty in other cases). |
639 if (!defined(deps)) { | 630 if (!defined(deps)) { |
640 deps = [] | 631 deps = [] |
641 } | 632 } |
642 deps += [ "//build/config/sanitizers:deps" ] | 633 deps += [ "//build/config/sanitizers:deps" ] |
643 } | 634 } |
644 } | 635 } |
OLD | NEW |