OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Writes a build_config file. | 7 """Writes a build_config file. |
8 | 8 |
9 The build_config file for a target is a json file containing information about | 9 The build_config file for a target is a json file containing information about |
10 how to build that target based on the target's dependencies. This includes | 10 how to build that target based on the target's dependencies. This includes |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 parser.add_option('--build-config', help='Path to build_config output.') | 62 parser.add_option('--build-config', help='Path to build_config output.') |
63 parser.add_option( | 63 parser.add_option( |
64 '--type', | 64 '--type', |
65 help='Type of this target (e.g. android_library).') | 65 help='Type of this target (e.g. android_library).') |
66 parser.add_option( | 66 parser.add_option( |
67 '--possible-deps-configs', | 67 '--possible-deps-configs', |
68 help='List of paths for dependency\'s build_config files. Some ' | 68 help='List of paths for dependency\'s build_config files. Some ' |
69 'dependencies may not write build_config files. Missing build_config ' | 69 'dependencies may not write build_config files. Missing build_config ' |
70 'files are handled differently based on the type of this target.') | 70 'files are handled differently based on the type of this target.') |
71 | 71 |
72 # android_resources/apk options | 72 # android_resources options |
73 parser.add_option('--srcjar', help='Path to target\'s resources srcjar.') | 73 parser.add_option('--srcjar', help='Path to target\'s resources srcjar.') |
74 parser.add_option('--resources-zip', help='Path to target\'s resources zip.') | 74 parser.add_option('--resources-zip', help='Path to target\'s resources zip.') |
75 parser.add_option('--package-name', | |
76 help='Java package name for these resources.') | |
77 parser.add_option('--android-manifest', help='Path to android manifest.') | |
75 | 78 |
76 # android_library/apk options | 79 # android_library/apk options |
77 parser.add_option('--jar-path', help='Path to target\'s jar output.') | 80 parser.add_option('--jar-path', help='Path to target\'s jar output.') |
78 parser.add_option('--dex-path', help='Path to target\'s dex output.') | 81 parser.add_option('--dex-path', help='Path to target\'s dex output.') |
79 | 82 |
80 # apk native library options | 83 # apk native library options |
81 parser.add_option('--native-libs', help='List of top-level native libs.') | 84 parser.add_option('--native-libs', help='List of top-level native libs.') |
82 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') | 85 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') |
83 | 86 |
84 options, args = parser.parse_args(argv) | 87 options, args = parser.parse_args(argv) |
(...skipping 29 matching lines...) Expand all Loading... | |
114 raise Exception('Unknown deps: ' + str(unknown_deps)) | 117 raise Exception('Unknown deps: ' + str(unknown_deps)) |
115 | 118 |
116 direct_deps_config_paths = [ | 119 direct_deps_config_paths = [ |
117 c for c in possible_deps_config_paths if not c in unknown_deps] | 120 c for c in possible_deps_config_paths if not c in unknown_deps] |
118 all_deps_config_paths = GetAllDepsConfigsInOrder(direct_deps_config_paths) | 121 all_deps_config_paths = GetAllDepsConfigsInOrder(direct_deps_config_paths) |
119 | 122 |
120 direct_deps_configs = [GetDepConfig(p) for p in direct_deps_config_paths] | 123 direct_deps_configs = [GetDepConfig(p) for p in direct_deps_config_paths] |
121 all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths] | 124 all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths] |
122 | 125 |
123 direct_library_deps = DepsOfType('android_library', direct_deps_configs) | 126 direct_library_deps = DepsOfType('android_library', direct_deps_configs) |
127 all_library_deps = DepsOfType('android_library', all_deps_configs) | |
128 | |
129 direct_resources_deps = DepsOfType('android_resources', direct_deps_configs) | |
124 all_resources_deps = DepsOfType('android_resources', all_deps_configs) | 130 all_resources_deps = DepsOfType('android_resources', all_deps_configs) |
125 all_library_deps = DepsOfType('android_library', all_deps_configs) | |
126 | 131 |
127 # Initialize some common config. | 132 # Initialize some common config. |
128 config = { | 133 config = { |
129 'deps_info': { | 134 'deps_info': { |
130 'path': options.build_config, | 135 'path': options.build_config, |
131 'type': options.type, | 136 'type': options.type, |
132 'deps_configs': direct_deps_config_paths, | 137 'deps_configs': direct_deps_config_paths, |
133 } | 138 } |
134 } | 139 } |
135 deps_info = config['deps_info'] | 140 deps_info = config['deps_info'] |
136 | 141 |
137 if options.type in ['android_library', 'android_apk']: | 142 if options.type in ['android_library', 'android_apk']: |
138 javac_classpath = [c['jar_path'] for c in direct_library_deps] | 143 javac_classpath = [c['jar_path'] for c in direct_library_deps] |
139 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] | 144 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] |
140 deps_info['jar_path'] = options.jar_path | 145 deps_info['jar_path'] = options.jar_path |
141 deps_info['dex_path'] = options.dex_path | 146 deps_info['dex_path'] = options.dex_path |
142 config['javac'] = { | 147 config['javac'] = { |
143 'classpath': javac_classpath, | 148 'classpath': javac_classpath, |
144 } | 149 } |
150 | |
151 if options.type == 'android_library': | |
145 # Only resources might have srcjars (normal srcjar targets are listed in | 152 # Only resources might have srcjars (normal srcjar targets are listed in |
146 # srcjar_deps). A resource's srcjar contains the R.java file for those | 153 # srcjar_deps). A resource's srcjar contains the R.java file for those |
147 # resources, and (like Android's default build system) we allow a library to | 154 # resources, and (like Android's default build system) we allow a library to |
148 # refer to the resources in any of its dependents. | 155 # refer to the resources in any of its dependents. |
149 config['javac']['srcjars'] = [ | 156 config['javac']['srcjars'] = [ |
150 c['srcjar'] for c in all_resources_deps if 'srcjar' in c] | 157 c['srcjar'] for c in direct_resources_deps if 'srcjar' in c] |
151 | 158 |
152 if options.type == 'android_resources' or options.type == 'android_apk': | 159 if options.type == 'android_apk': |
160 config['javac']['srcjars'] = [] | |
161 | |
162 | |
163 if options.type == 'android_resources': | |
153 deps_info['resources_zip'] = options.resources_zip | 164 deps_info['resources_zip'] = options.resources_zip |
154 if options.srcjar: | 165 if options.srcjar: |
155 deps_info['srcjar'] = options.srcjar | 166 deps_info['srcjar'] = options.srcjar |
167 if options.package_name: | |
168 deps_info['package_name'] = options.package_name | |
156 | 169 |
170 if options.type == 'android_resources' or options.type == 'android_apk': | |
newt (away)
2014/09/15 18:44:25
or "in ['android_resources', 'android_apk']"
| |
157 config['resources'] = {} | 171 config['resources'] = {} |
158 config['resources']['dependency_zips'] = [ | 172 config['resources']['dependency_zips'] = [ |
159 c['resources_zip'] for c in all_resources_deps] | 173 c['resources_zip'] for c in all_resources_deps] |
174 config['resources']['extra_package_names'] = [ | |
175 c['package_name'] for c in all_resources_deps if 'package_name' in c] | |
176 | |
160 | 177 |
161 if options.type == 'android_apk': | 178 if options.type == 'android_apk': |
162 config['apk_dex'] = {} | 179 config['apk_dex'] = {} |
163 dex_config = config['apk_dex'] | 180 dex_config = config['apk_dex'] |
164 # TODO(cjhopman): proguard version | 181 # TODO(cjhopman): proguard version |
165 dex_deps_files = [c['dex_path'] for c in all_library_deps] | 182 dex_deps_files = [c['dex_path'] for c in all_library_deps] |
166 dex_config['dependency_dex_files'] = dex_deps_files | 183 dex_config['dependency_dex_files'] = dex_deps_files |
167 | 184 |
168 config['dist_jar'] = { | 185 config['dist_jar'] = { |
169 'dependency_jars': [ | 186 'dependency_jars': [ |
(...skipping 27 matching lines...) Expand all Loading... | |
197 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 214 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
198 | 215 |
199 if options.depfile: | 216 if options.depfile: |
200 build_utils.WriteDepfile( | 217 build_utils.WriteDepfile( |
201 options.depfile, | 218 options.depfile, |
202 all_deps_config_paths + build_utils.GetPythonDependencies()) | 219 all_deps_config_paths + build_utils.GetPythonDependencies()) |
203 | 220 |
204 | 221 |
205 if __name__ == '__main__': | 222 if __name__ == '__main__': |
206 sys.exit(main(sys.argv[1:])) | 223 sys.exit(main(sys.argv[1:])) |
OLD | NEW |