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("internal_rules.gni") |
| 6 |
5 # Declare a jni target | 7 # Declare a jni target |
6 # | 8 # |
7 # This target generates the native jni bindings for a set of .java files. | 9 # This target generates the native jni bindings for a set of .java files. |
8 # | 10 # |
9 # See base/android/jni_generator/jni_generator.py for more info about the | 11 # See base/android/jni_generator/jni_generator.py for more info about the |
10 # format of generating JNI bindings. | 12 # format of generating JNI bindings. |
11 # | 13 # |
12 # Variables | 14 # Variables |
13 # sources: list of .java files to generate jni for | 15 # sources: list of .java files to generate jni for |
14 # jni_package: subdirectory path for generated bindings | 16 # jni_package: subdirectory path for generated bindings |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 "--output_dir", rebase_path(jni_output_dir), | 52 "--output_dir", rebase_path(jni_output_dir), |
51 "--includes=${jni_generator_includes}", | 53 "--includes=${jni_generator_includes}", |
52 ] | 54 ] |
53 if (defined(invoker.jni_generator_jarjar_file)) { | 55 if (defined(invoker.jni_generator_jarjar_file)) { |
54 args += [ | 56 args += [ |
55 "--jarjar", rebase_path(jni_generator_jarjar_file) | 57 "--jarjar", rebase_path(jni_generator_jarjar_file) |
56 ] | 58 ] |
57 } | 59 } |
58 } | 60 } |
59 } | 61 } |
| 62 |
| 63 # Declare a target for c-preprocessor-generated java files |
| 64 # |
| 65 # This target generates java files using the host C pre-processor. Each file in |
| 66 # sources will be compiled using the C pre-processor. If include_path is |
| 67 # specified, it will be passed (with --I) to the pre-processor. |
| 68 # |
| 69 # This target will create a single .srcjar. Adding this target to a library |
| 70 # target's srcjar_deps will make the generated java files be included in that |
| 71 # library's final outputs. |
| 72 # |
| 73 # Variables |
| 74 # sources: list of files to be processed by the C pre-processor. For each |
| 75 # file in sources, there will be one .java file in the final .srcjar. For a |
| 76 # file named FooBar.template, a java file will be created with name |
| 77 # FooBar.java. |
| 78 # source_prereqs: additional compile-time dependencies. Any files |
| 79 # `#include`-ed in the templates should be listed here. |
| 80 # package_name: this will be the subdirectory for each .java file in the .srcj
ar. |
| 81 # |
| 82 # Example |
| 83 # java_cpp_template("foo_generated_enum") { |
| 84 # sources = [ |
| 85 # "android/java/templates/Foo.template", |
| 86 # ] |
| 87 # source_prereqs = [ |
| 88 # "android/java/templates/native_foo_header.h", |
| 89 # ] |
| 90 # |
| 91 # package_name = "org/chromium/base/library_loader" |
| 92 # include_path = "android/java/templates" |
| 93 # } |
| 94 template("java_cpp_template") { |
| 95 assert(defined(invoker.sources)) |
| 96 package_name = invoker.package_name + "" |
| 97 |
| 98 if (defined(invoker.include_path)) { |
| 99 include_path = invoker.include_path + "" |
| 100 } else { |
| 101 include_path = "//" |
| 102 } |
| 103 |
| 104 action_foreach("${target_name}__apply_gcc") { |
| 105 script = "//build/android/gyp/gcc_preprocess.py" |
| 106 if (defined(invoker.source_prereqs)) { |
| 107 source_prereqs = invoker.source_prereqs + [] |
| 108 } |
| 109 |
| 110 sources = invoker.sources |
| 111 |
| 112 gen_dir = "${target_gen_dir}/${package_name}" |
| 113 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" |
| 114 |
| 115 outputs = [ |
| 116 gcc_template_output_pattern |
| 117 ] |
| 118 |
| 119 args = [ |
| 120 "--include-path", rebase_path(include_path, root_build_dir), |
| 121 "--output", rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}.
java", |
| 122 "--template={{source}}", |
| 123 ] |
| 124 } |
| 125 |
| 126 apply_gcc_outputs = get_target_outputs(":${target_name}__apply_gcc") |
| 127 base_gen_dir = get_label_info(":${target_name}__apply_gcc", "target_gen_dir") |
| 128 |
| 129 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
| 130 zip("${target_name}__zip_srcjar") { |
| 131 inputs = apply_gcc_outputs |
| 132 output = srcjar_path |
| 133 base_dir = base_gen_dir |
| 134 } |
| 135 |
| 136 group(target_name) { |
| 137 deps = [ |
| 138 ":${target_name}__zip_srcjar" |
| 139 ] |
| 140 } |
| 141 } |
OLD | NEW |