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

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

Issue 2475893002: Add template to compile plist files. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 # This file contains rules that are shared between Mac and iOS. 5 # This file contains rules that are shared between Mac and iOS.
6 6
7 import("//build/toolchain/toolchain.gni") 7 import("//build/toolchain/toolchain.gni")
8 import("//build/config/mac/symbols.gni") 8 import("//build/config/mac/symbols.gni")
9 9
10 if (is_mac) { 10 if (is_mac) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 "plutil", 49 "plutil",
50 "-convert", 50 "-convert",
51 invoker.format, 51 invoker.format,
52 "-o", 52 "-o",
53 rebase_path(invoker.output, root_build_dir), 53 rebase_path(invoker.output, root_build_dir),
54 rebase_path(invoker.source, root_build_dir), 54 rebase_path(invoker.source, root_build_dir),
55 ] 55 ]
56 } 56 }
57 } 57 }
58 58
59 # The base template used to generate Info.plist files for iOS and Mac apps and 59 # Template to merge multiple plist files and perform variable substitutions.
60 # frameworks.
61 # 60 #
62 # Arguments 61 # Arguments
63 # 62 #
64 # plist_templates: 63 # plist_templates:
65 # string array, paths to plist files which will be used for the bundle. 64 # string array, paths to plist files which will be used for the bundle.
66 # 65 #
67 # executable_name:
68 # string, name of the generated target used for the product
69 # and executable name as specified in the output Info.plist.
70 #
71 # format: 66 # format:
72 # string, the format to `plutil -convert` the plist to when 67 # string, the format to `plutil -convert` the plist to when
73 # generating the output. 68 # generating the output.
74 # 69 #
75 # extra_substitutions: 70 # substitutions:
76 # (optional) string array, 'key=value' pairs for extra fields which are 71 # string array, 'key=value' pairs used to replace ${key} by value
77 # specified in a source Info.plist template. 72 # when generating the output plist file.
78 # 73 #
79 # output_name: 74 # output_name:
80 # (optional) string, name of the generated plist file, default to 75 # string, name of the generated plist file.
81 # "$target_gen_dir/$target_name.plist". 76 template("compile_plist") {
82 template("info_plist") {
83 assert(defined(invoker.plist_templates), 77 assert(defined(invoker.plist_templates),
84 "A list of template plist files must be specified for $target_name") 78 "A list of template plist files must be specified for $target_name")
85 assert(defined(invoker.executable_name),
86 "The executable_name must be specified for $target_name")
87 assert(defined(invoker.format), 79 assert(defined(invoker.format),
88 "The plist format must be specified for $target_name") 80 "The plist format must be specified for $target_name")
89 executable_name = invoker.executable_name 81 assert(defined(invoker.substitutions),
82 "A list of key=value pairs must be specified for $target_name")
83 assert(defined(invoker.output_name),
84 "The name of the output file must be specified for $target_name")
90 85
91 _output_name = "$target_gen_dir/$target_name.plist" 86 _output_name = invoker.output_name
92 if (defined(invoker.output_name)) {
93 _output_name = invoker.output_name
94 }
95
96 _merged_name = get_path_info(_output_name, "dir") + "/" + 87 _merged_name = get_path_info(_output_name, "dir") + "/" +
97 get_path_info(_output_name, "name") + "_merged" + 88 get_path_info(_output_name, "name") + "_merged." +
98 get_path_info(_output_name, "extension") 89 get_path_info(_output_name, "extension")
99 90
100 action(target_name + "_merge_templates") { 91 _merge_target = target_name + "_merge"
92
93 action(_merge_target) {
101 forward_variables_from(invoker, 94 forward_variables_from(invoker,
102 [ 95 [
103 "deps", 96 "deps",
104 "testonly", 97 "testonly",
105 ]) 98 ])
106 99
107 script = "//build/config/mac/plist_util.py" 100 script = "//build/config/mac/plist_util.py"
108 sources = invoker.plist_templates 101 sources = invoker.plist_templates
109 outputs = [ 102 outputs = [
110 _merged_name, 103 _merged_name,
111 ] 104 ]
112 args = [ 105 args = [
113 "merge", 106 "merge",
114 "-f=" + invoker.format, 107 "-f=" + invoker.format,
115 "-o=" + rebase_path(_merged_name, root_build_dir), 108 "-o=" + rebase_path(_merged_name, root_build_dir),
116 ] + rebase_path(sources, root_build_dir) 109 ] + rebase_path(invoker.plist_templates, root_build_dir)
117 } 110 }
118 111
119 action(target_name) { 112 action(target_name) {
120 forward_variables_from(invoker, 113 forward_variables_from(invoker,
121 [ 114 [
122 "testonly", 115 "testonly",
123 "visibility", 116 "visibility",
124 ]) 117 ])
125 script = "//build/config/mac/plist_util.py" 118 script = "//build/config/mac/plist_util.py"
126 sources = [ 119 sources = [
127 _merged_name, 120 _merged_name,
128 ] 121 ]
129 outputs = [ 122 outputs = [
130 _output_name, 123 _output_name,
131 ] 124 ]
132 args = [ "substitute" ] 125 args = [
133 if (defined(invoker.extra_substitutions)) { 126 "substitute",
134 foreach(substitution, invoker.extra_substitutions) { 127 "-f=" + invoker.format,
135 args += [ "-s=$substitution" ]
136 }
137 }
138 args += [
139 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
140 "-s=EXECUTABLE_NAME=$executable_name",
141 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
142 "-s=PRODUCT_NAME=$executable_name",
143 "-s=XCODE_BUILD=$xcode_build",
144 "-s=XCODE_VERSION=$xcode_version",
145 "-o=" + rebase_path(_output_name, root_build_dir), 128 "-o=" + rebase_path(_output_name, root_build_dir),
146 "-t=" + rebase_path(_merged_name, root_build_dir), 129 "-t=" + rebase_path(_merged_name, root_build_dir),
147 "-f=" + invoker.format,
148 ] 130 ]
131 foreach(_substitution, invoker.substitutions) {
132 args += [ "-s=$_substitution" ]
133 }
149 deps = [ 134 deps = [
150 ":" + target_name + "_merge_templates", 135 ":$_merge_target",
151 ] 136 ]
152 } 137 }
153 } 138 }
154 139
140 # The base template used to generate Info.plist files for iOS and Mac apps and
141 # frameworks.
142 #
143 # Arguments
144 #
145 # plist_templates:
146 # string array, paths to plist files which will be used for the bundle.
147 #
148 # executable_name:
149 # string, name of the generated target used for the product
150 # and executable name as specified in the output Info.plist.
151 #
152 # format:
153 # string, the format to `plutil -convert` the plist to when
154 # generating the output.
155 #
156 # extra_substitutions:
157 # (optional) string array, 'key=value' pairs for extra fields which are
158 # specified in a source Info.plist template.
159 #
160 # output_name:
161 # (optional) string, name of the generated plist file, default to
162 # "$target_gen_dir/$target_name.plist".
163 template("info_plist") {
164 assert(defined(invoker.executable_name),
165 "The executable_name must be specified for $target_name")
166 executable_name = invoker.executable_name
167
168 compile_plist(target_name) {
169 forward_variables_from(invoker,
170 [
171 "plist_templates",
172 "testonly",
173 "deps",
174 "visibility",
175 "format",
176 ])
177
178 if (defined(invoker.output_name)) {
179 output_name = invoker.output_name
180 } else {
181 output_name = "$target_gen_dir/$target_name.plist"
182 }
183
184 substitutions = [
185 "BUILD_MACHINE_OS_BUILD=$machine_os_build",
186 "EXECUTABLE_NAME=$executable_name",
187 "GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
188 "PRODUCT_NAME=$executable_name",
189 "XCODE_BUILD=$xcode_build",
190 "XCODE_VERSION=$xcode_version",
191 ]
192 if (defined(invoker.extra_substitutions)) {
193 substitutions += invoker.extra_substitutions
194 }
195 }
196 }
197
155 # Template to combile .xib or .storyboard files. 198 # Template to combile .xib or .storyboard files.
156 # 199 #
157 # Arguments 200 # Arguments
158 # 201 #
159 # sources: 202 # sources:
160 # list of string, sources to compile 203 # list of string, sources to compile
161 # 204 #
162 # ibtool_flags: 205 # ibtool_flags:
163 # (optional) list of string, additional flags to pass to the ibtool 206 # (optional) list of string, additional flags to pass to the ibtool
164 template("compile_xibs") { 207 template("compile_xibs") {
(...skipping 24 matching lines...) Expand all
189 ] 232 ]
190 if (!use_system_xcode) { 233 if (!use_system_xcode) {
191 args += [ 234 args += [
192 "--developer_dir", 235 "--developer_dir",
193 hermetic_xcode_path, 236 hermetic_xcode_path,
194 ] 237 ]
195 } 238 }
196 args += ibtool_flags 239 args += ibtool_flags
197 } 240 }
198 } 241 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698