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/toolchain/toolchain.gni") | 5 import("//build/toolchain/toolchain.gni") |
6 | 6 |
7 mac_app_script = "//build/config/mac/mac_app.py" | |
8 | |
9 template("code_sign_mac") { | |
10 assert(defined(invoker.entitlements_path), | |
11 "The path to the entitlements .xcent file") | |
12 assert(defined(invoker.identity), "The code signing identity") | |
13 assert(defined(invoker.application_path), "The application to code sign") | |
14 assert(defined(invoker.deps)) | |
15 | |
16 action(target_name) { | |
17 sources = [ | |
18 invoker.entitlements_path, | |
19 ] | |
20 | |
21 _application_path = invoker.application_path | |
22 | |
23 script = mac_app_script | |
24 | |
25 outputs = [ | |
26 "$_application_path/_CodeSignature/CodeResources", | |
27 ] | |
28 | |
29 args = [ | |
30 "codesign", | |
31 "-p", | |
32 rebase_path(invoker.application_path, root_build_dir), | |
33 "-i", | |
34 invoker.identity, | |
35 "-e", | |
36 rebase_path(invoker.entitlements_path, root_build_dir), | |
37 ] | |
38 | |
39 forward_variables_from(invoker, | |
40 [ | |
41 "deps", | |
42 "public_deps", | |
43 "visibility", | |
44 ]) | |
45 } | |
46 } | |
47 | |
48 template("process_nibs_mac") { | |
49 assert(defined(invoker.sources), "The nib sources must be specified") | |
50 assert(defined(invoker.module), "The nib module must be specified") | |
51 assert(defined(invoker.output_dir), "The output directory must be specified") | |
52 | |
53 action_foreach(target_name) { | |
54 sources = invoker.sources | |
55 | |
56 script = mac_app_script | |
57 | |
58 invoker_out_dir = invoker.output_dir | |
59 | |
60 outputs = [ | |
61 "$root_build_dir/$invoker_out_dir/{{source_name_part}}.nib", | |
62 ] | |
63 | |
64 args = [ | |
65 "nib", | |
66 "-i", | |
67 "{{source}}", | |
68 "-o", | |
69 invoker_out_dir, | |
70 "-m", | |
71 invoker.module, | |
72 ] | |
73 } | |
74 | |
75 forward_variables_from(invoker, | |
76 [ | |
77 "deps", | |
78 "public_deps", | |
79 "visibility", | |
80 ]) | |
81 } | |
82 | |
83 template("resource_copy_mac") { | |
84 assert(defined(invoker.resources), | |
85 "The source list of resources to copy over") | |
86 assert(defined(invoker.bundle_directory), | |
87 "The directory within the bundle to place the sources in") | |
88 | |
89 if (defined(invoker.app_name)) { | |
90 _app_name = invoker.app_name | |
91 } else { | |
92 _app_name = target_name | |
93 } | |
94 | |
95 _bundle_directory = invoker.bundle_directory | |
96 _resources = invoker.resources | |
97 | |
98 copy(target_name) { | |
99 set_sources_assignment_filter([]) | |
100 sources = _resources | |
101 outputs = [ | |
102 "$root_build_dir/$_app_name.app/$_bundle_directory/Contents/Resources/{{so
urce_file_part}}", | |
103 ] | |
104 } | |
105 } | |
106 | |
107 template("mac_app") { | |
108 assert(defined(invoker.deps), | |
109 "Dependencies must be specified for $target_name") | |
110 assert(defined(invoker.info_plist), | |
111 "The application plist file must be specified for $target_name") | |
112 assert(defined(invoker.xibs), | |
113 "The list of XIB files must be specified for $target_name") | |
114 | |
115 group_gen_target_name = target_name | |
116 copy_all_target_name = target_name + "_all_copy" | |
117 | |
118 # We just create a variable so we can use the same in interpolation | |
119 if (defined(invoker.app_name)) { | |
120 _app_name = invoker.app_name | |
121 } else { | |
122 _app_name = target_name | |
123 } | |
124 | |
125 # Generate the executable | |
126 bin_gen_target_name = target_name + "_bin" | |
127 executable(bin_gen_target_name) { | |
128 visibility = [ ":$group_gen_target_name" ] | |
129 deps = invoker.deps | |
130 output_name = app_name | |
131 } | |
132 | |
133 # Process the Info.plist | |
134 plist_gen_target_name = target_name + "_plist" | |
135 | |
136 action(plist_gen_target_name) { | |
137 visibility = [ ":$group_gen_target_name" ] | |
138 script = mac_app_script | |
139 | |
140 sources = [ | |
141 invoker.info_plist, | |
142 ] | |
143 outputs = [ | |
144 "$root_build_dir/Info.plist", | |
145 ] | |
146 | |
147 args = [ | |
148 "plist", | |
149 "-i", | |
150 rebase_path(invoker.info_plist, root_build_dir), | |
151 "-o", | |
152 rebase_path(root_build_dir), | |
153 ] | |
154 } | |
155 | |
156 # Copy the generated binaries and assets to their appropriate locations | |
157 copy_plist_gen_target_name = target_name + "_plist_copy" | |
158 copy(copy_plist_gen_target_name) { | |
159 visibility = [ ":$group_gen_target_name" ] | |
160 sources = [ | |
161 "$root_build_dir/Info.plist", | |
162 ] | |
163 | |
164 outputs = [ | |
165 "$root_build_dir/$app_name.app/Contents/{{source_file_part}}", | |
166 ] | |
167 | |
168 deps = [ | |
169 ":$plist_gen_target_name", | |
170 ] | |
171 } | |
172 | |
173 copy_bin_target_name = target_name + "_bin_copy" | |
174 copy(copy_bin_target_name) { | |
175 visibility = [ ":$group_gen_target_name" ] | |
176 sources = [ | |
177 "$root_build_dir/$app_name", | |
178 ] | |
179 | |
180 outputs = [ | |
181 "$root_build_dir/$app_name.app/Contents/MacOS/{{source_file_part}}", | |
182 ] | |
183 | |
184 deps = [ | |
185 ":$bin_gen_target_name", | |
186 ] | |
187 } | |
188 | |
189 copy_xib_target_name = target_name + "_xib_copy" | |
190 process_nibs_mac(copy_xib_target_name) { | |
191 visibility = [ ":$group_gen_target_name" ] | |
192 sources = invoker.xibs | |
193 module = app_name | |
194 output_dir = "$app_name.app/Contents/Resources" | |
195 } | |
196 | |
197 group(copy_all_target_name) { | |
198 visibility = [ ":$group_gen_target_name" ] | |
199 deps = [ | |
200 ":$copy_bin_target_name", | |
201 ":$copy_plist_gen_target_name", | |
202 ":$copy_xib_target_name", | |
203 ":$struct_gen_target_name", | |
204 ] | |
205 } | |
206 | |
207 # Top level group | |
208 | |
209 group(group_gen_target_name) { | |
210 deps = [ | |
211 ":$copy_all_target_name", | |
212 ] | |
213 } | |
214 } | |
215 | |
216 # Template to package a shared library into a Mac framework bundle. | 7 # Template to package a shared library into a Mac framework bundle. |
217 # | 8 # |
218 # Arguments | 9 # Arguments |
219 # | 10 # |
220 # info_plist: | 11 # info_plist: |
221 # string, path to the Info.plist file that will be used for the bundle. | 12 # string, path to the Info.plist file that will be used for the bundle. |
222 # | 13 # |
223 # output_name: | 14 # output_name: |
224 # (optional) string, name of the generated framework without the | 15 # (optional) string, name of the generated framework without the |
225 # .framework suffix. If omitted, defaults to target_name. | 16 # .framework suffix. If omitted, defaults to target_name. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 [ | 138 [ |
348 "visibility", | 139 "visibility", |
349 "testonly", | 140 "testonly", |
350 ]) | 141 ]) |
351 deps = [ | 142 deps = [ |
352 ":$_framework_target", | 143 ":$_framework_target", |
353 ] | 144 ] |
354 } | 145 } |
355 } | 146 } |
356 } | 147 } |
OLD | NEW |