| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # This file is meant to be included into a target to provide a rule | 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 | 6 # to generate Java source files from templates that are processed |
| 7 # through the host C pre-processor. | 7 # through the host C pre-processor. |
| 8 # | 8 # |
| 9 # To use this, create a gyp target with the following form: | 9 # To use this, create a gyp target with the following form: |
| 10 # { | 10 # { |
| 11 # 'target_name': 'android_net_java_constants', | 11 # 'target_name': 'android_net_java_constants', |
| 12 # 'type': 'none', | 12 # 'type': 'none', |
| 13 # 'sources': [ | 13 # 'sources': [ |
| 14 # 'net/android/NetError.template', | 14 # 'net/android/NetError.template', |
| 15 # ], | 15 # ], |
| 16 # 'variables': { | 16 # 'variables': { |
| 17 # 'package_name': 'org/chromium/net', | 17 # 'package_name': 'org/chromium/net', |
| 18 # 'template_deps': ['net/base/certificate_mime_type_list.h'], | 18 # 'template_deps': ['net/base/certificate_mime_type_list.h'], |
| 19 # }, | 19 # }, |
| 20 # 'includes': [ '../build/android/java_constants.gypi' ], | 20 # 'includes': [ '../build/android/java_cpp_template.gypi' ], |
| 21 # }, | 21 # }, |
| 22 # | 22 # |
| 23 # The 'sources' entry should only list template file. The template file | 23 # The 'sources' entry should only list template file. The template file |
| 24 # itself should use the 'ClassName.template' format, and will generate | 24 # itself should use the 'ClassName.template' format, and will generate |
| 25 # 'gen/templates/<package-name>/ClassName.java. The files which template | 25 # 'gen/templates/<package-name>/ClassName.java. The files which template |
| 26 # dependents on and typically included by the template should be listed | 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 | 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. | 28 # the template, and hence of any source that depends on it. |
| 29 # | 29 # |
| 30 | 30 |
| 31 { | 31 { |
| 32 # Location where all generated Java sources will be placed. | 32 # Location where all generated Java sources will be placed. |
| 33 'variables': { | 33 'variables': { |
| 34 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(package_name)' | 34 'include_path%': '<(DEPTH)', |
| 35 'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(package_name)', |
| 35 }, | 36 }, |
| 36 # Ensure that the output directory is used in the class path | 37 # Ensure that the output directory is used in the class path |
| 37 # when building targets that depend on this one. | 38 # when building targets that depend on this one. |
| 38 'direct_dependent_settings': { | 39 'direct_dependent_settings': { |
| 39 'variables': { | 40 'variables': { |
| 40 'generated_src_dirs': [ | 41 'generated_src_dirs': [ |
| 41 '<(output_dir)/', | 42 '<(output_dir)/', |
| 42 ], | 43 ], |
| 43 }, | 44 }, |
| 44 }, | 45 }, |
| 45 # Define a single rule that will be apply to each .template file | 46 # Define a single rule that will be apply to each .template file |
| 46 # listed in 'sources'. | 47 # listed in 'sources'. |
| 47 'rules': [ | 48 'rules': [ |
| 48 { | 49 { |
| 49 'rule_name': 'generate_java_constants', | 50 'rule_name': 'generate_java_constants', |
| 50 'extension': 'template', | 51 'extension': 'template', |
| 51 # Set template_deps as additional dependencies. | 52 # Set template_deps as additional dependencies. |
| 52 'inputs': ['<@(template_deps)'], | 53 'variables': { |
| 54 'output_path': '<(output_dir)/<(RULE_INPUT_ROOT).java', |
| 55 }, |
| 56 'inputs': [ |
| 57 '<(DEPTH)/build/android/pylib/build_utils.py', |
| 58 '<(DEPTH)/build/android/gcc_preprocess.py', |
| 59 '<@(template_deps)' |
| 60 ], |
| 53 'outputs': [ | 61 'outputs': [ |
| 54 '<(output_dir)/<(RULE_INPUT_ROOT).java' | 62 '<(output_path)', |
| 55 ], | 63 ], |
| 56 'action': [ | 64 'action': [ |
| 57 'gcc', # invoke host gcc. | 65 'python', '<(DEPTH)/build/android/gcc_preprocess.py', |
| 58 '-E', # stop after preprocessing. | 66 '--include-path=<(include_path)', |
| 59 '-D', 'ANDROID', # Specify ANDROID define for pre-processor. | 67 '--output=<(output_path)', |
| 60 '-x', 'c-header', # treat sources as C header files | 68 '--template=<(RULE_INPUT_PATH)', |
| 61 '-P', # disable line markers, i.e. '#line 309' | |
| 62 '-I', '<(DEPTH)', # Add project top-level to include path | |
| 63 '-o', '<@(_outputs)', # Specify output file | |
| 64 '<(RULE_INPUT_PATH)', # Specify input file | |
| 65 ], | 69 ], |
| 66 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)', | 70 'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)', |
| 67 } | 71 } |
| 68 ], | 72 ], |
| 69 } | 73 } |
| OLD | NEW |