naiveproxy/src/build/apple/compile_plist.gni
2022-05-03 18:16:59 +08:00

77 lines
2.5 KiB
Plaintext

# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Template to merge multiple plist files and perform variable substitutions.
#
# Arguments
#
# plist_templates:
# string array, paths to plist files which will be used for the bundle.
#
# format:
# string, the format to `plutil -convert` the plist to when
# generating the output.
#
# substitutions:
# string array, 'key=value' pairs used to replace ${key} by value
# when generating the output plist file.
#
# output_name:
# string, name of the generated plist file.
template("compile_plist") {
assert(defined(invoker.plist_templates),
"A list of template plist files must be specified for $target_name")
assert(defined(invoker.format),
"The plist format must be specified for $target_name")
assert(defined(invoker.substitutions),
"A list of key=value pairs must be specified for $target_name")
assert(defined(invoker.output_name),
"The name of the output file must be specified for $target_name")
_output_name = invoker.output_name
_merged_name = get_path_info(_output_name, "dir") + "/" +
get_path_info(_output_name, "name") + "_merged." +
get_path_info(_output_name, "extension")
_merge_target = target_name + "_merge"
action(_merge_target) {
forward_variables_from(invoker,
[
"deps",
"testonly",
])
script = "//build/apple/plist_util.py"
sources = invoker.plist_templates
outputs = [ _merged_name ]
args = [
"merge",
"-f=" + invoker.format,
"-o=" + rebase_path(_merged_name, root_build_dir),
] + rebase_path(invoker.plist_templates, root_build_dir)
}
action(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
script = "//build/apple/plist_util.py"
sources = [ _merged_name ]
outputs = [ _output_name ]
args = [
"substitute",
"-f=" + invoker.format,
"-o=" + rebase_path(_output_name, root_build_dir),
"-t=" + rebase_path(_merged_name, root_build_dir),
]
foreach(_substitution, invoker.substitutions) {
args += [ "-s=$_substitution" ]
}
deps = [ ":$_merge_target" ]
}
}