1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# 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" ]
}
}
|