Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: build/config/BUILDCONFIG.gn

Issue 2060983002: Default components to static libraries in GN build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | build/config/chrome_build.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. 114 # Component build. Setting to true compiles targets declared as "components"
115 # as shared libraries loaded dynamically. This speeds up development time.
116 # When false, components will be linked statically.
115 is_component_build = false 117 is_component_build = false
116 118
117 # Debug build. 119 # Set to enable the official build level of optimization. This has nothing
118 is_debug = true 120 # to do with branding, but enables an additional level of optimization above
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
119 128
120 # Whether we're a traditional desktop unix. 129 # Whether we're a traditional desktop unix.
121 is_desktop_linux = current_os == "linux" 130 is_desktop_linux = current_os == "linux"
122 131
123 # Set to true when compiling with the Clang compiler. Typically this is used 132 # Set to true when compiling with the Clang compiler. Typically this is used
124 # to configure warnings. 133 # to configure warnings.
125 is_clang = current_os == "mac" || current_os == "ios" || 134 is_clang = current_os == "mac" || current_os == "ios" ||
126 current_os == "linux" || current_os == "chromeos" 135 current_os == "linux" || current_os == "chromeos"
127 136
128 # Allows the path to a custom target toolchain to be injected as a single 137 # Allows the path to a custom target toolchain to be injected as a single
129 # argument, and set as the default toolchain. 138 # argument, and set as the default toolchain.
130 custom_toolchain = "" 139 custom_toolchain = ""
131 140
132 # This should not normally be set as a build argument. It's here so that 141 # This should not normally be set as a build argument. It's here so that
133 # every toolchain can pass through the "global" value via toolchain_args(). 142 # every toolchain can pass through the "global" value via toolchain_args().
134 host_toolchain = "" 143 host_toolchain = ""
135 144
136 # DON'T ADD MORE FLAGS HERE. Read the comment above. 145 # DON'T ADD MORE FLAGS HERE. Read the comment above.
137 } 146 }
138 147
148 assert(!(is_debug && is_official_build), "Can't do official debug builds")
149
139 # ============================================================================== 150 # ==============================================================================
140 # TOOLCHAIN SETUP 151 # TOOLCHAIN SETUP
141 # ============================================================================== 152 # ==============================================================================
142 # 153 #
143 # Here we set the default toolchain, as well as the variable host_toolchain 154 # Here we set the default toolchain, as well as the variable host_toolchain
144 # which will identify the toolchain corresponding to the local system when 155 # which will identify the toolchain corresponding to the local system when
145 # doing cross-compiles. When not cross-compiling, this will be the same as the 156 # doing cross-compiles. When not cross-compiling, this will be the same as the
146 # default toolchain. 157 # default toolchain.
147 # 158 #
148 # We do this before anything else to make sure we complain about any 159 # 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
589 } else { 600 } else {
590 configs = _executable_configs 601 configs = _executable_configs
591 } 602 }
592 } 603 }
593 604
594 # ============================================================================== 605 # ==============================================================================
595 # COMPONENT SETUP 606 # COMPONENT SETUP
596 # ============================================================================== 607 # ==============================================================================
597 608
598 # Defines a component, which equates to a shared_library when 609 # Defines a component, which equates to a shared_library when
599 # is_component_build == true and a source_set / static_library otherwise. 610 # is_component_build == true and a static_library otherwise.
600 # 611 #
601 # Arguments are the same as a normal library with this addition: 612 # Use static libraries for the static build rather than source sets because
602 # component_never_use_source_set: Whether to use static_library instead of 613 # many of of our test binaries link many large dependencies but often don't
603 # source_set for non-component builds. Some targets (e.g. //base) should 614 # use large portions of them. The static libraries are much more efficient to
604 # use static_library rather than source_set to avoid linking unused object 615 # link in this situation since only the necessary object files are linked.
605 # files. 616 #
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.
606 template("component") { 620 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) { 621 if (is_component_build) {
611 _component_mode = "shared_library" 622 _component_mode = "shared_library"
612 } else if (_never_use_source_set) { 623 } else if (defined(invoker.static_component_type)) {
624 assert(invoker.static_component_type == "static_library" ||
625 invoker.static_component_type == "source_set")
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"
640 } else {
613 _component_mode = "static_library" 641 _component_mode = "static_library"
614 } else {
615 _component_mode = "source_set"
616 } 642 }
617 target(_component_mode, target_name) { 643 target(_component_mode, target_name) {
618 # Explicitly forward visibility, implicitly forward everything else. 644 # Explicitly forward visibility, implicitly forward everything else.
619 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all 645 # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all
620 # globals into each template invocation), so won't pick up file-scoped 646 # globals into each template invocation), so won't pick up file-scoped
621 # variables. Normally this isn't too bad, but visibility is commonly 647 # variables. Normally this isn't too bad, but visibility is commonly
622 # defined at the file scope. Explicitly forwarding visibility and then 648 # defined at the file scope. Explicitly forwarding visibility and then
623 # excluding it from the "*" set works around this problem. 649 # excluding it from the "*" set works around this problem.
624 # See http://crbug.com/594610 650 # See http://crbug.com/594610
625 forward_variables_from(invoker, [ "visibility" ]) 651 forward_variables_from(invoker, [ "visibility" ])
626 forward_variables_from(invoker, "*", [ "visibility" ]) 652 forward_variables_from(invoker, "*", [ "visibility" ])
627 653
628 # All shared libraries must have the sanitizer deps to properly link in 654 # All shared libraries must have the sanitizer deps to properly link in
629 # asan mode (this target will be empty in other cases). 655 # asan mode (this target will be empty in other cases).
630 if (!defined(deps)) { 656 if (!defined(deps)) {
631 deps = [] 657 deps = []
632 } 658 }
633 deps += [ "//build/config/sanitizers:deps" ] 659 deps += [ "//build/config/sanitizers:deps" ]
634 } 660 }
635 } 661 }
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | build/config/chrome_build.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698