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

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

Issue 484603004: New C++ -> Java enum build rule + parser/generator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed aosp bot and added gn rule Created 6 years, 3 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
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("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 import("//build/config/android/internal_rules.gni") 6 import("//build/config/android/internal_rules.gni")
7 import("//tools/grit/grit_rule.gni") 7 import("//tools/grit/grit_rule.gni")
8 8
9 assert(is_android) 9 assert(is_android)
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 base_dir = base_gen_dir 255 base_dir = base_gen_dir
256 } 256 }
257 257
258 group(target_name) { 258 group(target_name) {
259 deps = [ 259 deps = [
260 ":${target_name}__zip_srcjar" 260 ":${target_name}__zip_srcjar"
261 ] 261 ]
262 } 262 }
263 } 263 }
264 264
265 # Declare a target for generating Java classes from C++ enums.
266 #
267 # This target generates Java files from C++ enums using a script.
268 #
269 # This target will create a single .srcjar. Adding this target to an
270 # android_library target's srcjar_deps will make the generated java files be
271 # included in that library's final outputs.
272 #
273 # Variables
274 # sources: list of files to be processed by the script. For each annotated
275 # enum contained in the sources files the script will generate a .java
276 # file with the same name as the name of the enum.
277 #
278 # outputs: list of outputs, relative to the target_gen_dir. These paths are
279 # verified at build time by the script. To get the list programatically run:
280 # python build/android/gyp/java_cpp_enum.py --output_dir=. \
281 # --print_output_only path/to/header/file.h
282 #
283 # Example
284 # java_cpp_enum("foo_generated_enum") {
285 # sources = [
286 # "src/native_foo_header.h",
287 # ]
288 # outputs = [
289 # "org/chromium/FooEnum.java",
290 # ]
291 # }
292 template("java_cpp_enum") {
293 assert(defined(invoker.sources))
294 assert(defined(invoker.outputs))
295
296 action("${target_name}__generate_enum") {
297 sources = rebase_path(invoker.sources, root_build_dir)
298 script = "//build/android/gyp/java_cpp_enum.py"
299 gen_dir = "${target_gen_dir}/${target_name}/enums"
300 outputs = []
301 foreach(output, invoker.outputs) {
302 outputs += [gen_dir + "/" + output]
mkosiba (inactive) 2014/09/03 16:27:23 I couldn't figure out how to make rebase_path work
brettw 2014/09/03 21:23:38 The thing that reads the outputs variable will int
mkosiba (inactive) 2014/09/04 11:31:22 That just changes the error to: The given file
brettw 2014/09/08 19:56:15 Oh, sorry. The checker doesn't know about relative
mkosiba (inactive) 2014/09/09 09:00:12 Ok, this seems to work although I could have sworn
303 }
304
305 args = [
306 "--output_dir", rebase_path(gen_dir, root_build_dir),
307 ]
308 foreach(output, invoker.outputs) {
309 args += ["--assert_file", rebase_path(output, root_build_dir, gen_dir)]
310 }
311 args += sources
312 }
313
314 generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
315 base_gen_dir = get_label_info(":${target_name}__generate_enum",
316 "target_gen_dir")
317
318 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
319 zip("${target_name}__zip_srcjar") {
320 inputs = generate_enum_outputs
321 output = srcjar_path
322 base_dir = base_gen_dir
323 }
324
325 group(target_name) {
326 deps = [
327 ":${target_name}__zip_srcjar"
328 ]
329 }
330 }
331
265 332
266 # Declare an Android resources target 333 # Declare an Android resources target
267 # 334 #
268 # This creates a resources zip file that will be used when building an Android 335 # This creates a resources zip file that will be used when building an Android
269 # library or apk and included into a final apk. 336 # library or apk and included into a final apk.
270 # 337 #
271 # To include these resources in a library/apk, this target should be listed in 338 # To include these resources in a library/apk, this target should be listed in
272 # the library's deps. A library/apk will also include any resources used by its 339 # the library's deps. A library/apk will also include any resources used by its
273 # own dependencies. 340 # own dependencies.
274 # 341 #
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java" 837 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java"
771 ] 838 ]
772 android_manifest = "//testing/android/java/AndroidManifest.xml" 839 android_manifest = "//testing/android/java/AndroidManifest.xml"
773 unittests_outputs = [ unittests_binary ] 840 unittests_outputs = [ unittests_binary ]
774 native_libs = [unittests_outputs[0]] 841 native_libs = [unittests_outputs[0]]
775 if (defined(invoker.deps)) { 842 if (defined(invoker.deps)) {
776 deps = invoker.deps 843 deps = invoker.deps
777 } 844 }
778 } 845 }
779 } 846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698