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("//base/android/linker/config.gni") | 5 import("//base/android/linker/config.gni") |
6 import("//build/config/android/config.gni") | 6 import("//build/config/android/config.gni") |
7 import("//build/config/android/internal_rules.gni") | 7 import("//build/config/android/internal_rules.gni") |
8 import("//build/toolchain/toolchain.gni") | 8 import("//build/toolchain/toolchain.gni") |
9 import("//third_party/android_platform/config.gni") | 9 import("//third_party/android_platform/config.gni") |
10 import("//tools/grit/grit_rule.gni") | 10 import("//tools/grit/grit_rule.gni") |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 # | 320 # |
321 # This target will create a single .srcjar. Adding this target to an | 321 # This target will create a single .srcjar. Adding this target to an |
322 # android_library target's srcjar_deps will make the generated java files be | 322 # android_library target's srcjar_deps will make the generated java files be |
323 # included in that library's final outputs. | 323 # included in that library's final outputs. |
324 # | 324 # |
325 # Variables | 325 # Variables |
326 # sources: list of files to be processed by the script. For each annotated | 326 # sources: list of files to be processed by the script. For each annotated |
327 # enum contained in the sources files the script will generate a .java | 327 # enum contained in the sources files the script will generate a .java |
328 # file with the same name as the name of the enum. | 328 # file with the same name as the name of the enum. |
329 # | 329 # |
330 # outputs: list of outputs, relative to the output_dir. These paths are | |
331 # verified at build time by the script. To get the list programatically run: | |
332 # python build/android/gyp/java_cpp_enum.py \ | |
333 # --print_output_only . path/to/header/file.h | |
334 # | |
335 # Example | 330 # Example |
336 # java_cpp_enum("foo_generated_enum") { | 331 # java_cpp_enum("foo_generated_enum") { |
337 # sources = [ | 332 # sources = [ |
338 # "src/native_foo_header.h", | 333 # "src/native_foo_header.h", |
339 # ] | 334 # ] |
340 # outputs = [ | |
341 # "org/chromium/FooEnum.java", | |
342 # ] | |
343 # } | 335 # } |
344 template("java_cpp_enum") { | 336 template("java_cpp_enum") { |
345 set_sources_assignment_filter([]) | 337 action(target_name) { |
346 forward_variables_from(invoker, [ "testonly" ]) | |
347 | |
348 assert(defined(invoker.sources)) | |
349 assert(defined(invoker.outputs)) | |
350 | |
351 generate_enum_target_name = "${target_name}__generate_enum" | |
352 zip_srcjar_target_name = "${target_name}__zip_srcjar" | |
353 final_target_name = target_name | |
354 | |
355 action(generate_enum_target_name) { | |
356 visibility = [ ":$zip_srcjar_target_name" ] | |
357 | |
358 # The sources aren't compiled so don't check their dependencies. | 338 # The sources aren't compiled so don't check their dependencies. |
359 check_includes = false | 339 check_includes = false |
| 340 set_sources_assignment_filter([]) |
360 | 341 |
361 sources = invoker.sources | 342 assert(defined(invoker.sources)) |
| 343 forward_variables_from(invoker, |
| 344 [ |
| 345 "sources", |
| 346 "testonly", |
| 347 "visibility", |
| 348 ]) |
| 349 |
362 script = "//build/android/gyp/java_cpp_enum.py" | 350 script = "//build/android/gyp/java_cpp_enum.py" |
363 gen_dir = "${target_gen_dir}/${target_name}/enums" | |
364 outputs = | |
365 get_path_info(rebase_path(invoker.outputs, ".", gen_dir), "abspath") | |
366 | 351 |
367 args = [] | 352 _srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
368 foreach(output, rebase_path(outputs, root_build_dir)) { | 353 _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir) |
369 args += [ | 354 _rebased_sources = rebase_path(invoker.sources, root_build_dir) |
370 "--assert_file", | |
371 output, | |
372 ] | |
373 } | |
374 args += [ rebase_path(gen_dir, root_build_dir) ] | |
375 args += rebase_path(invoker.sources, root_build_dir) | |
376 } | |
377 | 355 |
378 generate_enum_outputs = get_target_outputs(":$generate_enum_target_name") | 356 args = [ "--srcjar=$_rebased_srcjar_path" ] + _rebased_sources |
379 base_gen_dir = get_label_info(":$generate_enum_target_name", "target_gen_dir") | 357 outputs = [ |
380 | 358 _srcjar_path, |
381 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" | |
382 zip(zip_srcjar_target_name) { | |
383 visibility = [ ":$final_target_name" ] | |
384 inputs = generate_enum_outputs | |
385 output = srcjar_path | |
386 base_dir = base_gen_dir | |
387 deps = [ | |
388 ":$generate_enum_target_name", | |
389 ] | |
390 } | |
391 | |
392 group(final_target_name) { | |
393 forward_variables_from(invoker, [ "visibility" ]) | |
394 public_deps = [ | |
395 ":$zip_srcjar_target_name", | |
396 ] | 359 ] |
397 } | 360 } |
398 } | 361 } |
399 | 362 |
400 # Declare a target for processing a Jinja template. | 363 # Declare a target for processing a Jinja template. |
401 # | 364 # |
402 # Variables | 365 # Variables |
403 # input: The template file to be processed. | 366 # input: The template file to be processed. |
404 # output: Where to save the result. | 367 # output: Where to save the result. |
405 # variables: (Optional) A list of variables to make available to the template | 368 # variables: (Optional) A list of variables to make available to the template |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 } | 2089 } |
2127 | 2090 |
2128 android_library(target_name) { | 2091 android_library(target_name) { |
2129 java_files = [] | 2092 java_files = [] |
2130 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2093 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
2131 deps = [ | 2094 deps = [ |
2132 "//third_party/android_protobuf:protobuf_nano_javalib", | 2095 "//third_party/android_protobuf:protobuf_nano_javalib", |
2133 ] | 2096 ] |
2134 } | 2097 } |
2135 } | 2098 } |
OLD | NEW |