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 # |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 # output_name: | 136 # output_name: |
137 # (optional) string, name of the generated framework without the | 137 # (optional) string, name of the generated framework without the |
138 # .framework suffix. If omitted, defaults to target_name. | 138 # .framework suffix. If omitted, defaults to target_name. |
139 # | 139 # |
140 # framework_version: | 140 # framework_version: |
141 # (optional) string, version of the framework. Typically this is a | 141 # (optional) string, version of the framework. Typically this is a |
142 # single letter, like "A". If omitted, the Versions/ subdirectory | 142 # single letter, like "A". If omitted, the Versions/ subdirectory |
143 # structure will not be created, and build output will go directly | 143 # structure will not be created, and build output will go directly |
144 # into the framework subdirectory. | 144 # into the framework subdirectory. |
145 # | 145 # |
| 146 # framework_contents: |
| 147 # (optional) list of string, top-level items in the framework. For |
| 148 # frameworks with a framework_version, this is the list of symlinks to |
| 149 # create in the .framework directory that link into Versions/Current/. |
| 150 # |
146 # extra_substitutions: | 151 # extra_substitutions: |
147 # (optional) string array, 'key=value' pairs for extra fields which are | 152 # (optional) string array, 'key=value' pairs for extra fields which are |
148 # specified in a source Info.plist template. | 153 # specified in a source Info.plist template. |
149 # | 154 # |
150 # This template provides two targets for the resulting framework bundle. The | 155 # This template provides two targets for the resulting framework bundle. The |
151 # link-time behavior varies depending on which of the two targets below is | 156 # link-time behavior varies depending on which of the two targets below is |
152 # added as a dependency: | 157 # added as a dependency: |
153 # - $target_name only adds a build-time dependency. Targets that depend on | 158 # - $target_name only adds a build-time dependency. Targets that depend on |
154 # it will not link against the framework. | 159 # it will not link against the framework. |
155 # - $target_name+link adds a build-time and link-time dependency. Targets | 160 # - $target_name+link adds a build-time and link-time dependency. Targets |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 # Note that the framework is still copied to the app's bundle, but dyld will | 214 # Note that the framework is still copied to the app's bundle, but dyld will |
210 # load this library when the app is launched because it uses the "+link" | 215 # load this library when the app is launched because it uses the "+link" |
211 # target as a dependency. This also requires that the framework set its | 216 # target as a dependency. This also requires that the framework set its |
212 # install_name so that dyld can locate it. | 217 # install_name so that dyld can locate it. |
213 # | 218 # |
214 # See "gn help shared_library" for more information on arguments supported | 219 # See "gn help shared_library" for more information on arguments supported |
215 # by shared library target. | 220 # by shared library target. |
216 template("mac_framework_bundle") { | 221 template("mac_framework_bundle") { |
217 assert(defined(invoker.deps), | 222 assert(defined(invoker.deps), |
218 "Dependencies must be specified for $target_name") | 223 "Dependencies must be specified for $target_name") |
| 224 assert(!defined(invoker.framework_contents) || |
| 225 defined(invoker.framework_version), |
| 226 "framework_contents requres a versioned framework") |
219 | 227 |
220 _info_plist_target = target_name + "_info_plist" | 228 _info_plist_target = target_name + "_info_plist" |
221 | 229 |
222 mac_info_plist(_info_plist_target) { | 230 mac_info_plist(_info_plist_target) { |
223 executable_name = target_name | 231 executable_name = target_name |
224 if (defined(invoker.output_name)) { | 232 if (defined(invoker.output_name)) { |
225 executable_name = invoker.output_name | 233 executable_name = invoker.output_name |
226 } | 234 } |
227 forward_variables_from(invoker, | 235 forward_variables_from(invoker, |
228 [ | 236 [ |
(...skipping 16 matching lines...) Expand all Loading... |
245 ":$_info_plist_target", | 253 ":$_info_plist_target", |
246 ] | 254 ] |
247 } | 255 } |
248 | 256 |
249 _target_name = target_name | 257 _target_name = target_name |
250 _output_name = target_name | 258 _output_name = target_name |
251 if (defined(invoker.output_name)) { | 259 if (defined(invoker.output_name)) { |
252 _output_name = invoker.output_name | 260 _output_name = invoker.output_name |
253 } | 261 } |
254 | 262 |
255 # If the framework is unversioned, the final _target_name will be the | 263 # Create a file to track the build dependency on the framework_version and |
256 # create_bundle(_framework_target), otherwise an action with the name | 264 # framework_contents variables. |
257 # _target_name will depends on the the create_bundle() in order to prepare | 265 _framework_toc = [] |
258 # the versioned directory structure. | 266 if (defined(invoker.framework_version)) { |
| 267 _framework_toc += [ |
| 268 "Version=" + invoker.framework_version, |
| 269 _output_name, |
| 270 ] |
| 271 _framework_contents = [ _output_name ] |
| 272 } |
| 273 if (defined(invoker.framework_contents)) { |
| 274 _framework_toc += invoker.framework_contents |
| 275 _framework_contents += invoker.framework_contents |
| 276 } |
| 277 _framework_toc_file = "$target_out_dir/${target_name}.toc" |
| 278 write_file(_framework_toc_file, _framework_toc) |
| 279 |
| 280 # Create local variables for referencing different parts of the bundle. |
259 _framework_target = _target_name | 281 _framework_target = _target_name |
260 _framework_name = _output_name + ".framework" | 282 _framework_name = _output_name + ".framework" |
261 _framework_base_dir = "$root_out_dir/$_framework_name" | 283 _framework_base_dir = "$root_out_dir/$_framework_name" |
262 if (defined(invoker.framework_version) && invoker.framework_version != "") { | 284 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
263 _framework_version = invoker.framework_version | 285 _framework_version = invoker.framework_version |
264 _framework_root_dir = _framework_base_dir + "/Versions/$_framework_version" | 286 _framework_root_dir = _framework_base_dir + "/Versions/$_framework_version" |
265 _framework_target = _target_name + "_create_bundle" | |
266 } else { | 287 } else { |
267 _framework_root_dir = _framework_base_dir | 288 _framework_root_dir = _framework_base_dir |
268 } | 289 } |
269 | 290 |
| 291 # Clean the entire framework if the framework_version changes. |
| 292 _version_arg = "''" |
| 293 if (defined(invoker.framework_version)) { |
| 294 _version_arg = _framework_version |
| 295 } |
| 296 _version_file = "$target_out_dir/${target_name}_version" |
| 297 exec_script("//build/config/mac/prepare_framework_version.py", |
| 298 [ |
| 299 rebase_path(_version_file), |
| 300 rebase_path(_framework_base_dir), |
| 301 _version_arg, |
| 302 ]) |
| 303 |
| 304 # Create the symlinks. |
| 305 _framework_package_target = target_name + "_package" |
| 306 action(_framework_package_target) { |
| 307 script = "//build/config/mac/package_framework.py" |
| 308 |
| 309 # The TOC file never needs to be read, since its contents are the values |
| 310 # of GN variables. It is only used to trigger this rule when the values |
| 311 # change. |
| 312 inputs = [ |
| 313 _framework_toc_file, |
| 314 ] |
| 315 |
| 316 _stamp_file = "$target_out_dir/run_${_framework_package_target}.stamp" |
| 317 outputs = [ |
| 318 _stamp_file, |
| 319 ] |
| 320 |
| 321 visibility = [ ":$_framework_target" ] |
| 322 |
| 323 args = [ |
| 324 "--framework", |
| 325 rebase_path(_framework_base_dir, root_build_dir), |
| 326 "--stamp", |
| 327 rebase_path(_stamp_file, root_build_dir), |
| 328 ] |
| 329 |
| 330 if (defined(invoker.framework_version)) { |
| 331 outputs += [ "$_framework_base_dir/Versions/Current" ] |
| 332 args += [ |
| 333 "--version", |
| 334 invoker.framework_version, |
| 335 "--contents", |
| 336 ] + _framework_contents |
| 337 |
| 338 # It is not possible to list _framework_contents as outputs, since |
| 339 # ninja does not properly stat symbolic links. The exception is the |
| 340 # "Current" symlink, since package_framework.py will ensure that |
| 341 # directory exists so the resolved-symlink mtime will be up-to-date. |
| 342 # https://github.com/ninja-build/ninja/issues/1186 |
| 343 } |
| 344 } |
| 345 |
270 _link_shared_library_target = target_name + "_shared_library" | 346 _link_shared_library_target = target_name + "_shared_library" |
271 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" | 347 _shared_library_bundle_data = target_name + "_shared_library_bundle_data" |
272 | 348 |
273 shared_library(_link_shared_library_target) { | 349 shared_library(_link_shared_library_target) { |
274 forward_variables_from(invoker, | 350 forward_variables_from(invoker, |
275 "*", | 351 "*", |
276 [ | 352 [ |
277 "assert_no_deps", | 353 "assert_no_deps", |
278 "bundle_deps", | 354 "bundle_deps", |
279 "code_signing_enabled", | 355 "code_signing_enabled", |
(...skipping 17 matching lines...) Expand all Loading... |
297 "$target_out_dir/$_link_shared_library_target/$_output_name", | 373 "$target_out_dir/$_link_shared_library_target/$_output_name", |
298 ] | 374 ] |
299 outputs = [ | 375 outputs = [ |
300 "{{bundle_executable_dir}}/$_output_name", | 376 "{{bundle_executable_dir}}/$_output_name", |
301 ] | 377 ] |
302 public_deps = [ | 378 public_deps = [ |
303 ":$_link_shared_library_target", | 379 ":$_link_shared_library_target", |
304 ] | 380 ] |
305 } | 381 } |
306 | 382 |
307 # Clean the entire framework if the framework_version changes. | |
308 _version_arg = "" | |
309 if (defined(_framework_version)) { | |
310 _version_arg = _framework_version | |
311 } | |
312 _version_file = "$target_out_dir/${target_name}_version" | |
313 exec_script("//build/config/mac/prepare_framework_version.py", | |
314 [ | |
315 rebase_path(_version_file), | |
316 rebase_path(_framework_base_dir), | |
317 "'$_version_arg'", | |
318 ]) | |
319 | |
320 _framework_public_config = _target_name + "_public_config" | 383 _framework_public_config = _target_name + "_public_config" |
321 config(_framework_public_config) { | 384 config(_framework_public_config) { |
322 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs | 385 # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs |
323 # and include_dirs to avoid duplicate values on the command-line. | 386 # and include_dirs to avoid duplicate values on the command-line. |
324 visibility = [ ":$_framework_target" ] | 387 visibility = [ ":$_framework_target" ] |
325 ldflags = [ | 388 ldflags = [ |
326 "-F", | 389 "-F", |
327 rebase_path("$root_out_dir/.", root_build_dir), | 390 rebase_path("$root_out_dir/.", root_build_dir), |
328 ] | 391 ] |
329 lib_dirs = [ root_out_dir ] | 392 lib_dirs = [ root_out_dir ] |
330 libs = [ _framework_name ] | 393 libs = [ _framework_name ] |
331 } | 394 } |
332 | 395 |
333 create_bundle(_framework_target) { | 396 create_bundle(_framework_target) { |
334 forward_variables_from(invoker, | 397 forward_variables_from(invoker, |
335 [ | 398 [ |
336 "data_deps", | 399 "data_deps", |
337 "deps", | 400 "deps", |
338 "public_deps", | 401 "public_deps", |
339 "testonly", | 402 "testonly", |
340 ]) | 403 ]) |
341 | 404 |
342 if (defined(_framework_version)) { | 405 if (defined(invoker.visibility)) { |
343 visibility = [ ":$_target_name" ] | 406 visibility = invoker.visibility |
344 } else { | 407 visibility += [ ":$_target_name+link" ] |
345 if (defined(invoker.visibility)) { | |
346 visibility = invoker.visibility | |
347 visibility += [ ":$_target_name+link" ] | |
348 } | |
349 } | 408 } |
350 | 409 |
351 if (!defined(deps)) { | 410 if (!defined(deps)) { |
352 deps = [] | 411 deps = [] |
353 } | 412 } |
354 deps += [ ":$_info_plist_bundle_data" ] | 413 deps += [ ":$_info_plist_bundle_data" ] |
355 | 414 |
356 if (defined(invoker.bundle_deps)) { | 415 if (defined(invoker.bundle_deps)) { |
357 deps += invoker.bundle_deps | 416 deps += invoker.bundle_deps |
358 } | 417 } |
359 | 418 |
360 if (!defined(public_deps)) { | 419 if (!defined(public_deps)) { |
361 public_deps = [] | 420 public_deps = [] |
362 } | 421 } |
363 public_deps += [ ":$_shared_library_bundle_data" ] | 422 public_deps += [ |
| 423 ":$_framework_package_target", |
| 424 ":$_shared_library_bundle_data", |
| 425 ] |
364 | 426 |
365 bundle_root_dir = _framework_root_dir | 427 bundle_root_dir = _framework_root_dir |
366 bundle_resources_dir = "$bundle_root_dir/Resources" | 428 bundle_resources_dir = "$bundle_root_dir/Resources" |
367 bundle_executable_dir = "$bundle_root_dir" | 429 bundle_executable_dir = "$bundle_root_dir" |
368 } | 430 } |
369 | 431 |
370 if (defined(_framework_version)) { | |
371 action(_target_name) { | |
372 forward_variables_from(invoker, [ "testonly" ]) | |
373 | |
374 if (defined(invoker.visibility)) { | |
375 visibility = invoker.visibility | |
376 visibility += [ ":$_target_name+link" ] | |
377 } | |
378 | |
379 script = "//build/config/mac/package_framework.py" | |
380 outputs = [ | |
381 "$root_out_dir/$_framework_name/Versions/Current", | |
382 ] | |
383 args = [ | |
384 "$_framework_name", | |
385 "$_framework_version", | |
386 ] | |
387 public_deps = [ | |
388 ":$_framework_target", | |
389 ] | |
390 } | |
391 } | |
392 | |
393 group(_target_name + "+link") { | 432 group(_target_name + "+link") { |
394 forward_variables_from(invoker, | 433 forward_variables_from(invoker, |
395 [ | 434 [ |
396 "public_configs", | 435 "public_configs", |
397 "testonly", | 436 "testonly", |
398 "visibility", | 437 "visibility", |
399 ]) | 438 ]) |
400 public_deps = [ | 439 public_deps = [ |
401 ":$_target_name", | 440 ":$_target_name", |
402 ] | 441 ] |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 ]) | 686 ]) |
648 if (!defined(deps)) { | 687 if (!defined(deps)) { |
649 deps = [] | 688 deps = [] |
650 } | 689 } |
651 deps += [ ":$_loadable_module_bundle_data" ] | 690 deps += [ ":$_loadable_module_bundle_data" ] |
652 | 691 |
653 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 692 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
654 bundle_executable_dir = "$bundle_root_dir/MacOS" | 693 bundle_executable_dir = "$bundle_root_dir/MacOS" |
655 } | 694 } |
656 } | 695 } |
OLD | NEW |