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 # (optional) string, path to the Info.plist file that will be used for |
13 # Info.plist generated. | 13 # the bundle. |
| 14 # |
| 15 # info_plist_target: |
| 16 # (optional) string, if the info_plist is generated from an action, |
| 17 # rather than a regular source file, specify the target name in lieu |
| 18 # of info_plist. The two arguments are mutually exclusive. |
14 # | 19 # |
15 # executable_name: | 20 # executable_name: |
16 # string, name of the generated target used for the product | 21 # string, name of the generated target used for the product |
17 # and executable name as specified in the output Info.plist. | 22 # and executable name as specified in the output Info.plist. |
18 # | 23 # |
19 # extra_substitutions: | 24 # extra_substitutions: |
20 # (optional) string array, 'key=value' pairs for extra fields which are | 25 # (optional) string array, 'key=value' pairs for extra fields which are |
21 # specified in a source Info.plist template. | 26 # specified in a source Info.plist template. |
22 template("ios_info_plist") { | 27 template("ios_info_plist") { |
| 28 assert(defined(invoker.info_plist) != defined(invoker.info_plist_target), |
| 29 "Only one of info_plist or info_plist_target may be specified in " + |
| 30 target_name) |
| 31 |
| 32 if (defined(invoker.info_plist)) { |
| 33 _info_plist = invoker.info_plist |
| 34 } else { |
| 35 _info_plist_target_output = get_target_outputs(invoker.info_plist_target) |
| 36 _info_plist = _info_plist_target_output[0] |
| 37 } |
| 38 |
23 info_plist(target_name) { | 39 info_plist(target_name) { |
24 format = "binary1" | 40 format = "binary1" |
25 extra_substitutions = [] | 41 extra_substitutions = [] |
26 if (defined(invoker.extra_substitutions)) { | 42 if (defined(invoker.extra_substitutions)) { |
27 extra_substitutions = invoker.extra_substitutions | 43 extra_substitutions = invoker.extra_substitutions |
28 } | 44 } |
29 extra_substitutions += [ | 45 extra_substitutions += [ |
30 "IOS_DEPLOYMENT_TARGET=$ios_deployment_target", | 46 "IOS_DEPLOYMENT_TARGET=$ios_deployment_target", |
31 "IOS_PLATFORM_BUILD=$ios_platform_build", | 47 "IOS_PLATFORM_BUILD=$ios_platform_build", |
32 "IOS_PLATFORM_NAME=$ios_sdk_name", | 48 "IOS_PLATFORM_NAME=$ios_sdk_name", |
33 "IOS_PLATFORM_VERSION=$ios_sdk_version", | 49 "IOS_PLATFORM_VERSION=$ios_sdk_version", |
34 "IOS_SDK_BUILD=$ios_sdk_build", | 50 "IOS_SDK_BUILD=$ios_sdk_build", |
35 "IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version", | 51 "IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version", |
36 "IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", | 52 "IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", |
37 ] | 53 ] |
38 plist_templates = [ | 54 plist_templates = [ |
39 "//build/config/ios/BuildInfo.plist", | 55 "//build/config/ios/BuildInfo.plist", |
40 invoker.info_plist, | 56 _info_plist, |
41 ] | 57 ] |
| 58 if (defined(invoker.info_plist_target)) { |
| 59 deps = [ |
| 60 invoker.info_plist_target, |
| 61 ] |
| 62 } |
42 forward_variables_from(invoker, | 63 forward_variables_from(invoker, |
43 [ | 64 [ |
44 "executable_name", | 65 "executable_name", |
45 "output_name", | 66 "output_name", |
46 "visibility", | 67 "visibility", |
47 ]) | 68 ]) |
48 } | 69 } |
49 } | 70 } |
50 | 71 |
51 # TODO(crbug.com/297668): refactor this template to extract common behaviour | 72 # TODO(crbug.com/297668): refactor this template to extract common behaviour |
(...skipping 12 matching lines...) Expand all Loading... |
64 # output_name: | 85 # output_name: |
65 # (optional) string, name of the generated application, if omitted, | 86 # (optional) string, name of the generated application, if omitted, |
66 # defaults to the target_name. | 87 # defaults to the target_name. |
67 # | 88 # |
68 # extra_substitutions: | 89 # extra_substitutions: |
69 # (optional) list of string in "key=value" format, each value will | 90 # (optional) list of string in "key=value" format, each value will |
70 # be used as an additional variable substitution rule when generating | 91 # be used as an additional variable substitution rule when generating |
71 # the application Info.plist | 92 # the application Info.plist |
72 # | 93 # |
73 # info_plist: | 94 # info_plist: |
74 # path to the template to use to generate the application Info.plist | 95 # (optional) string, path to the Info.plist file that will be used for |
75 # by performing variable substitutions. | 96 # the bundle. |
| 97 # |
| 98 # info_plist_target: |
| 99 # (optional) string, if the info_plist is generated from an action, |
| 100 # rather than a regular source file, specify the target name in lieu |
| 101 # of info_plist. The two arguments are mutually exclusive. |
76 # | 102 # |
77 # bundle_extension: | 103 # bundle_extension: |
78 # (optional) bundle extension including the dot, default to ".app". | 104 # (optional) bundle extension including the dot, default to ".app". |
79 # | 105 # |
80 # product_type | 106 # product_type |
81 # (optional) string, product type for the generated Xcode project, | 107 # (optional) string, product type for the generated Xcode project, |
82 # default to "com.apple.product-type.application". Should generally | 108 # default to "com.apple.product-type.application". Should generally |
83 # not be overridden. | 109 # not be overridden. |
84 # | 110 # |
85 # For more information, see "gn help executable". | 111 # For more information, see "gn help executable". |
86 template("ios_app_bundle") { | 112 template("ios_app_bundle") { |
87 assert(defined(invoker.info_plist), | |
88 "info_plist must be specified for target $target_name") | |
89 | |
90 _output_name = target_name | 113 _output_name = target_name |
91 _target_name = target_name | 114 _target_name = target_name |
92 if (defined(invoker.output_name)) { | 115 if (defined(invoker.output_name)) { |
93 _output_name = invoker.output_name | 116 _output_name = invoker.output_name |
94 } | 117 } |
95 | 118 |
96 _generate_info_plist = target_name + "_generate_info_plist" | 119 _generate_info_plist = target_name + "_generate_info_plist" |
97 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | 120 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" |
98 | 121 |
99 ios_info_plist(_generate_info_plist) { | 122 ios_info_plist(_generate_info_plist) { |
100 executable_name = _output_name | 123 executable_name = _output_name |
101 forward_variables_from(invoker, | 124 forward_variables_from(invoker, |
102 [ | 125 [ |
103 "extra_substitutions", | 126 "extra_substitutions", |
104 "info_plist", | 127 "info_plist", |
| 128 "info_plist_target", |
105 ]) | 129 ]) |
106 } | 130 } |
107 | 131 |
108 bundle_data(_bundle_data_info_plist) { | 132 bundle_data(_bundle_data_info_plist) { |
109 forward_variables_from(invoker, [ "testonly" ]) | 133 forward_variables_from(invoker, [ "testonly" ]) |
110 visibility = [ ":$_target_name" ] | 134 visibility = [ ":$_target_name" ] |
111 sources = get_target_outputs(":$_generate_info_plist") | 135 sources = get_target_outputs(":$_generate_info_plist") |
112 outputs = [ | 136 outputs = [ |
113 "{{bundle_root_dir}}/Info.plist", | 137 "{{bundle_root_dir}}/Info.plist", |
114 ] | 138 ] |
115 public_deps = [ | 139 public_deps = [ |
116 ":$_generate_info_plist", | 140 ":$_generate_info_plist", |
117 ] | 141 ] |
118 } | 142 } |
119 | 143 |
120 _generate_executable = target_name + "_generate_executable" | 144 _generate_executable = target_name + "_generate_executable" |
121 _bundle_data_executable = target_name + "_bundle_data_executable" | 145 _bundle_data_executable = target_name + "_bundle_data_executable" |
122 | 146 |
123 executable(_generate_executable) { | 147 executable(_generate_executable) { |
124 visibility = [ ":$_bundle_data_executable" ] | 148 visibility = [ ":$_bundle_data_executable" ] |
125 forward_variables_from(invoker, | 149 forward_variables_from(invoker, |
126 "*", | 150 "*", |
127 [ | 151 [ |
128 "assert_no_deps", | 152 "assert_no_deps", |
129 "bundle_extension", | 153 "bundle_extension", |
130 "code_signing_identity", | 154 "code_signing_identity", |
131 "data_deps", | 155 "data_deps", |
132 "entitlements_path", | 156 "entitlements_path", |
133 "info_plist", | 157 "info_plist", |
| 158 "info_plist_target", |
134 "output_name", | 159 "output_name", |
135 "product_type", | 160 "product_type", |
136 "visibility", | 161 "visibility", |
137 ]) | 162 ]) |
138 | 163 |
139 output_name = rebase_path("$target_gen_dir/$_output_name", root_out_dir) | 164 output_name = rebase_path("$target_gen_dir/$_output_name", root_out_dir) |
140 if (!defined(libs)) { | 165 if (!defined(libs)) { |
141 libs = [] | 166 libs = [] |
142 } | 167 } |
143 libs += [ "UIKit.framework" ] | 168 libs += [ "UIKit.framework" ] |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 # output_name: | 248 # output_name: |
224 # (optional) string, name of the generated application, if omitted, | 249 # (optional) string, name of the generated application, if omitted, |
225 # defaults to the target_name. | 250 # defaults to the target_name. |
226 # | 251 # |
227 # extra_substitutions: | 252 # extra_substitutions: |
228 # (optional) list of string in "key=value" format, each value will | 253 # (optional) list of string in "key=value" format, each value will |
229 # be used as an additional variable substitution rule when generating | 254 # be used as an additional variable substitution rule when generating |
230 # the application Info.plist | 255 # the application Info.plist |
231 # | 256 # |
232 # info_plist: | 257 # info_plist: |
233 # path to the template to use to generate the application Info.plist | 258 # (optional) string, path to the Info.plist file that will be used for |
234 # by performing variable substitutions. | 259 # the bundle. |
| 260 # |
| 261 # info_plist_target: |
| 262 # (optional) string, if the info_plist is generated from an action, |
| 263 # rather than a regular source file, specify the target name in lieu |
| 264 # of info_plist. The two arguments are mutually exclusive. |
235 # | 265 # |
236 # For more information, see "gn help executable". | 266 # For more information, see "gn help executable". |
237 template("ios_appex_bundle") { | 267 template("ios_appex_bundle") { |
238 ios_app_bundle(target_name) { | 268 ios_app_bundle(target_name) { |
239 forward_variables_from(invoker, | 269 forward_variables_from(invoker, |
240 "*", | 270 "*", |
241 [ | 271 [ |
242 "bundle_extension", | 272 "bundle_extension", |
243 "product_type", | 273 "product_type", |
244 ]) | 274 ]) |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 [ | 527 [ |
498 "testonly", | 528 "testonly", |
499 "visibility", | 529 "visibility", |
500 ]) | 530 ]) |
501 public_deps = [ | 531 public_deps = [ |
502 ":$_framework_target+link", | 532 ":$_framework_target+link", |
503 ] | 533 ] |
504 } | 534 } |
505 } | 535 } |
506 } | 536 } |
OLD | NEW |