OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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("mojo.gni") | 5 import("mojo.gni") |
6 | 6 |
7 # Generate a binary Mojo application in a self-named directory. | 7 # Generate a binary mojo application.The parameters of this template are those |
8 # Application resources are copied to a "resources" directory alongside the app. | 8 # of a shared library. |
9 # The parameters of this template are those of a shared library. | |
10 template("mojo_native_application") { | 9 template("mojo_native_application") { |
11 base_target_name = target_name | |
12 if (defined(invoker.output_name)) { | 10 if (defined(invoker.output_name)) { |
13 base_target_name = invoker.output_name | 11 base_target_name = invoker.output_name |
| 12 } else { |
| 13 base_target_name = target_name |
14 } | 14 } |
15 | 15 |
16 final_target_name = target_name | 16 final_target_name = target_name |
17 | 17 |
18 mojo_deps = [] | |
19 if (defined(invoker.deps)) { | |
20 mojo_deps += invoker.deps | |
21 } | |
22 | |
23 if (defined(invoker.resources)) { | |
24 copy_step_name = "${base_target_name}__copy_resources" | |
25 copy(copy_step_name) { | |
26 sources = invoker.resources | |
27 outputs = [ | |
28 "${root_out_dir}/${base_target_name}/resources/{{source_file_part}}", | |
29 ] | |
30 if (defined(invoker.testonly)) { | |
31 testonly = invoker.testonly | |
32 } | |
33 deps = mojo_deps | |
34 } | |
35 mojo_deps += [ ":$copy_step_name" ] | |
36 } | |
37 | |
38 if (!is_nacl) { | 18 if (!is_nacl) { |
39 output = base_target_name + ".mojo" | 19 output = base_target_name + ".mojo" |
40 library_target_name = base_target_name + "_library" | 20 library_target_name = base_target_name + "_library" |
41 | 21 |
42 if (is_linux || is_android) { | 22 if (is_linux || is_android) { |
43 library_name = "lib${library_target_name}.so" | 23 library_name = "lib${library_target_name}.so" |
44 } else if (is_win) { | 24 } else if (is_win) { |
45 library_name = "${library_target_name}.dll" | 25 library_name = "${library_target_name}.dll" |
46 } else if (is_mac) { | 26 } else if (is_mac) { |
47 library_name = "lib${library_target_name}.dylib" | 27 library_name = "lib${library_target_name}.dylib" |
48 } else { | 28 } else { |
49 assert(false, "Platform not supported.") | 29 assert(false, "Platform not supported.") |
50 } | 30 } |
51 | 31 |
52 if (is_android) { | 32 if (is_android) { |
53 # On android, use the stripped version of the library, because | 33 # On android, use the stripped version of the library, because application
s |
54 # applications are always fetched over the network. | 34 # are always fetched over the network. |
55 library_dir = "${root_out_dir}/lib.stripped" | 35 library_dir = "${root_out_dir}/lib.stripped" |
56 } else { | 36 } else { |
57 library_dir = root_out_dir | 37 library_dir = root_out_dir |
58 } | 38 } |
59 | 39 |
60 shared_library(library_target_name) { | 40 shared_library(library_target_name) { |
61 if (defined(invoker.cflags)) { | 41 if (defined(invoker.cflags)) { |
62 cflags = invoker.cflags | 42 cflags = invoker.cflags |
63 } | 43 } |
64 if (defined(invoker.cflags_c)) { | 44 if (defined(invoker.cflags_c)) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ".", | 84 ".", |
105 mojo_root) ] | 85 mojo_root) ] |
106 } | 86 } |
107 | 87 |
108 deps = rebase_path([ | 88 deps = rebase_path([ |
109 "mojo/public/c/system", | 89 "mojo/public/c/system", |
110 "mojo/public/platform/native:system", | 90 "mojo/public/platform/native:system", |
111 ], | 91 ], |
112 ".", | 92 ".", |
113 mojo_root) | 93 mojo_root) |
114 deps += mojo_deps | 94 if (defined(invoker.deps)) { |
| 95 deps += invoker.deps |
| 96 } |
115 if (defined(invoker.forward_dependent_configs_from)) { | 97 if (defined(invoker.forward_dependent_configs_from)) { |
116 forward_dependent_configs_from = invoker.forward_dependent_configs_from | 98 forward_dependent_configs_from = invoker.forward_dependent_configs_from |
117 } | 99 } |
118 if (defined(invoker.public_deps)) { | 100 if (defined(invoker.public_deps)) { |
119 public_deps = invoker.public_deps | 101 public_deps = invoker.public_deps |
120 } | 102 } |
121 if (defined(invoker.all_dependent_configs)) { | 103 if (defined(invoker.all_dependent_configs)) { |
122 all_dependent_configs = invoker.all_dependent_configs | 104 all_dependent_configs = invoker.all_dependent_configs |
123 } | 105 } |
124 if (defined(invoker.public_configs)) { | 106 if (defined(invoker.public_configs)) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 visibility = invoker.visibility | 139 visibility = invoker.visibility |
158 } | 140 } |
159 deps = [ | 141 deps = [ |
160 ":${library_target_name}", | 142 ":${library_target_name}", |
161 ] | 143 ] |
162 | 144 |
163 sources = [ | 145 sources = [ |
164 "${library_dir}/${library_name}", | 146 "${library_dir}/${library_name}", |
165 ] | 147 ] |
166 outputs = [ | 148 outputs = [ |
167 "${root_out_dir}/${base_target_name}/${output}", | 149 "${root_out_dir}/${output}", |
168 ] | 150 ] |
169 } | 151 } |
170 } else { | 152 } else { |
171 nexe_target_name = base_target_name + "_nexe" | 153 nexe_target_name = base_target_name + "_nexe" |
172 nexe_name = base_target_name + ".nexe" | 154 nexe_name = base_target_name + ".nexe" |
173 | 155 |
174 output = "${base_target_name}_${target_cpu}.nexe.mojo" | 156 output = "${base_target_name}_${target_cpu}.nexe.mojo" |
175 | 157 |
176 executable(nexe_target_name) { | 158 executable(nexe_target_name) { |
177 output_name = base_target_name | 159 output_name = base_target_name |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 ".", | 204 ".", |
223 mojo_root) ] | 205 mojo_root) ] |
224 } | 206 } |
225 | 207 |
226 deps = rebase_path([ | 208 deps = rebase_path([ |
227 "mojo/public/c/system", | 209 "mojo/public/c/system", |
228 "mojo/public/platform/nacl:system", | 210 "mojo/public/platform/nacl:system", |
229 ], | 211 ], |
230 ".", | 212 ".", |
231 mojo_root) | 213 mojo_root) |
232 deps += mojo_deps | 214 if (defined(invoker.deps)) { |
| 215 deps += invoker.deps |
| 216 } |
233 if (defined(invoker.forward_dependent_configs_from)) { | 217 if (defined(invoker.forward_dependent_configs_from)) { |
234 forward_dependent_configs_from = invoker.forward_dependent_configs_from | 218 forward_dependent_configs_from = invoker.forward_dependent_configs_from |
235 } | 219 } |
236 if (defined(invoker.public_deps)) { | 220 if (defined(invoker.public_deps)) { |
237 public_deps = invoker.public_deps | 221 public_deps = invoker.public_deps |
238 } | 222 } |
239 if (defined(invoker.all_dependent_configs)) { | 223 if (defined(invoker.all_dependent_configs)) { |
240 all_dependent_configs = invoker.all_dependent_configs | 224 all_dependent_configs = invoker.all_dependent_configs |
241 } | 225 } |
242 if (defined(invoker.public_configs)) { | 226 if (defined(invoker.public_configs)) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 visibility = invoker.visibility | 259 visibility = invoker.visibility |
276 } | 260 } |
277 | 261 |
278 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | 262 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) |
279 | 263 |
280 input_path = "${root_out_dir}/${nexe_name}" | 264 input_path = "${root_out_dir}/${nexe_name}" |
281 inputs = [ | 265 inputs = [ |
282 input_path, | 266 input_path, |
283 ] | 267 ] |
284 | 268 |
285 output_path = "${root_build_dir}/${base_target_name}/${output}" | 269 output_path = "${root_build_dir}/${output}" |
286 outputs = [ | 270 outputs = [ |
287 output_path, | 271 output_path, |
288 ] | 272 ] |
289 | 273 |
290 deps = [ | 274 deps = [ |
291 ":${nexe_target_name}", | 275 ":${nexe_target_name}", |
292 ] | 276 ] |
293 | 277 |
294 rebase_input = rebase_path(input_path, root_build_dir) | 278 rebase_input = rebase_path(input_path, root_build_dir) |
295 rebase_output = rebase_path(output_path, root_build_dir) | 279 rebase_output = rebase_path(output_path, root_build_dir) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 deps = invoker.deps | 329 deps = invoker.deps |
346 } | 330 } |
347 if (defined(invoker.public_deps)) { | 331 if (defined(invoker.public_deps)) { |
348 public_deps = invoker.public_deps | 332 public_deps = invoker.public_deps |
349 } | 333 } |
350 if (defined(invoker.data_deps)) { | 334 if (defined(invoker.data_deps)) { |
351 data_deps = invoker.data_deps | 335 data_deps = invoker.data_deps |
352 } | 336 } |
353 } | 337 } |
354 | 338 |
| 339 if (defined(invoker.output_name)) { |
| 340 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" |
| 341 } else { |
| 342 mojo_output = "$root_out_dir/" + target_name + ".mojo" |
| 343 } |
| 344 |
355 action(target_name) { | 345 action(target_name) { |
356 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | 346 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) |
357 | 347 |
358 base_target_name = target_name | |
359 if (defined(invoker.output_name)) { | |
360 base_target_name = invoker.output_name | |
361 } | |
362 | |
363 input = zip_action_output | 348 input = zip_action_output |
364 inputs = [ | 349 inputs = [ |
365 input, | 350 input, |
366 ] | 351 ] |
367 | 352 |
368 output = "${root_out_dir}/${base_target_name}/${base_target_name}.mojo" | 353 output = mojo_output |
369 outputs = [ | 354 outputs = [ |
370 output, | 355 output, |
371 ] | 356 ] |
372 | 357 |
373 rebase_input = rebase_path(input, root_build_dir) | 358 rebase_input = rebase_path(input, root_build_dir) |
374 rebase_output = rebase_path(output, root_build_dir) | 359 rebase_output = rebase_path(output, root_build_dir) |
375 args = [ | 360 args = [ |
376 "--input=$rebase_input", | 361 "--input=$rebase_input", |
377 "--output=$rebase_output", | 362 "--output=$rebase_output", |
378 "--line=#!mojo mojo:android_handler", | 363 "--line=#!mojo mojo:android_handler", |
379 ] | 364 ] |
380 | 365 |
381 public_deps = [ | 366 public_deps = [ |
382 ":$zip_action_name", | 367 ":$zip_action_name", |
383 ] | 368 ] |
384 } | 369 } |
385 } | 370 } |
386 } | 371 } |
OLD | NEW |