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

Side by Side Diff: build/config/mac/rules.gni

Issue 1925383003: [Mac/GN] Port tweak_info_plist.py and run it on //content targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « build/config/mac/base_rules.gni ('k') | build/mac/tweak_info_plist.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 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(
24 (defined(invoker.info_plist) || defined(invoker.info_plist_target)) &&
sdefresne 2016/04/29 18:23:18 Can't this be expressed more simply by "defined(in
Robert Sesek 2016/05/02 16:53:54 Ah, yes, that's better.
25 !(defined(invoker.info_plist) && defined(invoker.info_plist_target)),
26 "Only one of info_plist or info_plist_target may be specified in " +
27 target_name)
28
29 if (defined(invoker.info_plist)) {
30 _info_plist = invoker.info_plist
31 } else {
32 _info_plist_target_output = get_target_outputs(invoker.info_plist_target)
33 _info_plist = _info_plist_target_output[0]
34 }
35
23 info_plist(target_name) { 36 info_plist(target_name) {
24 format = "xml1" 37 format = "xml1"
25 extra_substitutions = [] 38 extra_substitutions = []
26 if (defined(invoker.extra_substitutions)) { 39 if (defined(invoker.extra_substitutions)) {
27 extra_substitutions = invoker.extra_substitutions 40 extra_substitutions = invoker.extra_substitutions
28 } 41 }
29 extra_substitutions += [ 42 extra_substitutions += [
30 "MAC_SDK_BUILD=$mac_sdk_build", 43 "MAC_SDK_BUILD=$mac_sdk_build",
31 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", 44 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version",
32 ] 45 ]
33 plist_templates = [ 46 plist_templates = [
34 "//build/config/mac/BuildInfo.plist", 47 "//build/config/mac/BuildInfo.plist",
35 invoker.info_plist, 48 _info_plist,
36 ] 49 ]
37 forward_variables_from(invoker, [ "executable_name" ]) 50 if (defined(invoker.info_plist_target)) {
51 deps = [
52 invoker.info_plist_target,
53 ]
54 }
55 forward_variables_from(invoker,
56 [
57 "testonly",
58 "executable_name",
59 ])
38 } 60 }
39 } 61 }
40 62
41 # Template to compile and package Mac XIB files as bundle data. 63 # Template to compile and package Mac XIB files as bundle data.
42 # 64 #
43 # Arguments 65 # Arguments
44 # 66 #
45 # sources: 67 # sources:
46 # list of string, sources to comiple 68 # list of string, sources to comiple
47 # 69 #
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 # This template provides two targets to control whether the framework is 116 # 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: 117 # merely built when targets depend on it, or whether it is linked as well:
96 # "$target_name" and "$target_name+link". 118 # "$target_name" and "$target_name+link".
97 # 119 #
98 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion 120 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion
99 # and examples. 121 # and examples.
100 # 122 #
101 # Arguments 123 # Arguments
102 # 124 #
103 # info_plist: 125 # info_plist:
104 # string, path to the Info.plist file that will be used for the bundle. 126 # string, path to the Info.plist file that will be used for the bundle.
sdefresne 2016/04/29 18:23:18 nit: info_plist is now also optional, isn't it?
Robert Sesek 2016/05/02 16:53:54 Done.
105 # 127 #
128 # info_plist_target:
129 # (optional) string, if the info_plist is generated from an action,
130 # rather than a regular source file, specify the target name in lieu
131 # of info_plist. The two arguments are mutually exclusive.
132 #
106 # output_name: 133 # output_name:
107 # (optional) string, name of the generated framework without the 134 # (optional) string, name of the generated framework without the
108 # .framework suffix. If omitted, defaults to target_name. 135 # .framework suffix. If omitted, defaults to target_name.
109 # 136 #
110 # framework_version: 137 # framework_version:
111 # (optional) string, version of the framework. Typically this is a 138 # (optional) string, version of the framework. Typically this is a
112 # single letter, like "A". If omitted, the Versions/ subdirectory 139 # single letter, like "A". If omitted, the Versions/ subdirectory
113 # structure will not be created, and build output will go directly 140 # structure will not be created, and build output will go directly
114 # into the framework subdirectory. 141 # into the framework subdirectory.
115 # 142 #
116 # See "gn help shared_library" for more information on arguments supported 143 # See "gn help shared_library" for more information on arguments supported
117 # by shared library target. 144 # by shared library target.
118 template("mac_framework_bundle") { 145 template("mac_framework_bundle") {
119 assert(defined(invoker.deps), 146 assert(defined(invoker.deps),
120 "Dependencies must be specified for $target_name") 147 "Dependencies must be specified for $target_name")
121 assert(defined(invoker.info_plist), 148 assert(defined(invoker.info_plist) || defined(invoker.info_plist_target),
122 "The Info.plist file must be specified for $target_name") 149 "The Info.plist file must be specified for $target_name")
123 150
124 _info_plist_target = target_name + "_info_plist" 151 _info_plist_target = target_name + "_info_plist"
125 152
126 mac_info_plist(_info_plist_target) { 153 mac_info_plist(_info_plist_target) {
127 executable_name = target_name 154 executable_name = target_name
128 if (defined(invoker.output_name)) { 155 if (defined(invoker.output_name)) {
129 executable_name = invoker.output_name 156 executable_name = invoker.output_name
130 } 157 }
131 forward_variables_from(invoker, [ "info_plist" ]) 158 forward_variables_from(invoker,
159 [
160 "testonly",
161 "info_plist",
162 "info_plist_target",
163 ])
132 } 164 }
133 165
134 _info_plist_bundle_data = _info_plist_target + "_bundle_data" 166 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
135 167
136 bundle_data(_info_plist_bundle_data) { 168 bundle_data(_info_plist_bundle_data) {
137 forward_variables_from(invoker, [ "testonly" ]) 169 forward_variables_from(invoker, [ "testonly" ])
138 sources = get_target_outputs(":$_info_plist_target") 170 sources = get_target_outputs(":$_info_plist_target")
139 outputs = [ 171 outputs = [
140 "{{bundle_root_dir}}/Info.plist", 172 "{{bundle_root_dir}}/Info.plist",
141 ] 173 ]
(...skipping 10 matching lines...) Expand all
152 } 184 }
153 deps += [ ":$_info_plist_bundle_data" ] 185 deps += [ ":$_info_plist_bundle_data" ]
154 } 186 }
155 } 187 }
156 188
157 # Template to create a Mac executable application bundle. 189 # Template to create a Mac executable application bundle.
158 # 190 #
159 # Arguments 191 # Arguments
160 # 192 #
161 # info_plist: 193 # info_plist:
162 # string, path to the Info.plist file that will be used for the bundle. 194 # string, path to the Info.plist file that will be used for the bundle.
sdefresne 2016/04/29 18:23:18 ditto
Robert Sesek 2016/05/02 16:53:54 Done.
163 # 195 #
196 # info_plist_target:
197 # (optional) string, if the info_plist is generated from an action,
198 # rather than a regular source file, specify the target name in lieu
199 # of info_plist. The two arguments are mutually exclusive.
200 #
164 # output_name: 201 # output_name:
165 # (optional) string, name of the generated app without the 202 # (optional) string, name of the generated app without the
166 # .app suffix. If omitted, defaults to target_name. 203 # .app suffix. If omitted, defaults to target_name.
167 template("mac_app_bundle") { 204 template("mac_app_bundle") {
168 assert(defined(invoker.info_plist), 205 assert(defined(invoker.info_plist) || defined(invoker.info_plist_target),
sdefresne 2016/04/29 18:23:18 Shouldn't it be the same mutually exclusive test t
Robert Sesek 2016/05/02 16:53:54 Does it make sense to duplicate that check? The ma
sdefresne 2016/05/03 07:12:17 I wanted to say that we should either do the same
Robert Sesek 2016/05/03 13:44:27 Agreed on your reasoning. Removed the checks in fa
169 "The Info.plist file must be specified for $target_name") 206 "The Info.plist file must be specified for $target_name")
170 207
171 _target_name = target_name 208 _target_name = target_name
172 _output_name = target_name 209 _output_name = target_name
173 if (defined(invoker.output_name)) { 210 if (defined(invoker.output_name)) {
174 _output_name = invoker.output_name 211 _output_name = invoker.output_name
175 } 212 }
176 213
177 _executable_target = target_name + "_executable" 214 _executable_target = target_name + "_executable"
178 _executable_bundle_data = _executable_target + "_bundle_data" 215 _executable_bundle_data = _executable_target + "_bundle_data"
179 216
217 _info_plist_target = target_name + "_info_plist"
218
219 mac_info_plist(_info_plist_target) {
220 executable_name = _output_name
221 forward_variables_from(invoker,
222 [
223 "testonly",
224 "info_plist",
225 "info_plist_target",
226 ])
227 }
228
180 executable(_executable_target) { 229 executable(_executable_target) {
181 visibility = [ ":$_executable_bundle_data" ] 230 visibility = [ ":$_executable_bundle_data" ]
182 forward_variables_from(invoker, 231 forward_variables_from(invoker,
183 "*", 232 "*",
184 [ 233 [
185 "assert_no_deps", 234 "assert_no_deps",
186 "data_deps", 235 "data_deps",
187 "info_plist", 236 "info_plist",
188 "output_name", 237 "output_name",
189 "visibility", 238 "visibility",
190 ]) 239 ])
191 output_name = _output_name 240 output_name = _output_name
192 output_dir = "$target_out_dir/$_executable_target" 241 output_dir = "$target_out_dir/$_executable_target"
193 } 242 }
194 243
195 bundle_data(_executable_bundle_data) { 244 bundle_data(_executable_bundle_data) {
196 visibility = [ ":$_target_name" ] 245 visibility = [ ":$_target_name" ]
197 forward_variables_from(invoker, [ "testonly" ]) 246 forward_variables_from(invoker, [ "testonly" ])
198 sources = [ 247 sources = [
199 "$target_out_dir/$_executable_target/$_output_name", 248 "$target_out_dir/$_executable_target/$_output_name",
200 ] 249 ]
201 outputs = [ 250 outputs = [
202 "{{bundle_executable_dir}}/$_output_name", 251 "{{bundle_executable_dir}}/$_output_name",
203 ] 252 ]
204 public_deps = [ 253 public_deps = [
205 ":$_executable_target", 254 ":$_executable_target",
206 ] 255 ]
207 } 256 }
208 257
209 _info_plist_target = target_name + "_info_plist"
210
211 mac_info_plist(_info_plist_target) {
212 executable_name = _output_name
213 forward_variables_from(invoker, [ "info_plist" ])
214 }
215
216 _info_plist_bundle_data = _info_plist_target + "_bundle_data" 258 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
217 259
218 bundle_data(_info_plist_bundle_data) { 260 bundle_data(_info_plist_bundle_data) {
219 forward_variables_from(invoker, [ "testonly" ]) 261 forward_variables_from(invoker, [ "testonly" ])
220 visibility = [ ":$_target_name" ] 262 visibility = [ ":$_target_name" ]
221 sources = get_target_outputs(":$_info_plist_target") 263 sources = get_target_outputs(":$_info_plist_target")
222 outputs = [ 264 outputs = [
223 "{{bundle_root_dir}}/Info.plist", 265 "{{bundle_root_dir}}/Info.plist",
224 ] 266 ]
225 public_deps = [ 267 public_deps = [
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ]) 346 ])
305 if (!defined(deps)) { 347 if (!defined(deps)) {
306 deps = [] 348 deps = []
307 } 349 }
308 deps += [ ":$_loadable_module_bundle_data" ] 350 deps += [ ":$_loadable_module_bundle_data" ]
309 351
310 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" 352 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
311 bundle_executable_dir = "$bundle_root_dir/MacOS" 353 bundle_executable_dir = "$bundle_root_dir/MacOS"
312 } 354 }
313 } 355 }
OLDNEW
« no previous file with comments | « build/config/mac/base_rules.gni ('k') | build/mac/tweak_info_plist.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698