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. | |
8 # | |
9 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum | |
10 # rule instead. | |
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/android/NetError.template', | |
18 # ], | |
19 # 'variables': { | |
20 # 'package_name': 'org/chromium/net', | |
21 # 'template_deps': ['base/net_error_list.h'], | |
22 # }, | |
23 # 'includes': [ '../build/android/java_cpp_template.gypi' ], | |
24 # }, | |
25 # | |
26 # The 'sources' entry should only list template file. The template file | |
27 # itself should use the 'ClassName.template' format, and will generate | |
28 # 'gen/templates/<target-name>/<package-name>/ClassName.java. The files which | |
29 # template dependents on and typically included by the template should be listed | |
30 # in template_deps variables. Any change to them will force a rebuild of | |
31 # the template, and hence of any source that depends on it. | |
32 # | |
33 | |
34 { | |
35 # Location where all generated Java sources will be placed. | |
36 'variables': { | |
37 'include_path%': '<(DEPTH)', | |
38 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)/<(packag
e_name)', | |
39 }, | |
40 'direct_dependent_settings': { | |
41 'variables': { | |
42 # Ensure that the output directory is used in the class path | |
43 # when building targets that depend on this one. | |
44 'generated_src_dirs': [ | |
45 '<(output_dir)/', | |
46 ], | |
47 # Ensure dependents are rebuilt when sources for this rule change. | |
48 'additional_input_paths': [ | |
49 '<@(_sources)', | |
50 '<@(template_deps)', | |
51 ], | |
52 }, | |
53 }, | |
54 # Define a single rule that will be apply to each .template file | |
55 # listed in 'sources'. | |
56 'rules': [ | |
57 { | |
58 'rule_name': 'generate_java_constants', | |
59 'extension': 'template', | |
60 # Set template_deps as additional dependencies. | |
61 'variables': { | |
62 'output_path': '<(output_dir)/<(RULE_INPUT_ROOT).java', | |
63 }, | |
64 'inputs': [ | |
65 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
66 '<(DEPTH)/build/android/gyp/gcc_preprocess.py', | |
67 '<@(template_deps)' | |
68 ], | |
69 'outputs': [ | |
70 '<(output_path)', | |
71 ], | |
72 'action': [ | |
73 'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py', | |
74 '--include-path=<(include_path)', | |
75 '--output=<(output_path)', | |
76 '--template=<(RULE_INPUT_PATH)', | |
77 ], | |
78 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)', | |
79 } | |
80 ], | |
81 } | |
OLD | NEW |