blob: f4ea0a9195d38eaa940040c46ada3e6f1e8fbaa6 [file] [log] [blame]
[email protected]4d491712012-12-10 12:38:241# 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#
mkosibadfdc7fb22014-10-23 13:56:129# NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
10# rule instead.
11#
[email protected]4d491712012-12-10 12:38:2412# To use this, create a gyp target with the following form:
13# {
14# 'target_name': 'android_net_java_constants',
15# 'type': 'none',
16# 'sources': [
[email protected]4d491712012-12-10 12:38:2417# 'net/android/NetError.template',
18# ],
19# 'variables': {
[email protected]1b19c9a1e2013-03-02 16:39:0820# 'package_name': 'org/chromium/net',
mkosibadfdc7fb22014-10-23 13:56:1221# 'template_deps': ['base/net_error_list.h'],
[email protected]4d491712012-12-10 12:38:2422# },
[email protected]b50a8b52013-04-01 23:12:3323# 'includes': [ '../build/android/java_cpp_template.gypi' ],
[email protected]4d491712012-12-10 12:38:2424# },
25#
[email protected]2716d84e2013-01-19 04:05:4826# The 'sources' entry should only list template file. The template file
[email protected]4d491712012-12-10 12:38:2427# itself should use the 'ClassName.template' format, and will generate
newte0da0962014-10-10 21:48:5228# 'gen/templates/<target-name>/<package-name>/ClassName.java. The files which
29# template dependents on and typically included by the template should be listed
[email protected]2716d84e2013-01-19 04:05:4830# 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.
[email protected]4d491712012-12-10 12:38:2432#
33
34{
35 # Location where all generated Java sources will be placed.
36 'variables': {
jbudorickf667d3b3a2015-11-13 00:44:5837 'additional_gcc_preprocess_options': [],
[email protected]b50a8b52013-04-01 23:12:3338 'include_path%': '<(DEPTH)',
newte0da0962014-10-10 21:48:5239 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)/<(package_name)',
[email protected]4d491712012-12-10 12:38:2440 },
[email protected]4d491712012-12-10 12:38:2441 'direct_dependent_settings': {
42 'variables': {
[email protected]76e47fab2013-05-21 17:32:2743 # Ensure that the output directory is used in the class path
44 # when building targets that depend on this one.
[email protected]4d491712012-12-10 12:38:2445 'generated_src_dirs': [
46 '<(output_dir)/',
47 ],
[email protected]76e47fab2013-05-21 17:32:2748 # Ensure dependents are rebuilt when sources for this rule change.
49 'additional_input_paths': [
50 '<@(_sources)',
51 '<@(template_deps)',
52 ],
[email protected]4d491712012-12-10 12:38:2453 },
54 },
55 # Define a single rule that will be apply to each .template file
56 # listed in 'sources'.
57 'rules': [
58 {
59 'rule_name': 'generate_java_constants',
60 'extension': 'template',
[email protected]2716d84e2013-01-19 04:05:4861 # Set template_deps as additional dependencies.
[email protected]b50a8b52013-04-01 23:12:3362 'variables': {
63 'output_path': '<(output_dir)/<(RULE_INPUT_ROOT).java',
64 },
65 'inputs': [
[email protected]2f601632013-04-04 23:04:4066 '<(DEPTH)/build/android/gyp/util/build_utils.py',
67 '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
[email protected]b50a8b52013-04-01 23:12:3368 '<@(template_deps)'
69 ],
[email protected]4d491712012-12-10 12:38:2470 'outputs': [
[email protected]b50a8b52013-04-01 23:12:3371 '<(output_path)',
[email protected]4d491712012-12-10 12:38:2472 ],
73 'action': [
[email protected]2f601632013-04-04 23:04:4074 'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
[email protected]b50a8b52013-04-01 23:12:3375 '--include-path=<(include_path)',
76 '--output=<(output_path)',
77 '--template=<(RULE_INPUT_PATH)',
jbudorickf667d3b3a2015-11-13 00:44:5878 '<@(additional_gcc_preprocess_options)',
[email protected]4d491712012-12-10 12:38:2479 ],
80 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)',
81 }
82 ],
83}