| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import("//build/config/mac/base_rules.gni") | 5 import("//build/config/mac/base_rules.gni") |
| 6 | 6 |
| 7 # Generates Info.plist files for Mac apps and frameworks. | 7 # Generates Info.plist files for Mac apps and frameworks. |
| 8 # | 8 # |
| 9 # Arguments | 9 # Arguments |
| 10 # | 10 # |
| 11 # info_plist: | 11 # info_plist: |
| 12 # string, the path to an plist file that will be included in the final | 12 # string, the path to an plist file that will be included in the final |
| 13 # Info.plist generated. | 13 # Info.plist generated. |
| 14 # | 14 # |
| 15 # executable_name: | 15 # executable_name: |
| 16 # string, name of the generated target used for the product | 16 # string, name of the generated target used for the product |
| 17 # and executable name as specified in the output Info.plist. | 17 # and executable name as specified in the output Info.plist. |
| 18 # | 18 # |
| 19 # extra_substitutions: | 19 # extra_substitutions: |
| 20 # (optional) string array, 'key=value' pairs for extra fields which are | 20 # (optional) string array, 'key=value' pairs for extra fields which are |
| 21 # specified in a source Info.plist template. | 21 # specified in a source Info.plist template. |
| 22 template("mac_info_plist") { | 22 template("mac_info_plist") { |
| 23 assert(defined(invoker.info_plist) != defined(invoker.info_plist_target), |
| 24 "Only one of info_plist or info_plist_target may be specified in " + |
| 25 target_name) |
| 26 |
| 27 if (defined(invoker.info_plist)) { |
| 28 _info_plist = invoker.info_plist |
| 29 } else { |
| 30 _info_plist_target_output = get_target_outputs(invoker.info_plist_target) |
| 31 _info_plist = _info_plist_target_output[0] |
| 32 } |
| 33 |
| 23 info_plist(target_name) { | 34 info_plist(target_name) { |
| 24 format = "xml1" | 35 format = "xml1" |
| 25 extra_substitutions = [] | 36 extra_substitutions = [] |
| 26 if (defined(invoker.extra_substitutions)) { | 37 if (defined(invoker.extra_substitutions)) { |
| 27 extra_substitutions = invoker.extra_substitutions | 38 extra_substitutions = invoker.extra_substitutions |
| 28 } | 39 } |
| 29 extra_substitutions += [ | 40 extra_substitutions += [ |
| 30 "MAC_SDK_BUILD=$mac_sdk_build", | 41 "MAC_SDK_BUILD=$mac_sdk_build", |
| 31 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", | 42 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", |
| 32 ] | 43 ] |
| 33 plist_templates = [ | 44 plist_templates = [ |
| 34 "//build/config/mac/BuildInfo.plist", | 45 "//build/config/mac/BuildInfo.plist", |
| 35 invoker.info_plist, | 46 _info_plist, |
| 36 ] | 47 ] |
| 37 forward_variables_from(invoker, [ "executable_name" ]) | 48 if (defined(invoker.info_plist_target)) { |
| 49 deps = [ |
| 50 invoker.info_plist_target, |
| 51 ] |
| 52 } |
| 53 forward_variables_from(invoker, |
| 54 [ |
| 55 "testonly", |
| 56 "executable_name", |
| 57 ]) |
| 38 } | 58 } |
| 39 } | 59 } |
| 40 | 60 |
| 41 # Template to compile and package Mac XIB files as bundle data. | 61 # Template to compile and package Mac XIB files as bundle data. |
| 42 # | 62 # |
| 43 # Arguments | 63 # Arguments |
| 44 # | 64 # |
| 45 # sources: | 65 # sources: |
| 46 # list of string, sources to comiple | 66 # list of string, sources to comiple |
| 47 # | 67 # |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 # This template provides two targets to control whether the framework is | 114 # This template provides two targets to control whether the framework is |
| 95 # merely built when targets depend on it, or whether it is linked as well: | 115 # merely built when targets depend on it, or whether it is linked as well: |
| 96 # "$target_name" and "$target_name+link". | 116 # "$target_name" and "$target_name+link". |
| 97 # | 117 # |
| 98 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion | 118 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion |
| 99 # and examples. | 119 # and examples. |
| 100 # | 120 # |
| 101 # Arguments | 121 # Arguments |
| 102 # | 122 # |
| 103 # info_plist: | 123 # info_plist: |
| 104 # string, path to the Info.plist file that will be used for the bundle. | 124 # (optional) string, path to the Info.plist file that will be used for |
| 125 # the bundle. |
| 126 # |
| 127 # info_plist_target: |
| 128 # (optional) string, if the info_plist is generated from an action, |
| 129 # rather than a regular source file, specify the target name in lieu |
| 130 # of info_plist. The two arguments are mutually exclusive. |
| 105 # | 131 # |
| 106 # output_name: | 132 # output_name: |
| 107 # (optional) string, name of the generated framework without the | 133 # (optional) string, name of the generated framework without the |
| 108 # .framework suffix. If omitted, defaults to target_name. | 134 # .framework suffix. If omitted, defaults to target_name. |
| 109 # | 135 # |
| 110 # framework_version: | 136 # framework_version: |
| 111 # (optional) string, version of the framework. Typically this is a | 137 # (optional) string, version of the framework. Typically this is a |
| 112 # single letter, like "A". If omitted, the Versions/ subdirectory | 138 # single letter, like "A". If omitted, the Versions/ subdirectory |
| 113 # structure will not be created, and build output will go directly | 139 # structure will not be created, and build output will go directly |
| 114 # into the framework subdirectory. | 140 # into the framework subdirectory. |
| 115 # | 141 # |
| 116 # See "gn help shared_library" for more information on arguments supported | 142 # See "gn help shared_library" for more information on arguments supported |
| 117 # by shared library target. | 143 # by shared library target. |
| 118 template("mac_framework_bundle") { | 144 template("mac_framework_bundle") { |
| 119 assert(defined(invoker.deps), | 145 assert(defined(invoker.deps), |
| 120 "Dependencies must be specified for $target_name") | 146 "Dependencies must be specified for $target_name") |
| 121 assert(defined(invoker.info_plist), | |
| 122 "The Info.plist file must be specified for $target_name") | |
| 123 | 147 |
| 124 _info_plist_target = target_name + "_info_plist" | 148 _info_plist_target = target_name + "_info_plist" |
| 125 | 149 |
| 126 mac_info_plist(_info_plist_target) { | 150 mac_info_plist(_info_plist_target) { |
| 127 executable_name = target_name | 151 executable_name = target_name |
| 128 if (defined(invoker.output_name)) { | 152 if (defined(invoker.output_name)) { |
| 129 executable_name = invoker.output_name | 153 executable_name = invoker.output_name |
| 130 } | 154 } |
| 131 forward_variables_from(invoker, [ "info_plist" ]) | 155 forward_variables_from(invoker, |
| 156 [ |
| 157 "testonly", |
| 158 "info_plist", |
| 159 "info_plist_target", |
| 160 ]) |
| 132 } | 161 } |
| 133 | 162 |
| 134 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 163 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 135 | 164 |
| 136 bundle_data(_info_plist_bundle_data) { | 165 bundle_data(_info_plist_bundle_data) { |
| 137 forward_variables_from(invoker, [ "testonly" ]) | 166 forward_variables_from(invoker, [ "testonly" ]) |
| 138 sources = get_target_outputs(":$_info_plist_target") | 167 sources = get_target_outputs(":$_info_plist_target") |
| 139 outputs = [ | 168 outputs = [ |
| 140 "{{bundle_root_dir}}/Info.plist", | 169 "{{bundle_root_dir}}/Info.plist", |
| 141 ] | 170 ] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 152 } | 181 } |
| 153 deps += [ ":$_info_plist_bundle_data" ] | 182 deps += [ ":$_info_plist_bundle_data" ] |
| 154 } | 183 } |
| 155 } | 184 } |
| 156 | 185 |
| 157 # Template to create a Mac executable application bundle. | 186 # Template to create a Mac executable application bundle. |
| 158 # | 187 # |
| 159 # Arguments | 188 # Arguments |
| 160 # | 189 # |
| 161 # info_plist: | 190 # info_plist: |
| 162 # string, path to the Info.plist file that will be used for the bundle. | 191 # (optional) string, path to the Info.plist file that will be used for |
| 192 # the bundle. |
| 193 # |
| 194 # info_plist_target: |
| 195 # (optional) string, if the info_plist is generated from an action, |
| 196 # rather than a regular source file, specify the target name in lieu |
| 197 # of info_plist. The two arguments are mutually exclusive. |
| 163 # | 198 # |
| 164 # output_name: | 199 # output_name: |
| 165 # (optional) string, name of the generated app without the | 200 # (optional) string, name of the generated app without the |
| 166 # .app suffix. If omitted, defaults to target_name. | 201 # .app suffix. If omitted, defaults to target_name. |
| 167 # | 202 # |
| 168 # extra_configs: | 203 # extra_configs: |
| 169 # (optional) list of label, additional configs to apply to the | 204 # (optional) list of label, additional configs to apply to the |
| 170 # executable target. | 205 # executable target. |
| 171 template("mac_app_bundle") { | 206 template("mac_app_bundle") { |
| 172 assert(defined(invoker.info_plist), | |
| 173 "The Info.plist file must be specified for $target_name") | |
| 174 | |
| 175 _target_name = target_name | 207 _target_name = target_name |
| 176 _output_name = target_name | 208 _output_name = target_name |
| 177 if (defined(invoker.output_name)) { | 209 if (defined(invoker.output_name)) { |
| 178 _output_name = invoker.output_name | 210 _output_name = invoker.output_name |
| 179 } | 211 } |
| 180 | 212 |
| 181 _executable_target = target_name + "_executable" | 213 _executable_target = target_name + "_executable" |
| 182 _executable_bundle_data = _executable_target + "_bundle_data" | 214 _executable_bundle_data = _executable_target + "_bundle_data" |
| 183 | 215 |
| 216 _info_plist_target = target_name + "_info_plist" |
| 217 |
| 218 mac_info_plist(_info_plist_target) { |
| 219 executable_name = _output_name |
| 220 forward_variables_from(invoker, |
| 221 [ |
| 222 "testonly", |
| 223 "info_plist", |
| 224 "info_plist_target", |
| 225 ]) |
| 226 } |
| 227 |
| 184 executable(_executable_target) { | 228 executable(_executable_target) { |
| 185 visibility = [ ":$_executable_bundle_data" ] | 229 visibility = [ ":$_executable_bundle_data" ] |
| 186 forward_variables_from(invoker, | 230 forward_variables_from(invoker, |
| 187 "*", | 231 "*", |
| 188 [ | 232 [ |
| 189 "assert_no_deps", | 233 "assert_no_deps", |
| 190 "data_deps", | 234 "data_deps", |
| 191 "info_plist", | 235 "info_plist", |
| 192 "output_name", | 236 "output_name", |
| 193 "visibility", | 237 "visibility", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 206 "$target_out_dir/$_executable_target/$_output_name", | 250 "$target_out_dir/$_executable_target/$_output_name", |
| 207 ] | 251 ] |
| 208 outputs = [ | 252 outputs = [ |
| 209 "{{bundle_executable_dir}}/$_output_name", | 253 "{{bundle_executable_dir}}/$_output_name", |
| 210 ] | 254 ] |
| 211 public_deps = [ | 255 public_deps = [ |
| 212 ":$_executable_target", | 256 ":$_executable_target", |
| 213 ] | 257 ] |
| 214 } | 258 } |
| 215 | 259 |
| 216 _info_plist_target = target_name + "_info_plist" | |
| 217 | |
| 218 mac_info_plist(_info_plist_target) { | |
| 219 executable_name = _output_name | |
| 220 forward_variables_from(invoker, [ "info_plist" ]) | |
| 221 } | |
| 222 | |
| 223 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 260 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 224 | 261 |
| 225 bundle_data(_info_plist_bundle_data) { | 262 bundle_data(_info_plist_bundle_data) { |
| 226 forward_variables_from(invoker, [ "testonly" ]) | 263 forward_variables_from(invoker, [ "testonly" ]) |
| 227 visibility = [ ":$_target_name" ] | 264 visibility = [ ":$_target_name" ] |
| 228 sources = get_target_outputs(":$_info_plist_target") | 265 sources = get_target_outputs(":$_info_plist_target") |
| 229 outputs = [ | 266 outputs = [ |
| 230 "{{bundle_root_dir}}/Info.plist", | 267 "{{bundle_root_dir}}/Info.plist", |
| 231 ] | 268 ] |
| 232 public_deps = [ | 269 public_deps = [ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 ]) | 348 ]) |
| 312 if (!defined(deps)) { | 349 if (!defined(deps)) { |
| 313 deps = [] | 350 deps = [] |
| 314 } | 351 } |
| 315 deps += [ ":$_loadable_module_bundle_data" ] | 352 deps += [ ":$_loadable_module_bundle_data" ] |
| 316 | 353 |
| 317 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 354 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
| 318 bundle_executable_dir = "$bundle_root_dir/MacOS" | 355 bundle_executable_dir = "$bundle_root_dir/MacOS" |
| 319 } | 356 } |
| 320 } | 357 } |
| OLD | NEW |