Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: build/config/android/rules.gni

Issue 264923007: Add java_cpp_template template (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/BUILD.gn ('K') | « build/config/android/internal_rules.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 hard_dep = true 61 hard_dep = true
60 } 62 }
61 } 63 }
64
65 # Declare a target for c-preprocessor-generated java files
66 #
67 # 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
69 # specified, it will be passed (with --I) to the pre-processor.
70 #
71 # 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
73 # library's final outputs.
74 #
75 # Variables
76 # 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
78 # file named FooBar.template, a java file will be created with name
79 # FooBar.java.
80 # source_prereqs: additional compile-time dependencies. Any files
81 # `#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.
83 #
84 # Example
85 # java_cpp_template("foo_generated_enum") {
86 # sources = [
87 # "android/java/templates/Foo.template",
88 # ]
89 # source_prereqs = [
90 # "android/java/templates/native_foo_header.h",
91 # ]
92 #
93 # package_name = "org/chromium/base/library_loader"
94 # include_path = "android/java/templates"
95 # }
96 template("java_cpp_template") {
97 assert(defined(invoker.sources))
98 package_name = invoker.package_name + ""
99
100 if (defined(invoker.include_path)) {
101 include_path = invoker.include_path + ""
102 } else {
103 include_path = "//"
104 }
105
106 base_gen_dir = "${root_gen_dir}/java_cpp_template/${target_name}/${package_nam e}"
brettw 2014/05/06 18:06:35 Can you put the string on the next line to make it
107 gen_dir = "${base_gen_dir}/${package_name}"
108 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java"
109 apply_gcc_outputs = process_file_template(
110 invoker.sources, gcc_template_output_pattern
111 )
brettw 2014/05/06 18:06:35 ) goes on prev line.
112
113 action_foreach("${target_name}__apply_gcc") {
114 script = "//build/android/gyp/gcc_preprocess.py"
115 if (defined(invoker.source_prereqs)) {
116 source_prereqs = invoker.source_prereqs + []
117 }
118
119 sources = invoker.sources
120 outputs = [
121 gcc_template_output_pattern
122 ]
123
124 args = [
125 "--include-path", rebase_path(include_path),
126 "--output", rebase_path(gen_dir) + "/{{source_name_part}}.java",
127 "--template={{source}}",
128 ]
129 }
130
131 srcjar_path = get_target_gen_path(":${target_name}", ".srcjar")
132 _zip("${target_name}__zip_srcjar") {
133 inputs = apply_gcc_outputs
134 output = srcjar_path
135 base_dir = base_gen_dir
136 }
137
138 group(target_name) {
139 deps = [
140 ":${target_name}__zip_srcjar"
141 ]
142 }
143 }
OLDNEW
« base/BUILD.gn ('K') | « build/config/android/internal_rules.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698