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', |
11 # 'type': 'none', | 11 # 'type': 'none', |
12 # 'variables': { | 12 # 'variables': { |
13 # 'package_name': 'my-package', | |
14 # 'java_in_dir': 'path/to/package/root', | 13 # 'java_in_dir': 'path/to/package/root', |
15 # }, | 14 # }, |
16 # 'includes': ['path/to/this/gypi/file'], | 15 # 'includes': ['path/to/this/gypi/file'], |
17 # } | 16 # } |
18 # | 17 # |
19 # The generated jar-file will be: | |
20 # <(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar | |
21 # Required variables: | 18 # Required variables: |
22 # package_name - Used to name the intermediate output directory and in the | |
23 # names of some output files. | |
24 # java_in_dir - The top-level java directory. The src should be in | 19 # java_in_dir - The top-level java directory. The src should be in |
25 # <java_in_dir>/src. | 20 # <java_in_dir>/src. |
26 # Optional/automatic variables: | 21 # Optional/automatic variables: |
27 # additional_input_paths - These paths will be included in the 'inputs' list to | 22 # additional_input_paths - These paths will be included in the 'inputs' list to |
28 # ensure that this target is rebuilt when one of these paths changes. | 23 # ensure that this target is rebuilt when one of these paths changes. |
29 # additional_src_dirs - Additional directories with .java files to be compiled | 24 # additional_src_dirs - Additional directories with .java files to be compiled |
30 # and included in the output of this target. | 25 # and included in the output of this target. |
31 # generated_src_dirs - Same as additional_src_dirs except used for .java files | 26 # 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 | 27 # 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 | 28 # target's dependencies. The .java files in these directories are not |
(...skipping 10 matching lines...) Expand all Loading... |
44 # R_package - The java package in which the R class (which maps resources to | 39 # 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. | 40 # integer IDs) should be generated, e.g. org.chromium.content. |
46 # R_package_relpath - Same as R_package, but replace each '.' with '/'. | 41 # R_package_relpath - Same as R_package, but replace each '.' with '/'. |
47 # java_strings_grd - The name of the grd file from which to generate localized | 42 # java_strings_grd - The name of the grd file from which to generate localized |
48 # strings.xml files, if any. | 43 # strings.xml files, if any. |
49 | 44 |
50 { | 45 { |
51 'dependencies': [ | 46 'dependencies': [ |
52 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' | 47 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' |
53 ], | 48 ], |
54 # This all_dependent_settings is used for java targets only. This will add the | |
55 # chromium_<(package_name) jar to the classpath of dependent java targets. | |
56 'all_dependent_settings': { | |
57 'variables': { | |
58 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
'], | |
59 }, | |
60 }, | |
61 'variables': { | 49 'variables': { |
62 'input_jars_paths': [], | 50 'input_jars_paths': [], |
63 'additional_src_dirs': [], | 51 'additional_src_dirs': [], |
64 'javac_includes': [], | 52 'javac_includes': [], |
| 53 'jar_name': '<(_target_name).jar', |
| 54 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
65 'additional_input_paths': ['>@(additional_R_files)'], | 55 'additional_input_paths': ['>@(additional_R_files)'], |
66 'generated_src_dirs': ['>@(generated_R_dirs)'], | 56 'generated_src_dirs': ['>@(generated_R_dirs)'], |
67 'generated_R_dirs': [], | 57 'generated_R_dirs': [], |
68 'additional_R_files': [], | 58 'additional_R_files': [], |
69 'has_java_resources%': 0, | 59 'has_java_resources%': 0, |
70 'java_strings_grd%': '', | 60 'java_strings_grd%': '', |
71 }, | 61 }, |
| 62 # This all_dependent_settings is used for java targets only. This will add the |
| 63 # jar path to the classpath of dependent java targets. |
| 64 'all_dependent_settings': { |
| 65 'variables': { |
| 66 'input_jars_paths': ['<(jar_path)'], |
| 67 }, |
| 68 }, |
72 'conditions': [ | 69 'conditions': [ |
73 ['has_java_resources == 1', { | 70 ['has_java_resources == 1', { |
74 'variables': { | 71 'variables': { |
75 'res_dir': '<(java_in_dir)/res', | 72 'res_dir': '<(java_in_dir)/res', |
76 'out_res_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)/res', | 73 'out_res_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)/res', |
77 'R_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)/java_R', | 74 'R_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)/java_R', |
78 'R_file': '<(R_dir)/<(R_package_relpath)/R.java', | 75 'R_file': '<(R_dir)/<(R_package_relpath)/R.java', |
79 'R_text_file': '<(R_dir)/R.txt', | 76 'R_text_file': '<(R_dir)/R.txt', |
80 'generated_src_dirs': ['<(R_dir)'], | 77 'generated_src_dirs': ['<(R_dir)'], |
81 'additional_input_paths': ['<(R_file)'], | 78 'additional_input_paths': ['<(R_file)'], |
82 # grit_grd_file is used by grit_action.gypi, included below. | 79 # grit_grd_file is used by grit_action.gypi, included below. |
83 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', | 80 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', |
84 }, | 81 }, |
85 'all_dependent_settings': { | 82 'all_dependent_settings': { |
86 'variables': { | 83 'variables': { |
87 # Dependent jars include this target's R.java file via | 84 # Dependent jars include this target's R.java file via |
(...skipping 20 matching lines...) Expand all Loading... |
108 }, | 105 }, |
109 'includes': ['../build/grit_action.gypi'], | 106 'includes': ['../build/grit_action.gypi'], |
110 }, | 107 }, |
111 ], | 108 ], |
112 }], | 109 }], |
113 ], | 110 ], |
114 'actions': [ | 111 'actions': [ |
115 # Generate R.java and crunch image resources. | 112 # Generate R.java and crunch image resources. |
116 { | 113 { |
117 'action_name': 'process_resources', | 114 'action_name': 'process_resources', |
118 'message': 'processing resources for <(package_name)', | 115 'message': 'processing resources for <(_target_name)', |
119 'conditions': [ | 116 'conditions': [ |
120 ['java_strings_grd != ""', { | 117 ['java_strings_grd != ""', { |
121 'inputs': [ | 118 'inputs': [ |
122 # TODO(newt): replace this with .../values/strings.xml once | 119 # TODO(newt): replace this with .../values/strings.xml once |
123 # the English strings.xml is generated as well? That would be | 120 # the English strings.xml is generated as well? That would be |
124 # simpler and faster and should be equivalent. | 121 # simpler and faster and should be equivalent. |
125 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_re
s_dir)" <(grit_grd_file))', | 122 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_re
s_dir)" <(grit_grd_file))', |
126 ], | 123 ], |
127 }], | 124 }], |
128 ], | 125 ], |
(...skipping 12 matching lines...) Expand all Loading... |
141 '--R-dir', '<(R_dir)', | 138 '--R-dir', '<(R_dir)', |
142 '--res-dir', '<(res_dir)', | 139 '--res-dir', '<(res_dir)', |
143 '--crunched-res-dir', '<(out_res_dir)', | 140 '--crunched-res-dir', '<(out_res_dir)', |
144 ], | 141 ], |
145 }, | 142 }, |
146 ], | 143 ], |
147 }], | 144 }], |
148 ], | 145 ], |
149 'actions': [ | 146 'actions': [ |
150 { | 147 { |
151 'action_name': 'ant_<(package_name)', | 148 'action_name': 'ant_<(_target_name)', |
152 'message': 'Building <(package_name) java sources.', | 149 'message': 'Building <(_target_name) java sources.', |
153 'inputs': [ | 150 'inputs': [ |
154 'android/ant/common.xml', | 151 'android/ant/common.xml', |
155 'android/ant/chromium-jars.xml', | 152 'android/ant/chromium-jars.xml', |
156 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 153 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
157 '>@(input_jars_paths)', | 154 '>@(input_jars_paths)', |
158 '>@(additional_input_paths)', | 155 '>@(additional_input_paths)', |
159 ], | 156 ], |
160 'outputs': [ | 157 'outputs': [ |
161 '<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar', | 158 '<(jar_path)', |
162 ], | 159 ], |
163 'action': [ | 160 'action': [ |
164 'ant', '-quiet', | 161 'ant', '-quiet', |
165 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | 162 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
166 '-DANDROID_SDK=<(android_sdk)', | 163 '-DANDROID_SDK=<(android_sdk)', |
167 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 164 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
168 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | 165 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', |
169 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 166 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
170 '-DANDROID_GDBSERVER=<(android_gdbserver)', | 167 '-DANDROID_GDBSERVER=<(android_gdbserver)', |
171 '-DPRODUCT_DIR=<(ant_build_out)', | 168 '-DPRODUCT_DIR=<(ant_build_out)', |
172 | 169 |
173 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | 170 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
174 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 171 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
175 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 172 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
176 '-DPACKAGE_NAME=<(package_name)', | 173 '-DJAR_NAME=<(jar_name)', |
| 174 '-DOUT_DIR=<(ant_build_out)/<(_target_name)', |
177 '-DJAVAC_INCLUDES=>(javac_includes)', | 175 '-DJAVAC_INCLUDES=>(javac_includes)', |
178 | 176 |
179 '-Dbasedir=<(java_in_dir)', | 177 '-Dbasedir=<(java_in_dir)', |
180 '-buildfile', | 178 '-buildfile', |
181 '<(DEPTH)/build/android/ant/chromium-jars.xml' | 179 '<(DEPTH)/build/android/ant/chromium-jars.xml' |
182 ] | 180 ] |
183 }, | 181 }, |
184 ], | 182 ], |
185 } | 183 } |
OLD | NEW |