| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 # you can just declare it in the corresponding BUILD.gn file. If you need a | 72 # you can just declare it in the corresponding BUILD.gn file. If you need a |
| 73 # flag in multiple components, there are a few options: | 73 # flag in multiple components, there are a few options: |
| 74 # | 74 # |
| 75 # - If your feature is a single target, say //components/foo, and the targets | 75 # - If your feature is a single target, say //components/foo, and the targets |
| 76 # depending on foo need to have some define set if foo is enabled: (1) Write | 76 # depending on foo need to have some define set if foo is enabled: (1) Write |
| 77 # a declare_args block in foo's BUILD.gn file listing your enable_foo build | 77 # a declare_args block in foo's BUILD.gn file listing your enable_foo build |
| 78 # flag. (2) Write a config in that file listing the define, and list that | 78 # flag. (2) Write a config in that file listing the define, and list that |
| 79 # config in foo's public_configs. This will propagate that define to all the | 79 # config in foo's public_configs. This will propagate that define to all the |
| 80 # targets depending on foo. (3) When foo is not enabled, just make it expand | 80 # targets depending on foo. (3) When foo is not enabled, just make it expand |
| 81 # to an empty group (or whatever's appropriate for the "off" state of your | 81 # to an empty group (or whatever's appropriate for the "off" state of your |
| 82 # feature. | 82 # feature). |
| 83 # | 83 # |
| 84 # - If a semi-random set of targets need to know about a define: (1) In the | 84 # - If a semi-random set of targets need to know about a define: (1) In the |
| 85 # lowest level of the build that knows about this feature, add a declare_args | 85 # lowest level of the build that knows about this feature, add a declare_args |
| 86 # block in the build file for your enable flag. (2) Write a config that adds | 86 # block in the build file for your enable flag. (2) Write a config that adds |
| 87 # a define conditionally based on that build flags. (3) Manually add that | 87 # a define conditionally based on that build flags. (3) Manually add that |
| 88 # config to the "configs" applying to the targets that need the define. | 88 # config to the "configs" applying to the targets that need the define. |
| 89 # | 89 # |
| 90 # - If a semi-random set of targets need to know about the build flag (to do | 90 # - If a semi-random set of targets need to know about the build flag (to do |
| 91 # file inclusion or exclusion, more than just defines): (1) Write a .gni file | 91 # file inclusion or exclusion, more than just defines): (1) Write a .gni file |
| 92 # in the lowest-level directory that knows about the feature. (2) Put the | 92 # in the lowest-level directory that knows about the feature. (2) Put the |
| (...skipping 11 matching lines...) Expand all 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" | |
| 115 # as shared libraries loaded dynamically. This speeds up development time. | |
| 116 # When false, components will be linked statically. | |
| 117 is_component_build = false | |
| 118 | |
| 119 # Set to enable the official build level of optimization. This has nothing | 114 # Set to enable the official build level of optimization. This has nothing |
| 120 # to do with branding, but enables an additional level of optimization above | 115 # 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 | 116 # release (!is_debug). This might be better expressed as a tri-state |
| 122 # (debug, release, official) but for historical reasons there are two | 117 # (debug, release, official) but for historical reasons there are two |
| 123 # separate flags. | 118 # separate flags. |
| 124 is_official_build = false | 119 is_official_build = false |
| 125 | 120 |
| 126 # Debug build. Enabling official builds automatically sets is_debug to false. | 121 # Debug build. Enabling official builds automatically sets is_debug to false. |
| 127 is_debug = !is_official_build | 122 is_debug = !is_official_build |
| 128 | 123 |
| 129 # Whether we're a traditional desktop unix. | 124 # Whether we're a traditional desktop unix. |
| 130 is_desktop_linux = current_os == "linux" | 125 is_desktop_linux = current_os == "linux" |
| 131 | 126 |
| 132 # Set to true when compiling with the Clang compiler. Typically this is used | 127 # Set to true when compiling with the Clang compiler. Typically this is used |
| 133 # to configure warnings. | 128 # to configure warnings. |
| 134 is_clang = current_os == "mac" || current_os == "ios" || | 129 is_clang = current_os == "mac" || current_os == "ios" || |
| 135 current_os == "linux" || current_os == "chromeos" | 130 current_os == "linux" || current_os == "chromeos" |
| 136 | 131 |
| 137 # Allows the path to a custom target toolchain to be injected as a single | 132 # Allows the path to a custom target toolchain to be injected as a single |
| 138 # argument, and set as the default toolchain. | 133 # argument, and set as the default toolchain. |
| 139 custom_toolchain = "" | 134 custom_toolchain = "" |
| 140 | 135 |
| 141 # This should not normally be set as a build argument. It's here so that | 136 # 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(). | 137 # every toolchain can pass through the "global" value via toolchain_args(). |
| 143 host_toolchain = "" | 138 host_toolchain = "" |
| 144 | 139 |
| 145 # DON'T ADD MORE FLAGS HERE. Read the comment above. | 140 # DON'T ADD MORE FLAGS HERE. Read the comment above. |
| 146 } | 141 } |
| 147 | 142 |
| 143 declare_args() { |
| 144 # Component build. Setting to true compiles targets declared as "components" |
| 145 # as shared libraries loaded dynamically. This speeds up development time. |
| 146 # When false, components will be linked statically. |
| 147 is_component_build = is_debug && current_os != "ios" |
| 148 } |
| 149 |
| 148 assert(!(is_debug && is_official_build), "Can't do official debug builds") | 150 assert(!(is_debug && is_official_build), "Can't do official debug builds") |
| 149 | 151 |
| 150 # ============================================================================== | 152 # ============================================================================== |
| 151 # TOOLCHAIN SETUP | 153 # TOOLCHAIN SETUP |
| 152 # ============================================================================== | 154 # ============================================================================== |
| 153 # | 155 # |
| 154 # Here we set the default toolchain, as well as the variable host_toolchain | 156 # 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 | 157 # 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 | 158 # doing cross-compiles. When not cross-compiling, this will be the same as the |
| 157 # default toolchain. | 159 # default toolchain. |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 set_defaults("component") { | 632 set_defaults("component") { |
| 631 if (is_component_build) { | 633 if (is_component_build) { |
| 632 configs = default_shared_library_configs | 634 configs = default_shared_library_configs |
| 633 if (is_android) { | 635 if (is_android) { |
| 634 configs -= [ "//build/config/android:hide_native_jni_exports" ] | 636 configs -= [ "//build/config/android:hide_native_jni_exports" ] |
| 635 } | 637 } |
| 636 } else { | 638 } else { |
| 637 configs = default_compiler_configs | 639 configs = default_compiler_configs |
| 638 } | 640 } |
| 639 } | 641 } |
| OLD | NEW |