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 23 matching lines...) Expand all Loading... |
34 # wildcard, and supports '**/' for recursive path wildcards, ie.: | 34 # wildcard, and supports '**/' for recursive path wildcards, ie.: |
35 # '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'. | 35 # '**/MyFileRegardlessOfDirectory.java', '**/IncludedPrefix*.java'. |
36 # has_java_resources - Set to 1 if the java target contains an | 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 | 37 # Android-compatible resources folder named res. If 1, R_package and |
38 # R_package_relpath must also be set. | 38 # R_package_relpath must also be set. |
39 # 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 |
40 # integer IDs) should be generated, e.g. org.chromium.content. | 40 # integer IDs) should be generated, e.g. org.chromium.content. |
41 # R_package_relpath - Same as R_package, but replace each '.' with '/'. | 41 # R_package_relpath - Same as R_package, but replace each '.' with '/'. |
42 # 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 |
43 # strings.xml files, if any. | 43 # strings.xml files, if any. |
| 44 # res_extra_dirs - A list of extra directories containing Android resources. |
| 45 # These directories may be generated at build time. |
| 46 # res_extra_files - A list of the files in res_extra_dirs. |
44 | 47 |
45 { | 48 { |
46 'dependencies': [ | 49 'dependencies': [ |
47 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' | 50 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' |
48 ], | 51 ], |
49 'variables': { | 52 'variables': { |
50 'android_jar': '<(android_sdk)/android.jar', | 53 'android_jar': '<(android_sdk)/android.jar', |
51 'input_jars_paths': [ '<(android_jar)' ], | 54 'input_jars_paths': [ '<(android_jar)' ], |
52 'additional_src_dirs': [], | 55 'additional_src_dirs': [], |
53 'javac_includes': [], | 56 'javac_includes': [], |
54 'jar_name': '<(_target_name).jar', | 57 'jar_name': '<(_target_name).jar', |
55 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 58 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
56 'excluded_classes': [ '*/R.class', '*/R##*.class' ], | 59 'excluded_classes': [ '*/R.class', '*/R##*.class' ], |
57 'additional_input_paths': [], | 60 'additional_input_paths': [], |
58 'generated_src_dirs': ['>@(generated_R_dirs)'], | 61 'generated_src_dirs': ['>@(generated_R_dirs)'], |
59 'generated_R_dirs': [], | 62 'generated_R_dirs': [], |
60 'has_java_resources%': 0, | 63 'has_java_resources%': 0, |
61 'java_strings_grd%': '', | 64 'java_strings_grd%': '', |
| 65 'res_extra_dirs': [], |
| 66 'res_extra_files': [], |
| 67 'resource_input_paths': ['>@(res_extra_files)'], |
62 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', | 68 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', |
63 'classes_dir': '<(intermediate_dir)/classes', | 69 'classes_dir': '<(intermediate_dir)/classes', |
64 'compile_stamp': '<(intermediate_dir)/compile.stamp', | 70 'compile_stamp': '<(intermediate_dir)/compile.stamp', |
65 }, | 71 }, |
66 # This all_dependent_settings is used for java targets only. This will add the | 72 # This all_dependent_settings is used for java targets only. This will add the |
67 # jar path to the classpath of dependent java targets. | 73 # jar path to the classpath of dependent java targets. |
68 'all_dependent_settings': { | 74 'all_dependent_settings': { |
69 'variables': { | 75 'variables': { |
70 'input_jars_paths': ['<(jar_path)'], | 76 'input_jars_paths': ['<(jar_path)'], |
71 }, | 77 }, |
72 }, | 78 }, |
73 'conditions': [ | 79 'conditions': [ |
74 ['has_java_resources == 1', { | 80 ['has_java_resources == 1', { |
75 'variables': { | 81 'variables': { |
76 'res_dir': '<(java_in_dir)/res', | 82 'res_dir': '<(java_in_dir)/res', |
77 'out_res_dir': '<(intermediate_dir)/res', | 83 'res_crunched_dir': '<(intermediate_dir)/res_crunched', |
| 84 'res_input_dirs': ['<(res_dir)', '<@(res_extra_dirs)'], |
| 85 'resource_input_paths': ['<!@(find <(res_dir) -type f)'], |
78 'R_dir': '<(intermediate_dir)/java_R', | 86 'R_dir': '<(intermediate_dir)/java_R', |
79 'R_text_file': '<(R_dir)/R.txt', | 87 'R_text_file': '<(R_dir)/R.txt', |
80 'R_stamp': '<(intermediate_dir)/resources.stamp', | 88 'R_stamp': '<(intermediate_dir)/resources.stamp', |
81 'generated_src_dirs': ['<(R_dir)'], | 89 'generated_src_dirs': ['<(R_dir)'], |
82 'additional_input_paths': ['<(R_stamp)'], | 90 'additional_input_paths': ['<(R_stamp)'], |
83 # grit_grd_file is used by grit_action.gypi, included below. | |
84 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', | |
85 'resource_input_paths': [], | |
86 }, | 91 }, |
87 'all_dependent_settings': { | 92 'all_dependent_settings': { |
88 'variables': { | 93 'variables': { |
89 # Dependent jars include this target's R.java file via | 94 # Dependent jars include this target's R.java file via |
90 # generated_R_dirs and additional_R_files. | 95 # generated_R_dirs and additional_R_files. |
91 'generated_R_dirs': ['<(R_dir)'], | 96 'generated_R_dirs': ['<(R_dir)'], |
92 'additional_input_paths': ['<(R_stamp)'], | 97 'additional_input_paths': ['<(R_stamp)'], |
93 'additional_R_text_files': ['<(R_text_file)'], | |
94 | 98 |
95 # Dependent APKs include this target's resources via | 99 # Dependent APKs include this target's resources via |
96 # additional_res_dirs and additional_res_packages. | 100 # additional_res_dirs, additional_res_packages, and |
97 'additional_res_dirs': ['<(out_res_dir)', '<(res_dir)'], | 101 # additional_R_text_files. |
| 102 'additional_res_dirs': ['<(res_crunched_dir)', '<@(res_input_dirs)'], |
98 'additional_res_packages': ['<(R_package)'], | 103 'additional_res_packages': ['<(R_package)'], |
| 104 'additional_R_text_files': ['<(R_text_file)'], |
99 }, | 105 }, |
100 }, | 106 }, |
101 'conditions': [ | 107 'conditions': [ |
102 ['java_strings_grd != ""', { | 108 ['java_strings_grd != ""', { |
103 'variables': { | 109 'variables': { |
104 'resource_input_paths': [ | 110 'res_grit_dir': '<(intermediate_dir)/res_grit', |
105 # TODO(newt): replace this with .../values/strings.xml once | 111 'res_input_dirs': ['<(res_grit_dir)'], |
106 # the English strings.xml is generated as well? That would be | 112 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', |
107 # simpler and faster and should be equivalent. | 113 'resource_input_paths': ['<!@pymod_do_main(grit_info <@(grit_defines
) --outputs "<(res_grit_dir)" <(grit_grd_file))'], |
108 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_res_
dir)" <(grit_grd_file))', | |
109 ], | |
110 }, | 114 }, |
111 'actions': [ | 115 'actions': [ |
112 { | 116 { |
113 'action_name': 'generate_localized_strings_xml', | 117 'action_name': 'generate_localized_strings_xml', |
114 'variables': { | 118 'variables': { |
115 'grit_out_dir': '<(out_res_dir)', | 119 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=fals
e'], |
| 120 'grit_out_dir': '<(res_grit_dir)', |
116 # resource_ids is unneeded since we don't generate .h headers. | 121 # resource_ids is unneeded since we don't generate .h headers. |
117 'grit_resource_ids': '', | 122 'grit_resource_ids': '', |
118 }, | 123 }, |
119 'includes': ['../build/grit_action.gypi'], | 124 'includes': ['../build/grit_action.gypi'], |
120 }, | 125 }, |
121 ], | 126 ], |
122 }], | 127 }], |
123 ], | 128 ], |
124 'actions': [ | 129 'actions': [ |
125 # Generate R.java and crunch image resources. | 130 # Generate R.java and crunch image resources. |
126 { | 131 { |
127 'action_name': 'process_resources', | 132 'action_name': 'process_resources', |
128 'message': 'processing resources for <(_target_name)', | 133 'message': 'processing resources for <(_target_name)', |
129 'variables': { | 134 'variables': { |
130 'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml', | 135 'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml', |
131 }, | 136 }, |
132 'inputs': [ | 137 'inputs': [ |
133 '<(DEPTH)/build/android/pylib/build_utils.py', | 138 '<(DEPTH)/build/android/pylib/build_utils.py', |
134 '<(DEPTH)/build/android/process_resources.py', | 139 '<(DEPTH)/build/android/process_resources.py', |
135 '<!@(find <(res_dir) -type f)', | 140 '>@(resource_input_paths)', |
136 '<@(resource_input_paths)', | |
137 ], | 141 ], |
138 'outputs': [ | 142 'outputs': [ |
139 '<(R_stamp)', | 143 '<(R_stamp)', |
140 ], | 144 ], |
141 'action': [ | 145 'action': [ |
142 '<(DEPTH)/build/android/process_resources.py', | 146 '<(DEPTH)/build/android/process_resources.py', |
143 '--android-sdk', '<(android_sdk)', | 147 '--android-sdk', '<(android_sdk)', |
144 '--android-sdk-tools', '<(android_sdk_tools)', | 148 '--android-sdk-tools', '<(android_sdk_tools)', |
145 '--R-dir', '<(R_dir)', | 149 '--R-dir', '<(R_dir)', |
146 '--res-dir', '<(res_dir)', | 150 '--res-dirs', '<(res_input_dirs)', |
147 '--out-res-dir', '<(out_res_dir)', | 151 '--crunch-input-dir', '>(res_dir)', |
| 152 '--crunch-output-dir', '<(res_crunched_dir)', |
148 '--android-manifest', '<(android_manifest)', | 153 '--android-manifest', '<(android_manifest)', |
149 '--non-constant-id', | 154 '--non-constant-id', |
150 '--custom-package', '<(R_package)', | 155 '--custom-package', '<(R_package)', |
151 '--stamp', '<(R_stamp)', | 156 '--stamp', '<(R_stamp)', |
152 | 157 |
153 # Add list of inputs to the command line, so if inputs change | 158 # Add hash of inputs to the command line, so if inputs change |
154 # (e.g. if a resource if removed), the command will be re-run. | 159 # (e.g. if a resource if removed), the command will be re-run. |
155 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 160 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
156 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', | 161 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', |
157 ], | 162 ], |
158 }, | 163 }, |
159 ], | 164 ], |
160 }], | 165 }], |
161 ], | 166 ], |
162 'actions': [ | 167 'actions': [ |
163 { | 168 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 '--classes-dir=<(classes_dir)', | 213 '--classes-dir=<(classes_dir)', |
209 '--jar-path=<(jar_path)', | 214 '--jar-path=<(jar_path)', |
210 '--excluded-classes=<(excluded_classes)', | 215 '--excluded-classes=<(excluded_classes)', |
211 | 216 |
212 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja
. | 217 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja
. |
213 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', | 218 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', |
214 ] | 219 ] |
215 }, | 220 }, |
216 ], | 221 ], |
217 } | 222 } |
OLD | NEW |