Temporary allocation of 20Mb before and after call to ServiceProcessControl::GetHisto...
[chromium-blink-merge.git] / build / java.gypi
blobbf6f56c8ed9542d5d73a44de7b801a8740446015
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 build Java in a consistent manner.
8 # To use this, create a gyp target with the following form:
9 # {
10 #   'target_name': 'my-package_java',
11 #   'type': 'none',
12 #   'variables': {
13 #     'java_in_dir': 'path/to/package/root',
14 #   },
15 #   'includes': ['path/to/this/gypi/file'],
16 # }
18 # Required variables:
19 #  java_in_dir - The top-level java directory. The src should be in
20 #    <java_in_dir>/src.
21 # Optional/automatic variables:
22 #  additional_input_paths - These paths will be included in the 'inputs' list to
23 #    ensure that this target is rebuilt when one of these paths changes.
24 #  additional_src_dirs - Additional directories with .java files to be compiled
25 #    and included in the output of this target.
26 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
27 #    that are generated at build time. This should be set automatically by a
28 #    target's dependencies. The .java files in these directories are not
29 #    included in the 'inputs' list (unlike additional_src_dirs).
30 #  input_jars_paths - The path to jars to be included in the classpath. This
31 #    should be filled automatically by depending on the appropriate targets.
32 #  javac_includes - A list of specific files to include. This is by default
33 #    empty, which leads to inclusion of all files specified. May include
34 #    wildcard, and supports '**/' for recursive path wildcards, ie.:
35 #    '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'.
36 #  has_java_resources - Set to 1 if the java target contains an
37 #    Android-compatible resources folder named res.  If 1, R_package and
38 #    R_package_relpath must also be set.
39 #  R_package - The java package in which the R class (which maps resources to
40 #    integer IDs) should be generated, e.g. org.chromium.content.
41 #  R_package_relpath - Same as R_package, but replace each '.' with '/'.
42 #  res_extra_dirs - A list of extra directories containing Android resources.
43 #    These directories may be generated at build time.
44 #  res_extra_files - A list of the files in res_extra_dirs.
45 #  never_lint - Set to 1 to not run lint on this target.
48   'dependencies': [
49     '<(DEPTH)/build/android/setup.gyp:build_output_dirs'
50   ],
51   'variables': {
52     'android_jar': '<(android_sdk)/android.jar',
53     'input_jars_paths': [ '<(android_jar)' ],
54     'additional_src_dirs': [],
55     'javac_includes': [],
56     'jar_name': '<(_target_name).jar',
57     'jar_dir': '<(PRODUCT_DIR)/lib.java',
58     'jar_path': '<(intermediate_dir)/<(jar_name)',
59     'jar_final_path': '<(jar_dir)/<(jar_name)',
60     'jar_excluded_classes': [ '*/R.class', '*/R##*.class' ],
61     'instr_stamp': '<(intermediate_dir)/instr.stamp',
62     'additional_input_paths': [],
63     'dex_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).dex.jar',
64     'generated_src_dirs': ['>@(generated_R_dirs)'],
65     'generated_R_dirs': [],
66     'has_java_resources%': 0,
67     'res_extra_dirs': [],
68     'res_extra_files': [],
69     'res_v14_verify_only%': 0,
70     'resource_input_paths': ['>@(res_extra_files)'],
71     'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)',
72     'compile_stamp': '<(intermediate_dir)/compile.stamp',
73     'lint_stamp': '<(intermediate_dir)/lint.stamp',
74     'lint_result': '<(intermediate_dir)/lint_result.xml',
75     'lint_config': '<(intermediate_dir)/lint_config.xml',
76     'never_lint%': 0,
77     'proguard_config%': '',
78     'proguard_preprocess%': '0',
79     'variables': {
80       'variables': {
81         'proguard_preprocess%': 0,
82         'emma_never_instrument%': 0,
83       },
84       'conditions': [
85         ['proguard_preprocess == 1', {
86           'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar'
87         }, {
88           'javac_jar_path': '<(jar_path)'
89         }],
90         ['chromium_code != 0 and emma_coverage != 0 and emma_never_instrument == 0', {
91           'emma_instrument': 1,
92         }, {
93           'emma_instrument': 0,
94         }],
95       ],
96     },
97     'emma_instrument': '<(emma_instrument)',
98     'javac_jar_path': '<(javac_jar_path)',
99   },
100   # This all_dependent_settings is used for java targets only. This will add the
101   # jar path to the classpath of dependent java targets.
102   'all_dependent_settings': {
103     'variables': {
104       'input_jars_paths': ['<(jar_final_path)'],
105       'library_dexed_jars_paths': ['<(dex_path)'],
106     },
107   },
108   'conditions': [
109     ['has_java_resources == 1', {
110       'variables': {
111         'res_dir': '<(java_in_dir)/res',
112         'res_input_dirs': ['<(res_dir)', '<@(res_extra_dirs)'],
113         'resource_input_paths': ['<!@(find <(res_dir) -type f)'],
115         'R_dir': '<(intermediate_dir)/java_R',
116         'R_text_file': '<(R_dir)/R.txt',
118         'generated_src_dirs': ['<(R_dir)'],
119         'additional_input_paths': ['<(resource_zip_path)', ],
121         'dependencies_res_zip_paths': [],
122         'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
123       },
124       'all_dependent_settings': {
125         'variables': {
126           # Dependent libraries include this target's R.java file via
127           # generated_R_dirs.
128           'generated_R_dirs': ['<(R_dir)'],
130           # Dependent libraries and apks include this target's resources via
131           # dependencies_res_zip_paths.
132           'additional_input_paths': ['<(resource_zip_path)'],
133           'dependencies_res_zip_paths': ['<(resource_zip_path)'],
135           # additional_res_packages and additional_R_text_files are used to
136           # create this packages R.java files when building the APK.
137           'additional_res_packages': ['<(R_package)'],
138           'additional_R_text_files': ['<(R_text_file)'],
139         },
140       },
141       'actions': [
142         # Generate R.java and crunch image resources.
143         {
144           'action_name': 'process_resources',
145           'message': 'processing resources for <(_target_name)',
146           'variables': {
147             'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
148             # Write the inputs list to a file, so that its mtime is updated when
149             # the list of inputs changes.
150             'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths))',
151             'process_resources_options': [],
152             'conditions': [
153               ['res_v14_verify_only == 1', {
154                 'process_resources_options': ['--v14-verify-only']
155               }],
156             ],
157           },
158           'inputs': [
159             '<(DEPTH)/build/android/gyp/util/build_utils.py',
160             '<(DEPTH)/build/android/gyp/process_resources.py',
161             '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
162             '>@(resource_input_paths)',
163             '>@(dependencies_res_zip_paths)',
164             '>(inputs_list_file)',
165           ],
166           'outputs': [
167             '<(resource_zip_path)',
168           ],
169           'action': [
170             'python', '<(DEPTH)/build/android/gyp/process_resources.py',
171             '--android-sdk', '<(android_sdk)',
172             '--android-sdk-tools', '<(android_sdk_tools)',
173             '--non-constant-id',
175             '--android-manifest', '<(android_manifest)',
176             '--custom-package', '<(R_package)',
178             '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
179             '--resource-dirs', '<(res_input_dirs)',
181             '--R-dir', '<(R_dir)',
182             '--resource-zip-out', '<(resource_zip_path)',
184             '<@(process_resources_options)',
185           ],
186         },
187       ],
188     }],
189     ['proguard_preprocess == 1', {
190       'actions': [
191         {
192           'action_name': 'proguard_<(_target_name)',
193           'message': 'Proguard preprocessing <(_target_name) jar',
194           'inputs': [
195             '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
196             '<(DEPTH)/build/android/gyp/util/build_utils.py',
197             '<(DEPTH)/build/android/gyp/proguard.py',
198             '<(javac_jar_path)',
199             '<(proguard_config)',
200           ],
201           'outputs': [
202             '<(jar_path)',
203           ],
204           'action': [
205             'python', '<(DEPTH)/build/android/gyp/proguard.py',
206             '--proguard-path=<(android_sdk_root)/tools/proguard/lib/proguard.jar',
207             '--input-path=<(javac_jar_path)',
208             '--output-path=<(jar_path)',
209             '--proguard-config=<(proguard_config)',
210             '--classpath=<(android_sdk_jar) >(input_jars_paths)',
211           ]
212         },
213       ],
214     }],
215   ],
216   'actions': [
217     {
218       'action_name': 'javac_<(_target_name)',
219       'message': 'Compiling <(_target_name) java sources',
220       'variables': {
221         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java")'],
222       },
223       'inputs': [
224         '<(DEPTH)/build/android/gyp/util/build_utils.py',
225         '<(DEPTH)/build/android/gyp/javac.py',
226         '>@(java_sources)',
227         '>@(input_jars_paths)',
228         '>@(additional_input_paths)',
229       ],
230       'outputs': [
231         '<(compile_stamp)',
232         '<(javac_jar_path)',
233       ],
234       'action': [
235         'python', '<(DEPTH)/build/android/gyp/javac.py',
236         '--classpath=>(input_jars_paths)',
237         '--src-gendirs=>(generated_src_dirs)',
238         '--javac-includes=<(javac_includes)',
239         '--chromium-code=<(chromium_code)',
240         '--jar-path=<(javac_jar_path)',
241         '--jar-excluded-classes=<(jar_excluded_classes)',
242         '--stamp=<(compile_stamp)',
243         '>@(java_sources)',
244       ]
245     },
246     {
247       'action_name': 'instr_jar_<(_target_name)',
248       'message': 'Instrumenting <(_target_name) jar',
249       'variables': {
250         'input_path': '<(jar_path)',
251         'output_path': '<(jar_final_path)',
252         'stamp_path': '<(instr_stamp)',
253         'instr_type': 'jar',
254       },
255       'outputs': [
256         '<(jar_final_path)',
257       ],
258       'inputs': [
259         '<(jar_path)',
260       ],
261       'includes': [ 'android/instr_action.gypi' ],
262     },
263     {
264       'variables': {
265         'src_dirs': [
266           '<(java_in_dir)/src',
267           '>@(additional_src_dirs)',
268         ],
269         'stamp_path': '<(lint_stamp)',
270         'result_path': '<(lint_result)',
271         'config_path': '<(lint_config)',
272         'lint_jar_path': '<(jar_final_path)',
273       },
274       'inputs': [
275         '<(jar_final_path)',
276         '<(compile_stamp)',
277       ],
278       'outputs': [
279         '<(lint_stamp)',
280       ],
281       'includes': [ 'android/lint_action.gypi' ],
282     },
283     {
284       'action_name': 'jar_toc_<(_target_name)',
285       'message': 'Creating <(_target_name) jar.TOC',
286       'inputs': [
287         '<(DEPTH)/build/android/gyp/util/build_utils.py',
288         '<(DEPTH)/build/android/gyp/util/md5_check.py',
289         '<(DEPTH)/build/android/gyp/jar_toc.py',
290         '<(jar_final_path)',
291       ],
292       'outputs': [
293         '<(jar_final_path).TOC',
294       ],
295       'action': [
296         'python', '<(DEPTH)/build/android/gyp/jar_toc.py',
297         '--jar-path=<(jar_final_path)',
298         '--toc-path=<(jar_final_path).TOC',
299       ]
300     },
301     {
302       'action_name': 'dex_<(_target_name)',
303       'variables': {
304         'conditions': [
305           ['emma_instrument != 0', {
306             'dex_no_locals': 1,
307           }],
308         ],
309         'dex_input_paths': [ '<(jar_final_path)' ],
310         'output_path': '<(dex_path)',
311       },
312       'includes': [ 'android/dex_action.gypi' ],
313     },
314   ],