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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for | 104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for |
105 # your feature) rather than just "foo". | 105 # your feature) rather than just "foo". |
106 # | 106 # |
107 # - Write good comments directly above the declaration with no blank line. | 107 # - Write good comments directly above the declaration with no blank line. |
108 # These comments will appear as documentation in "gn args --list". | 108 # These comments will appear as documentation in "gn args --list". |
109 # | 109 # |
110 # - Don't call exec_script inside declare_args. This will execute the script | 110 # - Don't call exec_script inside declare_args. This will execute the script |
111 # even if the value is overridden, which is wasteful. See first bullet. | 111 # even if the value is overridden, which is wasteful. See first bullet. |
112 | 112 |
113 declare_args() { | 113 declare_args() { |
114 # Component build. Setting to true compiles targets declared as "components" | 114 # Component build. |
115 # as shared libraries loaded dynamically. This speeds up development time. | |
116 # When false, components will be linked statically. | |
117 is_component_build = false | 115 is_component_build = false |
118 | 116 |
119 # Set to enable the official build level of optimization. This has nothing | 117 # Debug build. |
120 # to do with branding, but enables an additional level of optimization above | 118 is_debug = true |
121 # release (!is_debug). This might be better expressed as a tri-state | |
122 # (debug, release, official) but for historical reasons there are two | |
123 # separate flags. | |
124 is_official_build = false | |
125 | |
126 # Debug build. Enabling official builds automatically sets is_debug to false. | |
127 is_debug = !is_official_build | |
128 | 119 |
129 # Whether we're a traditional desktop unix. | 120 # Whether we're a traditional desktop unix. |
130 is_desktop_linux = current_os == "linux" | 121 is_desktop_linux = current_os == "linux" |
131 | 122 |
132 # Set to true when compiling with the Clang compiler. Typically this is used | 123 # Set to true when compiling with the Clang compiler. Typically this is used |
133 # to configure warnings. | 124 # to configure warnings. |
134 is_clang = current_os == "mac" || current_os == "ios" || | 125 is_clang = current_os == "mac" || current_os == "ios" || |
135 current_os == "linux" || current_os == "chromeos" | 126 current_os == "linux" || current_os == "chromeos" |
136 | 127 |
137 # Allows the path to a custom target toolchain to be injected as a single | 128 # Allows the path to a custom target toolchain to be injected as a single |
138 # argument, and set as the default toolchain. | 129 # argument, and set as the default toolchain. |
139 custom_toolchain = "" | 130 custom_toolchain = "" |
140 | 131 |
141 # This should not normally be set as a build argument. It's here so that | 132 # This should not normally be set as a build argument. It's here so that |
142 # every toolchain can pass through the "global" value via toolchain_args(). | 133 # every toolchain can pass through the "global" value via toolchain_args(). |
143 host_toolchain = "" | 134 host_toolchain = "" |
144 | 135 |
145 # DON'T ADD MORE FLAGS HERE. Read the comment above. | 136 # DON'T ADD MORE FLAGS HERE. Read the comment above. |
146 } | 137 } |
147 | 138 |
148 assert(!(is_debug && is_official_build), "Can't do official debug builds") | |
149 | |
150 # ============================================================================== | 139 # ============================================================================== |
151 # TOOLCHAIN SETUP | 140 # TOOLCHAIN SETUP |
152 # ============================================================================== | 141 # ============================================================================== |
153 # | 142 # |
154 # Here we set the default toolchain, as well as the variable host_toolchain | 143 # Here we set the default toolchain, as well as the variable host_toolchain |
155 # which will identify the toolchain corresponding to the local system when | 144 # which will identify the toolchain corresponding to the local system when |
156 # doing cross-compiles. When not cross-compiling, this will be the same as the | 145 # doing cross-compiles. When not cross-compiling, this will be the same as the |
157 # default toolchain. | 146 # default toolchain. |
158 # | 147 # |
159 # We do this before anything else to make sure we complain about any | 148 # We do this before anything else to make sure we complain about any |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } else { | 589 } else { |
601 configs = _executable_configs | 590 configs = _executable_configs |
602 } | 591 } |
603 } | 592 } |
604 | 593 |
605 # ============================================================================== | 594 # ============================================================================== |
606 # COMPONENT SETUP | 595 # COMPONENT SETUP |
607 # ============================================================================== | 596 # ============================================================================== |
608 | 597 |
609 # Defines a component, which equates to a shared_library when | 598 # Defines a component, which equates to a shared_library when |
610 # is_component_build == true and a static_library otherwise. | 599 # is_component_build == true and a source_set / static_library otherwise. |
611 # | 600 # |
612 # Use static libraries for the static build rather than source sets because | 601 # Arguments are the same as a normal library with this addition: |
613 # 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 |
614 # 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 |
615 # 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 |
616 # | 605 # files. |
617 # The invoker can override the type of the target in the non-component-build | |
618 # case by setting static_component_type to either "source_set" or | |
619 # "static_library". If unset, the default will be used. | |
620 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. |
621 if (is_component_build) { | 610 if (is_component_build) { |
622 _component_mode = "shared_library" | 611 _component_mode = "shared_library" |
623 } else if (defined(invoker.static_component_type)) { | 612 } else if (_never_use_source_set) { |
624 assert(invoker.static_component_type == "static_library" || | 613 _component_mode = "static_library" |
625 invoker.static_component_type == "source_set") | 614 } else { |
626 _component_mode = invoker.static_component_type | |
627 } else if (!defined(invoker.sources) || is_mac || | |
628 (is_win && is_official_build)) { | |
629 # When there are no sources defined, use a source set to avoid creating | |
630 # an empty static library (which generally don't work). | |
631 # | |
632 # On Windows official builds, the link time code generation bloats static | |
633 # libraries to the point where some of them become >32 bits large which | |
634 # causes lib.exe to fail. Always use source sets for that configuration. | |
635 # | |
636 # TODO(brettw) bug 618797: Remove the mac condition. On Mac making these as | |
637 # static_library causes crashes. Remove the mac condition above when this | |
638 # is fixed. | |
639 _component_mode = "source_set" | 615 _component_mode = "source_set" |
640 } else { | |
641 _component_mode = "static_library" | |
642 } | 616 } |
643 target(_component_mode, target_name) { | 617 target(_component_mode, target_name) { |
644 # Explicitly forward visibility, implicitly forward everything else. | 618 # Explicitly forward visibility, implicitly forward everything else. |
645 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all | 619 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all |
646 # 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 |
647 # variables. Normally this isn't too bad, but visibility is commonly | 621 # variables. Normally this isn't too bad, but visibility is commonly |
648 # defined at the file scope. Explicitly forwarding visibility and then | 622 # defined at the file scope. Explicitly forwarding visibility and then |
649 # excluding it from the "*" set works around this problem. | 623 # excluding it from the "*" set works around this problem. |
650 # See http://crbug.com/594610 | 624 # See http://crbug.com/594610 |
651 forward_variables_from(invoker, [ "visibility" ]) | 625 forward_variables_from(invoker, [ "visibility" ]) |
652 forward_variables_from(invoker, "*", [ "visibility" ]) | 626 forward_variables_from(invoker, "*", [ "visibility" ]) |
653 | 627 |
654 # 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 |
655 # asan mode (this target will be empty in other cases). | 629 # asan mode (this target will be empty in other cases). |
656 if (!defined(deps)) { | 630 if (!defined(deps)) { |
657 deps = [] | 631 deps = [] |
658 } | 632 } |
659 deps += [ "//build/config/sanitizers:deps" ] | 633 deps += [ "//build/config/sanitizers:deps" ] |
660 } | 634 } |
661 } | 635 } |
OLD | NEW |