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("//build/module_args/mojo.gni") | 5 import("//build/module_args/mojo.gni") |
6 import("mojo.gni") | 6 import("mojo.gni") |
7 import("mojo_sdk.gni") | 7 import("mojo_sdk.gni") |
8 | 8 |
9 # Generate a binary mojo application.The parameters of this template are those | 9 # Generate a binary mojo application.The parameters of this template are those |
10 # of a shared library. | 10 # of a shared library. |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 args = [ | 304 args = [ |
305 "--input=$rebase_input", | 305 "--input=$rebase_input", |
306 "--output=$rebase_output", | 306 "--output=$rebase_output", |
307 "--line=#!mojo mojo:nacl_content_handler", | 307 "--line=#!mojo mojo:nacl_content_handler", |
308 ] | 308 ] |
309 } | 309 } |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 if (is_android) { | 313 if (is_android) { |
| 314 import("//build/config/android/rules.gni") |
| 315 |
314 # Declares an Android Mojo application consisting of an .so file and a | 316 # Declares an Android Mojo application consisting of an .so file and a |
315 # corresponding .dex.jar file. | 317 # corresponding .dex.jar file. |
316 # | 318 # |
317 # Variables: | 319 # Variables: |
318 # input_so: the .so file to bundle | 320 # sources (optional): The c++ sources. |
319 # input_dex_jar: the .dex.jar file to bundle | 321 # deps (optional): The c++ dependencies. |
320 # deps / public_deps / data_deps (optional): | 322 # java_sources (optional): The java sources. |
321 # Dependencies. The targets that generate the .so/jar inputs should be | 323 # java_deps (optional): The java dependencies. |
322 # listed in either deps or public_deps. | 324 # jni_package (optional): The c++ package for the generated jni headers. |
323 # output_name (optional): override for the output file name | 325 # output_name (optional): override for the output file name |
| 326 # public_deps / data_deps (optional): Dependencies. |
324 template("mojo_android_application") { | 327 template("mojo_android_application") { |
325 assert(defined(invoker.input_so)) | 328 shared_library_name = "__${target_name}_lib" |
326 assert(defined(invoker.input_dex_jar)) | 329 library_basename = "lib${shared_library_name}.so" |
| 330 generate_jni_name = "__${target_name}_jni" |
| 331 java_library_name = "__${target_name}_java" |
| 332 android_standalone_library_name = "__${target_name}_java_lib" |
| 333 dex_output_path = "${target_gen_dir}/${target_name}.dex" |
| 334 zip_action_name = "__${target_name}_zip" |
| 335 zip_action_output = "${target_gen_dir}/${target_name}.zip" |
| 336 copy_symbols_target = "__${target_name}_copy_symbols" |
| 337 final_target_name = target_name |
327 | 338 |
328 zip_action_name = "${target_name}_zip" | 339 if (defined(invoker.java_sources) && defined(invoker.jni_package)) { |
329 zip_action_output = "$target_gen_dir/${target_name}.zip" | 340 generate_jni(generate_jni_name) { |
330 prepend_action_name = target_name | 341 visibility = [ ":${shared_library_name}" ] |
| 342 |
| 343 sources = invoker.java_sources |
| 344 jni_package = invoker.jni_package |
| 345 } |
| 346 } |
| 347 |
| 348 shared_library(shared_library_name) { |
| 349 visibility = [ |
| 350 ":${copy_symbols_target}", |
| 351 ":${zip_action_name}", |
| 352 ] |
| 353 |
| 354 if (defined(invoker.sources)) { |
| 355 sources = invoker.sources |
| 356 } |
| 357 |
| 358 deps = [] |
| 359 if (defined(invoker.java_sources) && defined(invoker.jni_package)) { |
| 360 deps += [ ":${generate_jni_name}" ] |
| 361 } |
| 362 if (defined(invoker.deps)) { |
| 363 deps += invoker.deps |
| 364 } |
| 365 } |
| 366 |
| 367 copy(copy_symbols_target) { |
| 368 visibility = [ ":${final_target_name}" ] |
| 369 deps = [ |
| 370 ":${shared_library_name}", |
| 371 ] |
| 372 |
| 373 sources = [ |
| 374 "${root_out_dir}/${library_basename}", |
| 375 ] |
| 376 outputs = [ |
| 377 "${root_out_dir}/symbols/${library_basename}", |
| 378 ] |
| 379 } |
| 380 |
| 381 android_library(java_library_name) { |
| 382 visibility = [ ":*" ] |
| 383 |
| 384 if (defined(invoker.java_sources)) { |
| 385 java_files = invoker.java_sources |
| 386 } |
| 387 |
| 388 if (defined(invoker.java_deps)) { |
| 389 deps = invoker.java_deps |
| 390 } |
| 391 } |
| 392 |
| 393 android_standalone_library(android_standalone_library_name) { |
| 394 deps = [ |
| 395 ":${java_library_name}", |
| 396 ] |
| 397 |
| 398 if (defined(invoker.java_deps)) { |
| 399 deps += invoker.java_deps |
| 400 } |
| 401 |
| 402 dex_path = dex_output_path |
| 403 } |
| 404 |
331 action(zip_action_name) { | 405 action(zip_action_name) { |
332 visibility = [ ":$prepend_action_name" ] | 406 visibility = [ ":${final_target_name}" ] |
333 script = "//build/android/gn/zip.py" | 407 script = "//build/android/gn/zip.py" |
334 | 408 |
335 inputs = [ | 409 inputs = [ |
336 invoker.input_so, | 410 "${root_out_dir}/lib.stripped/${library_basename}", |
337 invoker.input_dex_jar, | 411 dex_output_path, |
338 ] | 412 ] |
339 | 413 |
340 output = zip_action_output | 414 output = zip_action_output |
341 outputs = [ | 415 outputs = [ |
342 output, | 416 output, |
343 ] | 417 ] |
344 | 418 |
345 rebase_inputs = rebase_path(inputs, root_build_dir) | 419 rebase_inputs = rebase_path(inputs, root_build_dir) |
346 rebase_output = rebase_path(output, root_build_dir) | 420 rebase_output = rebase_path(output, root_build_dir) |
347 args = [ | 421 args = [ |
348 "--inputs=$rebase_inputs", | 422 "--inputs=${rebase_inputs}", |
349 "--output=$rebase_output", | 423 "--output=${rebase_output}", |
350 ] | 424 ] |
351 | 425 |
352 if (defined(invoker.deps)) { | 426 if (defined(invoker.deps)) { |
353 deps = invoker.deps | 427 deps = invoker.deps |
354 } | 428 } |
355 if (defined(invoker.public_deps)) { | 429 if (defined(invoker.public_deps)) { |
356 public_deps = invoker.public_deps | 430 public_deps = invoker.public_deps |
357 } | 431 } |
358 if (defined(invoker.data_deps)) { | 432 if (defined(invoker.data_deps)) { |
359 data_deps = invoker.data_deps | 433 data_deps = invoker.data_deps |
360 } | 434 } |
361 } | 435 } |
362 | 436 |
363 if (defined(invoker.output_name)) { | 437 if (defined(invoker.output_name)) { |
364 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" | 438 mojo_output = "${root_out_dir}/" + invoker.output_name + ".mojo" |
365 } else { | 439 } else { |
366 mojo_output = "$root_out_dir/" + target_name + ".mojo" | 440 mojo_output = "${root_out_dir}/" + target_name + ".mojo" |
367 } | 441 } |
368 | 442 |
369 action(target_name) { | 443 action(final_target_name) { |
370 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | 444 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) |
371 | 445 |
372 input = zip_action_output | 446 input = zip_action_output |
373 inputs = [ | 447 inputs = [ |
374 input, | 448 input, |
375 ] | 449 ] |
376 | 450 |
377 output = mojo_output | 451 output = mojo_output |
378 outputs = [ | 452 outputs = [ |
379 output, | 453 output, |
380 ] | 454 ] |
381 | 455 |
382 rebase_input = rebase_path(input, root_build_dir) | 456 rebase_input = rebase_path(input, root_build_dir) |
383 rebase_output = rebase_path(output, root_build_dir) | 457 rebase_output = rebase_path(output, root_build_dir) |
384 args = [ | 458 args = [ |
385 "--input=$rebase_input", | 459 "--input=${rebase_input}", |
386 "--output=$rebase_output", | 460 "--output=${rebase_output}", |
387 "--line=#!mojo mojo:android_handler", | 461 "--line=#!mojo mojo:android_handler", |
388 ] | 462 ] |
389 | 463 |
| 464 deps = [ |
| 465 ":${copy_symbols_target}", |
| 466 ] |
| 467 |
390 public_deps = [ | 468 public_deps = [ |
391 ":$zip_action_name", | 469 ":${zip_action_name}", |
392 ] | 470 ] |
393 } | 471 } |
394 } | 472 } |
395 } | 473 } |
OLD | NEW |