[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 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. |
| 8 | # |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 9 | # To use this, create a gyp target with the following form: |
| 10 | # { |
| 11 | # 'target_name': 'android_net_java_constants', |
| 12 | # 'type': 'none', |
| 13 | # 'sources': [ |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 14 | # 'net/android/NetError.template', |
| 15 | # ], |
| 16 | # 'variables': { |
[email protected] | 1b19c9a1e | 2013-03-02 16:39:08 | [diff] [blame] | 17 | # 'package_name': 'org/chromium/net', |
[email protected] | 2716d84e | 2013-01-19 04:05:48 | [diff] [blame] | 18 | # 'template_deps': ['net/base/certificate_mime_type_list.h'], |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 19 | # }, |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 20 | # 'includes': [ '../build/android/java_cpp_template.gypi' ], |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 21 | # }, |
| 22 | # |
[email protected] | 2716d84e | 2013-01-19 04:05:48 | [diff] [blame] | 23 | # The 'sources' entry should only list template file. The template file |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 24 | # itself should use the 'ClassName.template' format, and will generate |
[email protected] | 2716d84e | 2013-01-19 04:05:48 | [diff] [blame] | 25 | # 'gen/templates/<package-name>/ClassName.java. The files which template |
| 26 | # dependents on and typically included by the template should be listed |
| 27 | # in template_deps variables. Any change to them will force a rebuild of |
| 28 | # the template, and hence of any source that depends on it. |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 29 | # |
| 30 | |
| 31 | { |
| 32 | # Location where all generated Java sources will be placed. |
| 33 | 'variables': { |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 34 | 'include_path%': '<(DEPTH)', |
| 35 | 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(package_name)', |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 36 | }, |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 37 | 'direct_dependent_settings': { |
| 38 | 'variables': { |
[email protected] | 76e47fab | 2013-05-21 17:32:27 | [diff] [blame] | 39 | # Ensure that the output directory is used in the class path |
| 40 | # when building targets that depend on this one. |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 41 | 'generated_src_dirs': [ |
| 42 | '<(output_dir)/', |
| 43 | ], |
[email protected] | 76e47fab | 2013-05-21 17:32:27 | [diff] [blame] | 44 | # Ensure dependents are rebuilt when sources for this rule change. |
| 45 | 'additional_input_paths': [ |
| 46 | '<@(_sources)', |
| 47 | '<@(template_deps)', |
| 48 | ], |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 49 | }, |
| 50 | }, |
| 51 | # Define a single rule that will be apply to each .template file |
| 52 | # listed in 'sources'. |
| 53 | 'rules': [ |
| 54 | { |
| 55 | 'rule_name': 'generate_java_constants', |
| 56 | 'extension': 'template', |
[email protected] | 2716d84e | 2013-01-19 04:05:48 | [diff] [blame] | 57 | # Set template_deps as additional dependencies. |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 58 | 'variables': { |
| 59 | 'output_path': '<(output_dir)/<(RULE_INPUT_ROOT).java', |
| 60 | }, |
| 61 | 'inputs': [ |
[email protected] | 2f60163 | 2013-04-04 23:04:40 | [diff] [blame] | 62 | '<(DEPTH)/build/android/gyp/util/build_utils.py', |
| 63 | '<(DEPTH)/build/android/gyp/gcc_preprocess.py', |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 64 | '<@(template_deps)' |
| 65 | ], |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 66 | 'outputs': [ |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 67 | '<(output_path)', |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 68 | ], |
| 69 | 'action': [ |
[email protected] | 2f60163 | 2013-04-04 23:04:40 | [diff] [blame] | 70 | 'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py', |
[email protected] | b50a8b5 | 2013-04-01 23:12:33 | [diff] [blame] | 71 | '--include-path=<(include_path)', |
| 72 | '--output=<(output_path)', |
| 73 | '--template=<(RULE_INPUT_PATH)', |
[email protected] | 4d49171 | 2012-12-10 12:38:24 | [diff] [blame] | 74 | ], |
| 75 | 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)', |
| 76 | } |
| 77 | ], |
| 78 | } |