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 16 matching lines...) Expand all Loading... | |
27 # additional_input_paths - These paths will be included in the 'inputs' list to | 27 # 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. | 28 # ensure that this target is rebuilt when one of these paths changes. |
29 # additional_src_dirs - Additional directories with .java files to be compiled | 29 # additional_src_dirs - Additional directories with .java files to be compiled |
30 # and included in the output of this target. | 30 # and included in the output of this target. |
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 # has_java_resources - Set to 1 if the java target contains an | |
38 # Android-compatible resources folder named res. If 1, R_package and | |
39 # R_package_path_ must also be set. | |
40 # R_package - The java package in which the R class (which maps resources to | |
41 # integer IDs) should be generated, e.g. org.chromium.content. | |
42 # R_package_path_ - Same as R_package, but replace each '.' with '/'. (The | |
cjhopman
2012/11/09 22:21:30
Instead of the trailing underscore, you could have
newt (away)
2012/11/09 23:05:35
I considered that... though it could break if some
| |
43 # trailing underscore prevents gyp's pathname relativization.) | |
37 | 44 |
38 { | 45 { |
39 'dependencies': [ | 46 'dependencies': [ |
40 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' | 47 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' |
41 ], | 48 ], |
42 # This all_dependent_settings is used for java targets only. This will add the | 49 # This all_dependent_settings is used for java targets only. This will add the |
43 # chromium_<(package_name) jar to the classpath of dependent java targets. | 50 # chromium_<(package_name) jar to the classpath of dependent java targets. |
44 'all_dependent_settings': { | 51 'all_dependent_settings': { |
45 'variables': { | 52 'variables': { |
46 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar '], | 53 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar '], |
47 }, | 54 }, |
48 }, | 55 }, |
49 'variables': { | 56 'variables': { |
50 'input_jars_paths': [], | 57 'input_jars_paths': [], |
51 'additional_src_dirs': [], | 58 'additional_src_dirs': [], |
52 'additional_input_paths': [], | 59 'additional_input_paths': [], |
53 'generated_src_dirs': [], | 60 'generated_src_dirs': [], |
61 'has_java_resources%': 0, | |
54 }, | 62 }, |
55 'actions': [ | 63 'actions': [ |
56 { | 64 { |
57 'action_name': 'ant_<(package_name)', | 65 'action_name': 'ant_<(package_name)', |
58 'message': 'Building <(package_name) java sources.', | 66 'message': 'Building <(package_name) java sources.', |
59 'inputs': [ | 67 'inputs': [ |
60 'android/ant/common.xml', | 68 'android/ant/common.xml', |
61 'android/ant/chromium-jars.xml', | 69 'android/ant/chromium-jars.xml', |
62 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 70 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
63 '>@(input_jars_paths)', | 71 '>@(input_jars_paths)', |
(...skipping 16 matching lines...) Expand all Loading... | |
80 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 88 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
81 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 89 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
82 '-DPACKAGE_NAME=<(package_name)', | 90 '-DPACKAGE_NAME=<(package_name)', |
83 | 91 |
84 '-Dbasedir=<(java_in_dir)', | 92 '-Dbasedir=<(java_in_dir)', |
85 '-buildfile', | 93 '-buildfile', |
86 '<(DEPTH)/build/android/ant/chromium-jars.xml' | 94 '<(DEPTH)/build/android/ant/chromium-jars.xml' |
87 ] | 95 ] |
88 }, | 96 }, |
89 ], | 97 ], |
98 'conditions': [ | |
99 ['has_java_resources == 1', { | |
100 'variables': { | |
101 'generated_src_dirs': ['<(INTERMEDIATE_DIR)/R'], | |
102 'additional_input_paths': ['<(INTERMEDIATE_DIR)/R/<(R_package_path_)/R.j ava'], | |
103 }, | |
104 'all_dependent_settings': { | |
105 'variables': { | |
106 'additional_res_dirs': ['<(java_in_dir)/res'], | |
107 'additional_res_packages': ['<(R_package)'], | |
108 }, | |
109 }, | |
110 'actions': [ | |
111 # Generate R.java for the library. This R.java contains non-final | |
112 # constants and is used only while compiling the library jar (e.g. | |
113 # chromium_content.jar). When building an apk, a new R.java file with | |
114 # the correct resource -> ID mappings will be generated by merging the | |
115 # resources from all libraries and the main apk project. | |
116 { | |
117 'action_name': 'generate_r_java', | |
118 'message': 'generating R.java for <(package_name)', | |
119 'inputs': [ | |
120 '<(android_sdk_tools)/aapt', | |
121 '<(android_sdk)/android.jar', | |
122 '<(java_in_dir)/AndroidManifest.xml', | |
123 '<!@(find <(java_in_dir)/res -type f)', | |
124 ], | |
125 'outputs': [ | |
126 '<(INTERMEDIATE_DIR)/R/<(R_package_path_)/R.java', | |
127 ], | |
128 'action': [ | |
129 '<(android_sdk_tools)/aapt', | |
130 'package', | |
131 '-m', | |
132 '--non-constant-id', | |
133 '-M', '<(java_in_dir)/AndroidManifest.xml', | |
134 '-S', '<(java_in_dir)/res', | |
135 '-I', '<(android_sdk)/android.jar', | |
136 '-J', '<(INTERMEDIATE_DIR)/R', | |
137 ], | |
138 }, | |
139 ], | |
140 }], | |
141 ], | |
90 } | 142 } |
OLD | NEW |