Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: build/android/gyp/process_resources.py

Issue 507523002: Add content_shell_apk target (and a bunch of its dependencies) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 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 """Process Android resources to generate R.java, and prepare for packaging. 7 """Process Android resources to generate R.java, and prepare for packaging.
8 8
9 This will crunch images and generate v14 compatible resources 9 This will crunch images and generate v14 compatible resources
10 (see generate_v14_compatible_resources.py). 10 (see generate_v14_compatible_resources.py).
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for d in resource_dirs: 147 for d in resource_dirs:
148 for root, _, files in os.walk(d): 148 for root, _, files in os.walk(d):
149 for f in files: 149 for f in files:
150 archive_path = os.path.join(os.path.relpath(root, d), f) 150 archive_path = os.path.join(os.path.relpath(root, d), f)
151 path = os.path.join(root, f) 151 path = os.path.join(root, f)
152 files_to_zip[archive_path] = path 152 files_to_zip[archive_path] = path
153 with zipfile.ZipFile(zip_path, 'w') as outzip: 153 with zipfile.ZipFile(zip_path, 'w') as outzip:
154 for archive_path, path in files_to_zip.iteritems(): 154 for archive_path, path in files_to_zip.iteritems():
155 outzip.write(path, archive_path) 155 outzip.write(path, archive_path)
156 156
157 def CombineZips(zip_files, output_path):
newt (away) 2014/09/02 23:41:30 A short comment here would be nice
cjhopman 2014/09/04 01:14:58 Done.
158 with zipfile.ZipFile(output_path, 'w') as outzip:
159 for i, z in enumerate(zip_files):
160 with zipfile.ZipFile(z, 'r') as inzip:
161 for name in inzip.namelist():
162 new_name = '%d/%s' % (i, name)
163 outzip.writestr(new_name, inzip.read(name))
164
157 165
158 def main(): 166 def main():
159 args = build_utils.ExpandFileArgs(sys.argv[1:]) 167 args = build_utils.ExpandFileArgs(sys.argv[1:])
160 168
161 options = ParseArgs(args) 169 options = ParseArgs(args)
162 android_jar = os.path.join(options.android_sdk, 'android.jar') 170 android_jar = os.path.join(options.android_sdk, 'android.jar')
163 aapt = os.path.join(options.android_sdk_tools, 'aapt') 171 aapt = os.path.join(options.android_sdk_tools, 'aapt')
164 172
165 input_files = [] 173 input_files = []
166 174
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 zip_resource_dirs.append(crunch_dir) 249 zip_resource_dirs.append(crunch_dir)
242 aapt_cmd = [aapt, 250 aapt_cmd = [aapt,
243 'crunch', 251 'crunch',
244 '-C', crunch_dir, 252 '-C', crunch_dir,
245 '-S', d] 253 '-S', d]
246 build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail) 254 build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail)
247 255
248 ZipResources(zip_resource_dirs, options.resource_zip_out) 256 ZipResources(zip_resource_dirs, options.resource_zip_out)
249 257
250 if options.all_resources_zip_out: 258 if options.all_resources_zip_out:
251 ZipResources( 259 CombineZips([options.resource_zip_out] + dep_zips,
252 zip_resource_dirs + dep_subdirs, options.all_resources_zip_out) 260 options.all_resources_zip_out)
253 261
254 if options.R_dir: 262 if options.R_dir:
255 build_utils.DeleteDirectory(options.R_dir) 263 build_utils.DeleteDirectory(options.R_dir)
256 shutil.copytree(gen_dir, options.R_dir) 264 shutil.copytree(gen_dir, options.R_dir)
257 else: 265 else:
258 build_utils.ZipDir(options.srcjar_out, gen_dir) 266 build_utils.ZipDir(options.srcjar_out, gen_dir)
259 267
260 if options.depfile: 268 if options.depfile:
261 input_files += build_utils.GetPythonDependencies() 269 input_files += build_utils.GetPythonDependencies()
262 build_utils.WriteDepfile(options.depfile, input_files) 270 build_utils.WriteDepfile(options.depfile, input_files)
263 271
264 if options.stamp: 272 if options.stamp:
265 build_utils.Touch(options.stamp) 273 build_utils.Touch(options.stamp)
266 274
267 275
268 if __name__ == '__main__': 276 if __name__ == '__main__':
269 main() 277 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698