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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 parser.add_option('--native-libs', help='List of top-level native libs.') | 88 parser.add_option('--native-libs', help='List of top-level native libs.') |
89 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') | 89 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') |
90 | 90 |
91 options, args = parser.parse_args(argv) | 91 options, args = parser.parse_args(argv) |
92 | 92 |
93 if args: | 93 if args: |
94 parser.error('No positional arguments should be given.') | 94 parser.error('No positional arguments should be given.') |
95 | 95 |
96 | 96 |
97 if not options.type in [ | 97 if not options.type in [ |
98 'java_library', 'android_resources', 'android_apk']: | 98 'java_library', 'android_resources', 'android_apk', 'deps_dex']: |
99 raise Exception('Unknown type: <%s>' % options.type) | 99 raise Exception('Unknown type: <%s>' % options.type) |
100 | 100 |
101 required_options = ['build_config'] + { | 101 required_options = ['build_config'] + { |
102 'java_library': ['jar_path'], | 102 'java_library': ['jar_path'], |
103 'android_resources': ['resources_zip'], | 103 'android_resources': ['resources_zip'], |
104 'android_apk': ['jar_path', 'dex_path', 'resources_zip'] | 104 'android_apk': ['jar_path', 'dex_path', 'resources_zip'], |
105 'deps_dex': ['dex_path'] | |
105 }[options.type] | 106 }[options.type] |
106 | 107 |
107 if options.native_libs: | 108 if options.native_libs: |
108 required_options.append('readelf_path') | 109 required_options.append('readelf_path') |
109 | 110 |
110 build_utils.CheckOptions(options, parser, required_options) | 111 build_utils.CheckOptions(options, parser, required_options) |
111 | 112 |
112 if options.type == 'java_library': | 113 if options.type == 'java_library': |
113 if options.supports_android and not options.dex_path: | 114 if options.supports_android and not options.dex_path: |
114 raise Exception('java_library that supports Android requires a dex path.') | 115 raise Exception('java_library that supports Android requires a dex path.') |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 config['resources'] = {} | 207 config['resources'] = {} |
207 config['resources']['dependency_zips'] = [ | 208 config['resources']['dependency_zips'] = [ |
208 c['resources_zip'] for c in all_resources_deps] | 209 c['resources_zip'] for c in all_resources_deps] |
209 config['resources']['extra_package_names'] = [] | 210 config['resources']['extra_package_names'] = [] |
210 | 211 |
211 if options.type == 'android_apk': | 212 if options.type == 'android_apk': |
212 config['resources']['extra_package_names'] = [ | 213 config['resources']['extra_package_names'] = [ |
213 c['package_name'] for c in all_resources_deps if 'package_name' in c] | 214 c['package_name'] for c in all_resources_deps if 'package_name' in c] |
214 | 215 |
215 | 216 |
216 # Dependencies for the final dex file of an apk or the standalone .dex.jar | 217 # Dependencies for the final dex file of an apk or a 'deps_dex'. |
217 # output of a library. | 218 if options.type == 'android_apk' or 'deps_dex': |
cjhopman
2014/12/09 19:53:55
Should be:
if options.type == 'android_apk' or opt
ppi
2014/12/09 21:36:46
Done.
| |
218 if options.type == 'android_apk' or (options.type == "java_library" | |
219 and options.supports_android): | |
220 config['final_dex'] = {} | 219 config['final_dex'] = {} |
221 dex_config = config['final_dex'] | 220 dex_config = config['final_dex'] |
222 # TODO(cjhopman): proguard version | 221 # TODO(cjhopman): proguard version |
223 dex_deps_files = [c['dex_path'] for c in all_library_deps] | 222 dex_deps_files = [c['dex_path'] for c in all_library_deps] |
224 dex_config['dependency_dex_files'] = dex_deps_files | 223 dex_config['dependency_dex_files'] = dex_deps_files |
225 | 224 |
226 if options.type == 'android_apk': | 225 if options.type == 'android_apk': |
227 config['dist_jar'] = { | 226 config['dist_jar'] = { |
228 'dependency_jars': [ | 227 'dependency_jars': [ |
229 c['jar_path'] for c in all_library_deps | 228 c['jar_path'] for c in all_library_deps |
(...skipping 26 matching lines...) Expand all Loading... | |
256 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 255 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
257 | 256 |
258 if options.depfile: | 257 if options.depfile: |
259 build_utils.WriteDepfile( | 258 build_utils.WriteDepfile( |
260 options.depfile, | 259 options.depfile, |
261 all_deps_config_paths + build_utils.GetPythonDependencies()) | 260 all_deps_config_paths + build_utils.GetPythonDependencies()) |
262 | 261 |
263 | 262 |
264 if __name__ == '__main__': | 263 if __name__ == '__main__': |
265 sys.exit(main(sys.argv[1:])) | 264 sys.exit(main(sys.argv[1:])) |
OLD | NEW |