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.
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.
9 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
12 # To use this, create a gyp target with the following form:
14 # 'target_name': 'android_net_java_constants',
17 # 'net/android/NetError.template',
20 # 'package_name': 'org/chromium/net',
21 # 'template_deps': ['base/net_error_list.h'],
23 # 'includes': [ '../build/android/java_cpp_template.gypi' ],
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.
35 # Location where all generated Java sources will be placed.
37 'include_path%': '<(DEPTH)',
38 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)/<(package_name)',
40 'direct_dependent_settings': {
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': [
47 # Ensure dependents are rebuilt when sources for this rule change.
48 'additional_input_paths': [
54 # Define a single rule that will be apply to each .template file
55 # listed in 'sources'.
58 'rule_name': 'generate_java_constants',
59 'extension': 'template',
60 # Set template_deps as additional dependencies.
62 'output_path': '<(output_dir)/<(RULE_INPUT_ROOT).java',
65 '<(DEPTH)/build/android/gyp/util/build_utils.py',
66 '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
73 'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
74 '--include-path=<(include_path)',
75 '--output=<(output_path)',
76 '--template=<(RULE_INPUT_PATH)',
78 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)',