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("config.gni") | 5 import("//build/config/android/config.gni") |
6 import("internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
7 | 7 |
8 # Declare a jni target | 8 # Declare a jni target |
9 # | 9 # |
10 # This target generates the native jni bindings for a set of .java files. | 10 # This target generates the native jni bindings for a set of .java files. |
11 # | 11 # |
12 # See base/android/jni_generator/jni_generator.py for more info about the | 12 # See base/android/jni_generator/jni_generator.py for more info about the |
13 # format of generating JNI bindings. | 13 # format of generating JNI bindings. |
14 # | 14 # |
15 # Variables | 15 # Variables |
16 # sources: list of .java files to generate jni for | 16 # sources: list of .java files to generate jni for |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 # See base/android/jni_generator/jni_generator.py for more info about the | 84 # See base/android/jni_generator/jni_generator.py for more info about the |
85 # format of generating JNI bindings. | 85 # format of generating JNI bindings. |
86 # | 86 # |
87 # Variables | 87 # Variables |
88 # classes: list of .class files in the jar to generate jni for. These should | 88 # classes: list of .class files in the jar to generate jni for. These should |
89 # include the full path to the .class file. | 89 # include the full path to the .class file. |
90 # jni_package: subdirectory path for generated bindings | 90 # jni_package: subdirectory path for generated bindings |
91 # jar_file: the path to the .jar. If not provided, will default to the sdk's | 91 # jar_file: the path to the .jar. If not provided, will default to the sdk's |
92 # android.jar | 92 # android.jar |
93 # | 93 # |
| 94 # deps, forward_dependent_configs_from: As normal |
| 95 # |
94 # Example | 96 # Example |
95 # generate_jar_jni("foo_jni") { | 97 # generate_jar_jni("foo_jni") { |
96 # classes = [ | 98 # classes = [ |
97 # "android/view/Foo.class", | 99 # "android/view/Foo.class", |
98 # ] | 100 # ] |
99 # jni_package = "foo" | 101 # jni_package = "foo" |
100 # } | 102 # } |
101 template("generate_jar_jni") { | 103 template("generate_jar_jni") { |
102 assert(defined(invoker.classes)) | 104 assert(defined(invoker.classes)) |
103 assert(defined(invoker.jni_package)) | 105 assert(defined(invoker.jni_package)) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 direct_dependent_configs = [ ":jni_includes_${target_name}" ] | 166 direct_dependent_configs = [ ":jni_includes_${target_name}" ] |
165 } | 167 } |
166 } | 168 } |
167 | 169 |
168 # Declare a target for c-preprocessor-generated java files | 170 # Declare a target for c-preprocessor-generated java files |
169 # | 171 # |
170 # This target generates java files using the host C pre-processor. Each file in | 172 # This target generates java files using the host C pre-processor. Each file in |
171 # sources will be compiled using the C pre-processor. If include_path is | 173 # sources will be compiled using the C pre-processor. If include_path is |
172 # specified, it will be passed (with --I) to the pre-processor. | 174 # specified, it will be passed (with --I) to the pre-processor. |
173 # | 175 # |
174 # This target will create a single .srcjar. Adding this target to a library | 176 # This target will create a single .srcjar. Adding this target to an |
175 # target's srcjar_deps will make the generated java files be included in that | 177 # android_library target's srcjar_deps will make the generated java files be |
176 # library's final outputs. | 178 # included in that library's final outputs. |
177 # | 179 # |
178 # Variables | 180 # Variables |
179 # sources: list of files to be processed by the C pre-processor. For each | 181 # sources: list of files to be processed by the C pre-processor. For each |
180 # file in sources, there will be one .java file in the final .srcjar. For a | 182 # file in sources, there will be one .java file in the final .srcjar. For a |
181 # file named FooBar.template, a java file will be created with name | 183 # file named FooBar.template, a java file will be created with name |
182 # FooBar.java. | 184 # FooBar.java. |
183 # source_prereqs: additional compile-time dependencies. Any files | 185 # source_prereqs: additional compile-time dependencies. Any files |
184 # `#include`-ed in the templates should be listed here. | 186 # `#include`-ed in the templates should be listed here. |
185 # package_name: this will be the subdirectory for each .java file in the .srcj
ar. | 187 # package_name: this will be the subdirectory for each .java file in the .srcj
ar. |
186 # | 188 # |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 output = srcjar_path | 242 output = srcjar_path |
241 base_dir = base_gen_dir | 243 base_dir = base_gen_dir |
242 } | 244 } |
243 | 245 |
244 group(target_name) { | 246 group(target_name) { |
245 deps = [ | 247 deps = [ |
246 ":${target_name}__zip_srcjar" | 248 ":${target_name}__zip_srcjar" |
247 ] | 249 ] |
248 } | 250 } |
249 } | 251 } |
| 252 |
| 253 # Declare an Android library target |
| 254 # |
| 255 # This target creates an Android library containing java code and Android |
| 256 # resources. |
| 257 # |
| 258 # Variables |
| 259 # deps: Specifies the dependencies of this target. Java targets in this list |
| 260 # will be added to the javac classpath. |
| 261 # java_files: List of .java files included in this library. |
| 262 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars |
| 263 # will be added to java_files and be included in this library. |
| 264 # |
| 265 # jar_excluded_patterns: List of patterns of .class files to exclude from the
final jar. |
| 266 # |
| 267 # Example |
| 268 # android_library("foo_java") { |
| 269 # java_files = [ |
| 270 # "android/org/chromium/foo/Foo.java", |
| 271 # "android/org/chromium/foo/FooInterface.java", |
| 272 # "android/org/chromium/foo/FooService.java", |
| 273 # ] |
| 274 # deps = [ |
| 275 # ":bar_java" |
| 276 # ] |
| 277 # srcjar_deps = [ |
| 278 # ":foo_generated_enum" |
| 279 # ] |
| 280 # jar_excluded_patterns = [ |
| 281 # "*/FooService.class", "*/FooService##*.class" |
| 282 # ] |
| 283 # } |
| 284 template("android_library") { |
| 285 #TODO(cjhopman): resources |
| 286 |
| 287 assert(defined(invoker.java_files)) |
| 288 dep = ":${target_name}" |
| 289 base_path = get_label_info(dep, "target_gen_dir") + "/" + target_name |
| 290 build_config = base_path + ".build_config" |
| 291 |
| 292 write_build_config("${target_name}__build_config") { |
| 293 type = "android_library" |
| 294 |
| 295 deps = [] |
| 296 if (defined(invoker.deps)) { |
| 297 deps += invoker.deps |
| 298 } |
| 299 |
| 300 # base_path |
| 301 } |
| 302 |
| 303 jar_path = base_path + ".jar" |
| 304 android_java_library(target_name) { |
| 305 java_files = invoker.java_files |
| 306 build_config = build_config |
| 307 |
| 308 if (defined(invoker.jar_excluded_patterns)) { |
| 309 jar_excluded_patterns = invoker.jar_excluded_patterns |
| 310 } |
| 311 |
| 312 if (defined(invoker.srcjar_deps)) { |
| 313 srcjar_deps = invoker.srcjar_deps |
| 314 } |
| 315 } |
| 316 } |
| 317 |
OLD | NEW |