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 build Java in a consistent manner. | 6 # to build Java in a consistent manner. |
7 # | 7 # |
8 # To use this, create a gyp target with the following form: | 8 # To use this, create a gyp target with the following form: |
9 # { | 9 # { |
10 # 'target_name': 'my-package_java', | 10 # 'target_name': 'my-package_java', |
(...skipping 20 matching lines...) Expand all Loading... |
31 # generated_src_dirs - Same as additional_src_dirs except used for .java files | 31 # generated_src_dirs - Same as additional_src_dirs except used for .java files |
32 # that are generated at build time. This should be set automatically by a | 32 # that are generated at build time. This should be set automatically by a |
33 # target's dependencies. The .java files in these directories are not | 33 # target's dependencies. The .java files in these directories are not |
34 # included in the 'inputs' list (unlike additional_src_dirs). | 34 # included in the 'inputs' list (unlike additional_src_dirs). |
35 # input_jars_paths - The path to jars to be included in the classpath. This | 35 # input_jars_paths - The path to jars to be included in the classpath. This |
36 # should be filled automatically by depending on the appropriate targets. | 36 # should be filled automatically by depending on the appropriate targets. |
37 # javac_includes - A list of specific files to include. This is by default | 37 # javac_includes - A list of specific files to include. This is by default |
38 # empty, which leads to inclusion of all files specified. May include | 38 # empty, which leads to inclusion of all files specified. May include |
39 # wildcard, and supports '**/' for recursive path wildcards, ie.: | 39 # wildcard, and supports '**/' for recursive path wildcards, ie.: |
40 # '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'. | 40 # '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'. |
| 41 # has_java_resources - Set to 1 if the java target contains an |
| 42 # Android-compatible resources folder named res. If 1, R_package and |
| 43 # R_package_relpath must also be set. |
| 44 # R_package - The java package in which the R class (which maps resources to |
| 45 # integer IDs) should be generated, e.g. org.chromium.content. |
| 46 # R_package_relpath - Same as R_package, but replace each '.' with '/'. |
41 | 47 |
42 { | 48 { |
43 'dependencies': [ | 49 'dependencies': [ |
44 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' | 50 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' |
45 ], | 51 ], |
46 # This all_dependent_settings is used for java targets only. This will add the | 52 # This all_dependent_settings is used for java targets only. This will add the |
47 # chromium_<(package_name) jar to the classpath of dependent java targets. | 53 # chromium_<(package_name) jar to the classpath of dependent java targets. |
48 'all_dependent_settings': { | 54 'all_dependent_settings': { |
49 'variables': { | 55 'variables': { |
50 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
'], | 56 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
'], |
51 }, | 57 }, |
52 }, | 58 }, |
53 'variables': { | 59 'variables': { |
54 'input_jars_paths': [], | 60 'input_jars_paths': [], |
55 'additional_src_dirs': [], | 61 'additional_src_dirs': [], |
56 'additional_input_paths': [], | |
57 'generated_src_dirs': [], | |
58 'javac_includes': [], | 62 'javac_includes': [], |
| 63 'additional_input_paths': ['>@(additional_R_files)'], |
| 64 'generated_src_dirs': ['>@(generated_R_dirs)'], |
| 65 'generated_R_dirs': [], |
| 66 'additional_R_files': [], |
| 67 'has_java_resources%': 0, |
59 }, | 68 }, |
| 69 'conditions': [ |
| 70 ['has_java_resources == 1', { |
| 71 'variables': { |
| 72 'R_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)/java_R', |
| 73 'R_file': '<(R_dir)/<(R_package_relpath)/R.java', |
| 74 'generated_src_dirs': ['<(R_dir)'], |
| 75 'additional_input_paths': ['<(R_file)'], |
| 76 }, |
| 77 'all_dependent_settings': { |
| 78 'variables': { |
| 79 # Dependent jars include this target's R.java file via |
| 80 # generated_R_dirs and additional_R_files. |
| 81 'generated_R_dirs': ['<(R_dir)'], |
| 82 'additional_R_files': ['<(R_file)'], |
| 83 |
| 84 # Dependent APKs include this target's resources via |
| 85 # additional_res_dirs and additional_res_packages. |
| 86 'additional_res_dirs': ['<(java_in_dir)/res'], |
| 87 'additional_res_packages': ['<(R_package)'], |
| 88 }, |
| 89 }, |
| 90 'actions': [ |
| 91 # Generate R.java for the library. This R.java contains non-final |
| 92 # constants and is used only while compiling the library jar (e.g. |
| 93 # chromium_content.jar). When building an apk, a new R.java file with |
| 94 # the correct resource -> ID mappings will be generated by merging the |
| 95 # resources from all libraries and the main apk project. |
| 96 { |
| 97 'action_name': 'generate_r_java', |
| 98 'message': 'generating R.java for <(package_name)', |
| 99 'inputs': [ |
| 100 '<(android_sdk_tools)/aapt', |
| 101 '<(android_sdk)/android.jar', |
| 102 '<(DEPTH)/build/android/AndroidManifest.xml', |
| 103 '<!@(find <(java_in_dir)/res -type f)', |
| 104 ], |
| 105 'outputs': [ |
| 106 '<(R_file)', |
| 107 ], |
| 108 'action': [ |
| 109 '<(android_sdk_tools)/aapt', |
| 110 'package', |
| 111 '-m', |
| 112 '--non-constant-id', |
| 113 '--custom-package', '<(R_package)', |
| 114 '-M', '<(DEPTH)/build/android/AndroidManifest.xml', |
| 115 '-S', '<(java_in_dir)/res', |
| 116 '-I', '<(android_sdk)/android.jar', |
| 117 '-J', '<(R_dir)', |
| 118 ], |
| 119 }, |
| 120 ], |
| 121 }], |
| 122 ], |
60 'actions': [ | 123 'actions': [ |
61 { | 124 { |
62 'action_name': 'ant_<(package_name)', | 125 'action_name': 'ant_<(package_name)', |
63 'message': 'Building <(package_name) java sources.', | 126 'message': 'Building <(package_name) java sources.', |
64 'inputs': [ | 127 'inputs': [ |
65 'android/ant/common.xml', | 128 'android/ant/common.xml', |
66 'android/ant/chromium-jars.xml', | 129 'android/ant/chromium-jars.xml', |
67 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 130 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
68 '>@(input_jars_paths)', | 131 '>@(input_jars_paths)', |
69 '>@(additional_input_paths)', | 132 '>@(additional_input_paths)', |
(...skipping 17 matching lines...) Expand all Loading... |
87 '-DPACKAGE_NAME=<(package_name)', | 150 '-DPACKAGE_NAME=<(package_name)', |
88 '-DJAVAC_INCLUDES=>(javac_includes)', | 151 '-DJAVAC_INCLUDES=>(javac_includes)', |
89 | 152 |
90 '-Dbasedir=<(java_in_dir)', | 153 '-Dbasedir=<(java_in_dir)', |
91 '-buildfile', | 154 '-buildfile', |
92 '<(DEPTH)/build/android/ant/chromium-jars.xml' | 155 '<(DEPTH)/build/android/ant/chromium-jars.xml' |
93 ] | 156 ] |
94 }, | 157 }, |
95 ], | 158 ], |
96 } | 159 } |
OLD | NEW |