| 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("internal_rules.gni") | 6 import("internal_rules.gni") |
| 6 | 7 |
| 7 # Declare a jni target | 8 # Declare a jni target |
| 8 # | 9 # |
| 9 # 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. |
| 10 # | 11 # |
| 11 # 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 |
| 12 # format of generating JNI bindings. | 13 # format of generating JNI bindings. |
| 13 # | 14 # |
| 14 # Variables | 15 # Variables |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 if (defined(invoker.jni_generator_jarjar_file)) { | 56 if (defined(invoker.jni_generator_jarjar_file)) { |
| 56 args += [ | 57 args += [ |
| 57 "--jarjar", rebase_path(jni_generator_jarjar_file) | 58 "--jarjar", rebase_path(jni_generator_jarjar_file) |
| 58 ] | 59 ] |
| 59 } | 60 } |
| 60 | 61 |
| 61 hard_dep = true | 62 hard_dep = true |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 66 |
| 65 # Declare a target for c-preprocessor-generated java files | 67 # Declare a target for c-preprocessor-generated java files |
| 66 # | 68 # |
| 67 # This target generates java files using the host C pre-processor. Each file in | 69 # This target generates java files using the host C pre-processor. Each file in |
| 68 # sources will be compiled using the C pre-processor. If include_path is | 70 # sources will be compiled using the C pre-processor. If include_path is |
| 69 # specified, it will be passed (with --I) to the pre-processor. | 71 # specified, it will be passed (with --I) to the pre-processor. |
| 70 # | 72 # |
| 71 # This target will create a single .srcjar. Adding this target to a library | 73 # This target will create a single .srcjar. Adding this target to a library |
| 72 # target's srcjar_deps will make the generated java files be included in that | 74 # target's srcjar_deps will make the generated java files be included in that |
| 73 # library's final outputs. | 75 # library's final outputs. |
| 74 # | 76 # |
| 75 # Variables | 77 # Variables |
| 76 # sources: list of files to be processed by the C pre-processor. For each | 78 # sources: list of files to be processed by the C pre-processor. For each |
| 77 # file in sources, there will be one .java file in the final .srcjar. For a | 79 # file in sources, there will be one .java file in the final .srcjar. For a |
| 78 # file named FooBar.template, a java file will be created with name | 80 # file named FooBar.template, a java file will be created with name |
| 79 # FooBar.java. | 81 # FooBar.java. |
| 80 # source_prereqs: additional compile-time dependencies. Any files | 82 # source_prereqs: additional compile-time dependencies. Any files |
| 81 # `#include`-ed in the templates should be listed here. | 83 # `#include`-ed in the templates should be listed here. |
| 82 # package_name: this will be the subdirectory for each .java file in the .srcj
ar. | 84 # package_name: this will be the subdirectory for each .java file in the .srcj
ar. |
| 83 # | 85 # |
| 84 # Example | 86 # Example |
| 85 # java_cpp_template("foo_jni") { | 87 # java_cpp_template("foo_generated_enum") { |
| 86 # sources = [ | 88 # sources = [ |
| 87 # "android/java/templates/Foo.template", | 89 # "android/java/templates/Foo.template", |
| 88 # ] | 90 # ] |
| 89 # source_prereqs = [ | 91 # source_prereqs = [ |
| 90 # "android/java/templates/native_foo_header.h", | 92 # "android/java/templates/native_foo_header.h", |
| 91 # ] | 93 # ] |
| 92 # | 94 # |
| 93 # package_name = "org/chromium/base/library_loader" | 95 # package_name = "org/chromium/base/library_loader" |
| 94 # include_path = "android/java/templates" | 96 # include_path = "android/java/templates" |
| 95 # } | 97 # } |
| 96 template("java_cpp_template") { | 98 template("java_cpp_template") { |
| 97 assert(defined(invoker.sources)) | 99 assert(defined(invoker.sources)) |
| 98 package_name = invoker.package_name + "" | 100 package_name = invoker.package_name + "" |
| 99 | 101 |
| 100 if (defined(invoker.include_path)) { | 102 if (defined(invoker.include_path)) { |
| 101 include_path = invoker.include_path + "" | 103 include_path = invoker.include_path + "" |
| 102 } else { | 104 } else { |
| 103 include_path = "//" | 105 include_path = "//" |
| 104 } | 106 } |
| 105 | 107 |
| 106 base_gen_dir = "${root_gen_dir}/java_cpp_template/${target_name}/${package_nam
e}" | 108 base_gen_dir = "${root_gen_dir}/java_cpp_template/${target_name}/${package_nam
e}" |
| 107 gen_dir = "${base_gen_dir}/${package_name}" | 109 gen_dir = "${base_gen_dir}/${package_name}" |
| 110 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" |
| 108 apply_gcc_outputs = process_file_template( | 111 apply_gcc_outputs = process_file_template( |
| 109 invoker.sources, | 112 invoker.sources, gcc_template_output_pattern |
| 110 "${gen_dir}/{{source_name_part}}.java" | |
| 111 ) | 113 ) |
| 112 | 114 |
| 113 action_foreach("${target_name}__apply_gcc") { | 115 action_foreach("${target_name}__apply_gcc") { |
| 114 script = "//build/android/gyp/gcc_preprocess.py" | 116 script = "//build/android/gyp/gcc_preprocess.py" |
| 115 if (defined(invoker.source_prereqs)) { | 117 if (defined(invoker.source_prereqs)) { |
| 116 source_prereqs = invoker.source_prereqs + [] | 118 source_prereqs = invoker.source_prereqs + [] |
| 117 } | 119 } |
| 118 | 120 |
| 119 sources = invoker.sources | 121 sources = invoker.sources |
| 120 outputs = [ | 122 outputs = [ |
| 121 "${gen_dir}/{{source_name_part}}.java" | 123 gcc_template_output_pattern |
| 122 ] | 124 ] |
| 123 | 125 |
| 124 args = [ | 126 args = [ |
| 125 "--include-path", rebase_path(include_path), | 127 "--include-path", rebase_path(include_path), |
| 126 "--output", rebase_path(gen_dir) + "/{{source_name_part}}.java", | 128 "--output", rebase_path(gen_dir) + "/{{source_name_part}}.java", |
| 127 "--template={{source}}", | 129 "--template={{source}}", |
| 128 ] | 130 ] |
| 129 } | 131 } |
| 130 | 132 |
| 133 srcjar_path = get_target_gen_path(":${target_name}", ".srcjar") |
| 131 _zip("${target_name}__zip_srcjar") { | 134 _zip("${target_name}__zip_srcjar") { |
| 132 inputs = apply_gcc_outputs | 135 inputs = apply_gcc_outputs |
| 133 output = get_target_gen_path(target_name, ".srcjar") | 136 output = srcjar_path |
| 134 base_dir = base_gen_dir | 137 base_dir = base_gen_dir |
| 135 } | 138 } |
| 136 | 139 |
| 137 group(target_name) { | 140 group(target_name) { |
| 138 deps = [ | 141 deps = [ |
| 139 ":${target_name}__zip_srcjar" | 142 ":${target_name}__zip_srcjar" |
| 140 ] | 143 ] |
| 141 } | 144 } |
| 142 } | 145 } |
| 143 | 146 |
| 144 | 147 |
| 148 # Declare an Android library target |
| 149 # |
| 150 # This target creates an Android library containing java code and Android |
| 151 # resources. |
| 152 # |
| 153 # Variables |
| 154 # android_library_deps: list of other Android libraries that this library |
| 155 # depends on. |
| 156 # java_files: List of .java files included in this library. |
| 157 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars |
| 158 # will be added to java_files and be included in this library. |
| 159 # |
| 160 # Example |
| 161 # android_library("foo_java") { |
| 162 # java_files = [ |
| 163 # "android/org/chromium/foo/Foo.java", |
| 164 # "android/org/chromium/foo/FooInterface.java", |
| 165 # "android/org/chromium/foo/FooService.java", |
| 166 # ] |
| 167 # srcjar_deps = [ |
| 168 # ":foo_generated_enum" |
| 169 # ] |
| 170 # } |
| 171 template("android_library") { |
| 172 template_name = target_name |
| 173 |
| 174 #TODO(cjhopman): resources |
| 175 |
| 176 assert(defined(invoker.java_files)) |
| 177 if (defined(invoker.android_library_deps)) { |
| 178 android_library_deps = invoker.android_library_deps |
| 179 } else { |
| 180 android_library_deps = [] |
| 181 } |
| 182 |
| 183 _android_java_library(target_name) { |
| 184 jar_path = get_target_gen_path(":${template_name}", ".jar") |
| 185 java_files = invoker.java_files |
| 186 library_deps = android_library_deps |
| 187 |
| 188 if (defined(invoker.srcjar_deps)) { |
| 189 srcjar_deps = invoker.srcjar_deps |
| 190 } |
| 191 } |
| 192 } |
| 193 |
| OLD | NEW |