| 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/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/android/internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
| 7 import("//build/toolchain/toolchain.gni") | 7 import("//build/toolchain/toolchain.gni") |
| 8 | 8 |
| 9 assert(is_android) | 9 assert(is_android) |
| 10 | 10 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 # "android/java/templates/native_foo_header.h", | 358 # "android/java/templates/native_foo_header.h", |
| 359 # ] | 359 # ] |
| 360 # | 360 # |
| 361 # package_name = "org/chromium/base/library_loader" | 361 # package_name = "org/chromium/base/library_loader" |
| 362 # include_path = "android/java/templates" | 362 # include_path = "android/java/templates" |
| 363 # } | 363 # } |
| 364 template("java_cpp_template") { | 364 template("java_cpp_template") { |
| 365 set_sources_assignment_filter([]) | 365 set_sources_assignment_filter([]) |
| 366 forward_variables_from(invoker, [ "testonly" ]) | 366 forward_variables_from(invoker, [ "testonly" ]) |
| 367 | 367 |
| 368 assert(defined(invoker.sources)) | 368 _include_path = "//" |
| 369 package_name = invoker.package_name + "" | |
| 370 | |
| 371 if (defined(invoker.include_path)) { | 369 if (defined(invoker.include_path)) { |
| 372 include_path = invoker.include_path + "" | 370 _include_path = invoker.include_path |
| 373 } else { | |
| 374 include_path = "//" | |
| 375 } | 371 } |
| 376 | 372 |
| 377 apply_gcc_target_name = "${target_name}__apply_gcc" | 373 _apply_gcc_target_name = "${target_name}__apply_gcc" |
| 378 zip_srcjar_target_name = "${target_name}__zip_srcjar" | 374 _base_gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template" |
| 379 final_target_name = target_name | |
| 380 | 375 |
| 381 action_foreach(apply_gcc_target_name) { | 376 action_foreach(_apply_gcc_target_name) { |
| 382 forward_variables_from(invoker, | 377 forward_variables_from(invoker, |
| 383 [ | 378 [ |
| 384 "deps", | 379 "deps", |
| 385 "public_deps", | 380 "public_deps", |
| 386 "data_deps", | 381 "data_deps", |
| 387 ]) | 382 ]) |
| 388 visibility = [ ":$zip_srcjar_target_name" ] | |
| 389 script = "//build/android/gyp/gcc_preprocess.py" | 383 script = "//build/android/gyp/gcc_preprocess.py" |
| 390 if (defined(invoker.inputs)) { | 384 if (defined(invoker.inputs)) { |
| 391 inputs = invoker.inputs + [] | 385 inputs = invoker.inputs + [] |
| 392 } | 386 } |
| 393 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d" | 387 depfile = |
| 388 "${target_gen_dir}/${invoker.target_name}_{{source_name_part}}.d" |
| 394 | 389 |
| 395 sources = invoker.sources | 390 sources = invoker.sources |
| 396 | 391 |
| 397 gen_dir = | |
| 398 "${target_gen_dir}/${target_name}/java_cpp_template/${package_name}" | |
| 399 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" | |
| 400 | |
| 401 outputs = [ | 392 outputs = [ |
| 402 depfile, | 393 depfile, |
| 403 gcc_template_output_pattern, | 394 "$_base_gen_dir/${invoker.package_name}/{{source_name_part}}.java", |
| 404 ] | 395 ] |
| 405 | 396 |
| 406 args = [ | 397 args = [ |
| 407 "--depfile", | 398 "--depfile", |
| 408 rebase_path(depfile, root_build_dir), | 399 rebase_path(depfile, root_build_dir), |
| 409 "--include-path", | 400 "--include-path", |
| 410 rebase_path(include_path, root_build_dir), | 401 rebase_path(_include_path, root_build_dir), |
| 411 "--output", | 402 "--output", |
| 412 rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}.java", | 403 rebase_path(outputs[1], root_build_dir), |
| 413 "--template={{source}}", | 404 "--template={{source}}", |
| 414 ] | 405 ] |
| 415 | 406 |
| 416 if (defined(invoker.defines)) { | 407 if (defined(invoker.defines)) { |
| 417 foreach(def, invoker.defines) { | 408 foreach(def, invoker.defines) { |
| 418 args += [ | 409 args += [ |
| 419 "--defines", | 410 "--defines", |
| 420 def, | 411 def, |
| 421 ] | 412 ] |
| 422 } | 413 } |
| 423 } | 414 } |
| 424 } | 415 } |
| 425 | 416 |
| 426 apply_gcc_outputs = get_target_outputs(":$apply_gcc_target_name") | 417 # Filter out .d files. |
| 427 base_gen_dir = get_label_info(":$apply_gcc_target_name", "target_gen_dir") | 418 set_sources_assignment_filter([ "*.d" ]) |
| 419 sources = get_target_outputs(":$_apply_gcc_target_name") |
| 428 | 420 |
| 429 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" | 421 zip(target_name) { |
| 430 zip(zip_srcjar_target_name) { | 422 forward_variables_from(invoker, [ "visibility" ]) |
| 431 visibility = [ ":$final_target_name" ] | 423 inputs = sources |
| 432 inputs = apply_gcc_outputs | 424 output = "${target_gen_dir}/${target_name}.srcjar" |
| 433 output = srcjar_path | 425 base_dir = _base_gen_dir |
| 434 base_dir = base_gen_dir | |
| 435 deps = [ | 426 deps = [ |
| 436 ":$apply_gcc_target_name", | 427 ":$_apply_gcc_target_name", |
| 437 ] | |
| 438 } | |
| 439 | |
| 440 group(final_target_name) { | |
| 441 forward_variables_from(invoker, [ "visibility" ]) | |
| 442 public_deps = [ | |
| 443 ":$zip_srcjar_target_name", | |
| 444 ] | 428 ] |
| 445 } | 429 } |
| 446 } | 430 } |
| 447 | 431 |
| 448 # Declare a target for generating Java classes from C++ enums. | 432 # Declare a target for generating Java classes from C++ enums. |
| 449 # | 433 # |
| 450 # This target generates Java files from C++ enums using a script. | 434 # This target generates Java files from C++ enums using a script. |
| 451 # | 435 # |
| 452 # This target will create a single .srcjar. Adding this target to an | 436 # This target will create a single .srcjar. Adding this target to an |
| 453 # android_library target's srcjar_deps will make the generated java files be | 437 # android_library target's srcjar_deps will make the generated java files be |
| (...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 android_library(target_name) { | 2543 android_library(target_name) { |
| 2560 chromium_code = false | 2544 chromium_code = false |
| 2561 java_files = [] | 2545 java_files = [] |
| 2562 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2546 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
| 2563 deps = [ | 2547 deps = [ |
| 2564 "//third_party/android_protobuf:protobuf_nano_javalib", | 2548 "//third_party/android_protobuf:protobuf_nano_javalib", |
| 2565 ] | 2549 ] |
| 2566 } | 2550 } |
| 2567 } | 2551 } |
| 2568 } | 2552 } |
| OLD | NEW |