Add support for generating PkgInfo for application bundle on iOS.

The generation of PkgInfo is disabled for the moment (as come target
downstream already pack a PkgInfo file and enabling the target would
cause a non-deterministic build) and can be enabled by an undocumented
parameter write_pkg_info.

Update build/config/mac/write_pkg_info.py to support loading plist
in any format, not only xml1.

BUG=672516

Review-Url: https://codereview.chromium.org/2559323005
Cr-Original-Commit-Position: refs/heads/master@{#437551}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8afe7bf6abf4c6c50b9c8f153e4ebf3cb045ef83
This commit is contained in:
sdefresne 2016-12-09 08:05:56 -08:00 коммит произвёл Commit bot
Родитель 50196c9d9b
Коммит 86b55ceb7a
2 изменённых файлов: 48 добавлений и 2 удалений

Просмотреть файл

@ -420,6 +420,17 @@ template("ios_app_bundle") {
_output_name = invoker.output_name
}
# TODO(sdefresne): some target downstream manually pack an PkgInfo, so
# allow controlling the generation of the PkgInfo file via an undocumented
# parameter until they are fixed.
_write_pkg_info = false
if (defined(invoker.write_pkg_info)) {
_write_pkg_info = invoker.write_pkg_info
}
assert(_write_pkg_info || !_write_pkg_info,
"prevents 'Assignment had no effect.' errors")
_arch_executable_source = _target_name + "_arch_executable_sources"
_arch_executable_target = _target_name + "_arch_executable"
_lipo_executable_target = _target_name + "_executable"
@ -634,6 +645,38 @@ template("ios_app_bundle") {
]
}
if (_write_pkg_info) {
_create_pkg_info = target_name + "_pkg_info"
action(_create_pkg_info) {
forward_variables_from(invoker, [ "testonly" ])
script = "//build/config/mac/write_pkg_info.py"
sources = get_target_outputs(":$_generate_info_plist")
outputs = [
# Cannot name the output PkgInfo as the name will not be unique if
# multiple ios_app_bundle are defined in the same BUILD.gn file. The
# file is renamed in the bundle_data outputs to the correct name.
"$target_gen_dir/$target_name",
]
args = [ "--plist" ] + rebase_path(sources, root_build_dir) +
[ "--output" ] + rebase_path(outputs, root_build_dir)
deps = [
":$_generate_info_plist",
]
}
_bundle_data_pkg_info = target_name + "_bundle_data_pkg_info"
bundle_data(_bundle_data_pkg_info) {
forward_variables_from(invoker, [ "testonly" ])
sources = get_target_outputs(":$_create_pkg_info")
outputs = [
"{{bundle_resources_dir}}/PkgInfo",
]
public_deps = [
":$_create_pkg_info",
]
}
}
create_signed_bundle(_target_name) {
forward_variables_from(invoker,
[
@ -661,6 +704,9 @@ template("ios_app_bundle") {
bundle_deps = []
}
bundle_deps += [ ":$_bundle_data_info_plist" ]
if (_write_pkg_info) {
bundle_deps += [ ":$_bundle_data_pkg_info" ]
}
if (use_ios_simulator) {
if (!defined(data_deps)) {

Просмотреть файл

@ -4,7 +4,7 @@
import argparse
import os
import plistlib
import plist_util
import sys
# This script creates a PkgInfo file for an OS X .app bundle's plist.
@ -24,7 +24,7 @@ def Main():
if os.path.exists(args.output):
os.unlink(args.output)
plist = plistlib.readPlist(args.plist)
plist = plist_util.LoadPList(args.plist)
package_type = plist['CFBundlePackageType']
if package_type != 'APPL':
raise ValueError('Expected CFBundlePackageType to be %s, got %s' % \