Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 # This file is meant to be included into a target to provide a rule | |
| 6 # to generate Java source files from templates that are processed | |
| 7 # through the host C pre-processor. | |
|
Ryan Sleevi
2012/12/04 03:14:56
This should be in build/android, given that it dep
digit1
2012/12/04 12:20:34
I can move it there, but we already have plenty of
| |
| 8 # | |
| 9 # This assumes a GNU-compatible pre-processor installed as 'cpp'. | |
| 10 # Only tested on Linux. | |
| 11 # | |
| 12 # To use this, create a gyp target with the following form: | |
| 13 # { | |
| 14 # 'target_name': 'android_net_java_constants', | |
| 15 # 'type': 'none', | |
| 16 # 'sources': [ | |
| 17 # 'net/base/certificate_mime_type_list.h', | |
| 18 # 'net/android/NetError.template', | |
| 19 # ], | |
| 20 # 'variables': { | |
| 21 # 'package_name': 'org.chromium.net', | |
| 22 # }, | |
| 23 # 'includes': [ '../build/java_constants.gypi' ], | |
| 24 # }, | |
| 25 # | |
| 26 # The 'sources' entry should list all input files. The template file | |
| 27 # itself should use the 'ClassName.template' format, and will generate | |
| 28 # 'gen/templates/<package-name>/ClassName.java. Other source files | |
| 29 # are those typically included by the template. Any change to them | |
| 30 # will force a rebuild of the template, and hence of any source that | |
| 31 # depends on it. | |
| 32 # | |
| 33 | |
| 34 { | |
| 35 # Location where all generated Java sources will be placed. | |
| 36 'variables': { | |
| 37 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(package_name)' | |
| 38 }, | |
| 39 # Ensure that the output directory is used in the class path | |
| 40 # when building targets that depend on this one. | |
| 41 'direct_dependent_settings': { | |
| 42 'variables': { | |
| 43 'generated_src_dirs': [ | |
| 44 '<(output_dir)/', | |
| 45 ], | |
| 46 }, | |
| 47 }, | |
| 48 # Define a single rule that will be apply to each .template file | |
| 49 # listed in 'sources'. | |
| 50 'rules': [ | |
| 51 { | |
| 52 'rule_name': 'generate_java_constants', | |
| 53 'extension': 'template', | |
| 54 # Ensure the generated Java file is treated as input to the targets | |
| 55 # that depend on it. | |
| 56 'direct_dependent_settings': { | |
| 57 'variables': { | |
| 58 'additional_input_paths': [ | |
| 59 '<(output_dir)/<(RULE_INPUT_ROOT).java' | |
| 60 ], | |
| 61 }, | |
| 62 }, | |
| 63 'outputs': [ | |
| 64 '<(output_dir)/<(RULE_INPUT_ROOT).java' | |
| 65 ], | |
| 66 'action': [ | |
| 67 'cpp', # invoke host pre-processor. | |
| 68 '-x', 'c-header', # treat sources as C header files | |
| 69 '-P', # disable line markers, i.e. '#line 309' | |
| 70 '-I', '<(DEPTH)', # Add project top-level to include path | |
| 71 '-o', '<@(_outputs)', # Specify output file | |
| 72 '<(RULE_INPUT_PATH)', # Specify input file | |
| 73 ], | |
| 74 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)', | |
| 75 'process_outputs_as_sources': 1, | |
|
Ryan Sleevi
2012/12/04 03:14:56
Why 'process_outputs_as_sources', given that there
digit1
2012/12/04 12:20:34
The NetError.template generates an output named Ne
| |
| 76 } | |
| 77 ], | |
| 78 'hard_dependency': 1, | |
|
Ryan Sleevi
2012/12/04 03:14:56
hard_dependency is only applicable to static_libra
digit1
2012/12/04 12:20:34
It also came from jni_generator.gypi, I'll remove
| |
| 79 } | |
| OLD | NEW |