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

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

Issue 1877523002: Mac/iOS/GN: Generate Info.plist files for Mac apps and frameworks with gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor out Info.plist generation into its own template. Created 4 years, 8 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
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/toolchain/toolchain.gni") 5 import("//build/toolchain/toolchain.gni")
6 import("//build/config/mac/mac_sdk.gni")
7 import("//build/util/version.gni")
6 8
7 # This is used as the base template for both iOS and Mac frameworks.. 9 # Used to generate an Info.plist file for iOS and Mac apps and frameworks.
Robert Sesek 2016/04/19 14:49:04 Also document the Arguments as the other templates
Patti Lor 2016/04/21 08:02:09 Done.
10 template("info_plist") {
11 _generate_info_plist = target_name + "_action"
12
13 action(_generate_info_plist) {
14 script = "//build/config/mac/gen_plist.py"
15 sources = [
16 "//build/config/mac/BuildInfo.plist",
17 invoker.info_plist,
18 ]
19 outputs = [
20 "$target_gen_dir/Info.plist",
21 ]
22 extra_args = []
23 if (defined(invoker.extra_substitutions)) {
24 foreach(substitution, invoker.extra_substitutions) {
25 extra_args += [ "-s=$substitution" ]
26 }
27 }
28 response_file_contents =
29 extra_args + [
30 "-s=MAC_SDK_BUILD=$mac_sdk_build",
31 "-s=MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version",
32 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
33 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
34 "-s=XCODE_BUILD=$xcode_build",
35 "-s=XCODE_VERSION=$xcode_version",
36 "-s=VERSION=$chrome_version_full",
37 "-s=VERSION_BUILD=$chrome_version_build",
38 "-o=" + rebase_path(outputs[0], root_build_dir),
39 ] + rebase_path(sources, root_build_dir)
40 args = [ "@{{response_file_name}}" ]
41 }
42
43 source_set(target_name) {
44 sources = get_target_outputs(":$_generate_info_plist")
45 public_deps = [
46 ":$_generate_info_plist",
47 ]
48 }
49 }
50
51 # This is used as the base template for both iOS and Mac frameworks.
8 # 52 #
9 # Arguments 53 # Arguments
10 # 54 #
11 # output_name: 55 # output_name:
12 # (optional) string, name of the generated framework without the 56 # (optional) string, name of the generated framework without the
13 # .framework suffix. If omitted, defaults to target_name. 57 # .framework suffix. If omitted, defaults to target_name.
14 # 58 #
15 # framework_version: 59 # framework_version:
16 # (optional) string, version of the framework. Typically this is a 60 # (optional) string, version of the framework. Typically this is a
17 # single letter, like "A". If omitted, the Versions/ subdirectory 61 # single letter, like "A". If omitted, the Versions/ subdirectory
18 # structure will not be created, and build output will go directly 62 # structure will not be created, and build output will go directly
19 # into the framework subdirectory. 63 # into the framework subdirectory.
20 # 64 #
21 # See "gn help shared_library" for more information on arguments supported 65 # See "gn help shared_library" for more information on arguments supported
22 # by shared library target. 66 # by shared library target.
23 template("framework_bundle") { 67 template("framework_bundle") {
24 _target_name = target_name 68 _target_name = target_name
25 _output_name = target_name 69 _output_name = target_name
26 if (defined(invoker.output_name)) { 70 if (defined(invoker.output_name)) {
27 _output_name = invoker.output_name 71 _output_name = invoker.output_name
28 } 72 }
29 73
30 # If the framework is unversionned, the final _target_name will be the 74 # If the framework is unversioned, the final _target_name will be the
31 # create_bundle(_framework_target), otherwise an action with the name 75 # create_bundle(_framework_target), otherwise an action with the name
32 # _target_name will depends on the the create_bundle() in order to prepare 76 # _target_name will depends on the the create_bundle() in order to prepare
33 # the versioned directory structure. 77 # the versioned directory structure.
34 _framework_target = _target_name 78 _framework_target = _target_name
35 _framework_name = _output_name + ".framework" 79 _framework_name = _output_name + ".framework"
36 _framework_root_dir = "$root_out_dir/$_framework_name" 80 _framework_root_dir = "$root_out_dir/$_framework_name"
37 if (defined(invoker.framework_version) && invoker.framework_version != "") { 81 if (defined(invoker.framework_version) && invoker.framework_version != "") {
38 _framework_version = invoker.framework_version 82 _framework_version = invoker.framework_version
39 _framework_root_dir += "/Versions/$_framework_version" 83 _framework_root_dir += "/Versions/$_framework_version"
40 _framework_target = _target_name + "_create_bundle" 84 _framework_target = _target_name + "_create_bundle"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 # See "gn help shared_library" for more information on arguments supported 186 # See "gn help shared_library" for more information on arguments supported
143 # by shared library target. 187 # by shared library target.
144 template("mac_framework_bundle") { 188 template("mac_framework_bundle") {
145 assert(defined(invoker.deps), 189 assert(defined(invoker.deps),
146 "Dependencies must be specified for $target_name") 190 "Dependencies must be specified for $target_name")
147 assert(defined(invoker.info_plist), 191 assert(defined(invoker.info_plist),
148 "The Info.plist file must be specified for $target_name") 192 "The Info.plist file must be specified for $target_name")
149 193
150 _info_plist_target = target_name + "_info_plist" 194 _info_plist_target = target_name + "_info_plist"
151 195
152 # TODO(rsesek): Process Info.plist variables. 196 # TODO(rsesek): Process Info.plist variables.
Robert Sesek 2016/04/19 14:49:04 Remove, since you're doing it :).
Patti Lor 2016/04/21 08:02:09 Done.
197 info_plist(_info_plist_target) {
198 forward_variables_from(invoker, [ "info_plist" ])
199 }
153 200
154 _info_plist_bundle_data = _info_plist_target + "_bundle_data" 201 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
155 202
156 bundle_data(_info_plist_bundle_data) { 203 bundle_data(_info_plist_bundle_data) {
157 forward_variables_from(invoker, [ "testonly" ]) 204 forward_variables_from(invoker, [ "testonly" ])
158 sources = [ 205 sources = [
206 "$target_gen_dir/Info.plist",
159 invoker.info_plist, 207 invoker.info_plist,
160 ] 208 ]
161 outputs = [ 209 outputs = [
162 "{{bundle_root_dir}}/Info.plist", 210 "{{bundle_root_dir}}/Info.plist",
163 ] 211 ]
212 public_deps = [
213 ":$_info_plist_target",
214 ]
164 } 215 }
165 216
166 framework_bundle(target_name) { 217 framework_bundle(target_name) {
167 forward_variables_from(invoker, "*", [ "info_plist" ]) 218 forward_variables_from(invoker, "*", [ "info_plist" ])
168 219
169 if (!defined(deps)) { 220 if (!defined(deps)) {
170 deps = [] 221 deps = []
171 } 222 }
172 deps += [ ":$_info_plist_bundle_data" ] 223 deps += [ ":$_info_plist_bundle_data" ]
173 } 224 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 outputs = [ 271 outputs = [
221 "{{bundle_executable_dir}}/$_output_name", 272 "{{bundle_executable_dir}}/$_output_name",
222 ] 273 ]
223 public_deps = [ 274 public_deps = [
224 ":$_executable_target", 275 ":$_executable_target",
225 ] 276 ]
226 } 277 }
227 278
228 _info_plist_target = target_name + "_info_plist" 279 _info_plist_target = target_name + "_info_plist"
229 280
230 # TODO(rsesek): Process Info.plist variables. 281 # TODO(rsesek): Process Info.plist variables.
Robert Sesek 2016/04/19 14:49:04 Remove.
Patti Lor 2016/04/21 08:02:09 Done.
282 info_plist(_info_plist_target) {
283 forward_variables_from(invoker, [ "info_plist" ])
284 if (!defined(extra_substitutions)) {
Robert Sesek 2016/04/19 14:49:04 Since you're not forward_varaibles_from()-ing extr
Patti Lor 2016/04/21 08:02:09 Done.
285 extra_substitutions = []
286 }
287 extra_substitutions += [
288 "PRODUCT_NAME=$_output_name",
Robert Sesek 2016/04/19 14:49:04 These subs are needed in the mac_framework_bundle
Patti Lor 2016/04/21 08:02:09 Done.
289 "EXECUTABLE_NAME=$_output_name",
290 ]
291 }
231 292
232 _info_plist_bundle_data = _info_plist_target + "_bundle_data" 293 _info_plist_bundle_data = _info_plist_target + "_bundle_data"
233 294
234 bundle_data(_info_plist_bundle_data) { 295 bundle_data(_info_plist_bundle_data) {
235 forward_variables_from(invoker, [ "testonly" ]) 296 forward_variables_from(invoker, [ "testonly" ])
236 visibility = [ ":$_target_name" ] 297 visibility = [ ":$_target_name" ]
237 sources = [ 298 sources = [
299 "$target_gen_dir/Info.plist",
238 invoker.info_plist, 300 invoker.info_plist,
239 ] 301 ]
240 outputs = [ 302 outputs = [
241 "{{bundle_root_dir}}/Info.plist", 303 "{{bundle_root_dir}}/Info.plist",
242 ] 304 ]
305 public_deps = [
306 ":$_info_plist_target",
307 ]
243 } 308 }
244 309
245 create_bundle(_target_name) { 310 create_bundle(_target_name) {
246 forward_variables_from(invoker, 311 forward_variables_from(invoker,
247 [ 312 [
248 "data_deps", 313 "data_deps",
249 "deps", 314 "deps",
250 "public_deps", 315 "public_deps",
251 "testonly", 316 "testonly",
252 ]) 317 ])
253 if (!defined(deps)) { 318 if (!defined(deps)) {
254 deps = [] 319 deps = []
255 } 320 }
256 deps += [ 321 deps += [
257 ":$_executable_bundle_data", 322 ":$_executable_bundle_data",
258 ":$_info_plist_bundle_data", 323 ":$_info_plist_bundle_data",
259 ] 324 ]
260 325
261 bundle_root_dir = "$root_out_dir/${_output_name}.app/Contents" 326 bundle_root_dir = "$root_out_dir/${_output_name}.app/Contents"
262 bundle_resources_dir = "$bundle_root_dir/Resources" 327 bundle_resources_dir = "$bundle_root_dir/Resources"
263 bundle_executable_dir = "$bundle_root_dir/MacOS" 328 bundle_executable_dir = "$bundle_root_dir/MacOS"
264 } 329 }
265 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698