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

Side by Side Diff: build/android/gyp/package_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 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 # pylint: disable=C0301 7 # pylint: disable=C0301
8 """Package resources into an apk. 8 """Package resources into an apk.
9 9
10 See https://android.googlesource.com/platform/tools/base/+/master/legacy/ant-tas ks/src/main/java/com/android/ant/AaptExecTask.java 10 See https://android.googlesource.com/platform/tools/base/+/master/legacy/ant-tas ks/src/main/java/com/android/ant/AaptExecTask.java
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 build_utils.MakeDirectory(dst_dir) 81 build_utils.MakeDirectory(dst_dir)
82 for src_file_name in os.listdir(src_dir): 82 for src_file_name in os.listdir(src_dir):
83 if not src_file_name.endswith('.png'): 83 if not src_file_name.endswith('.png'):
84 continue 84 continue
85 src_file = os.path.join(src_dir, src_file_name) 85 src_file = os.path.join(src_dir, src_file_name)
86 dst_file = os.path.join(dst_dir, src_file_name) 86 dst_file = os.path.join(dst_dir, src_file_name)
87 assert not os.path.lexists(dst_file) 87 assert not os.path.lexists(dst_file)
88 shutil.move(src_file, dst_file) 88 shutil.move(src_file, dst_file)
89 89
90 90
91 def PrepareExtractedZip(d):
92 res_dirs = []
93 subdirs = [os.path.join(d, s) for s in os.listdir(d)]
94 subdirs = sorted([s for s in subdirs if os.path.isdir(s)])
95 if subdirs and os.path.basename(subdirs[0]) == '0':
newt (away) 2014/09/02 23:41:30 I'd explain what's going on here (the two possible
cjhopman 2014/09/04 01:14:58 Done.
96 res_dirs = subdirs
97 else:
98 res_dirs = [d]
99 package_command = []
100 for d in res_dirs:
101 MoveImagesToNonMdpiFolders(d)
102 package_command += ['-S', d]
103 return package_command
104
105
91 def main(): 106 def main():
92 options = ParseArgs() 107 options = ParseArgs()
93 android_jar = os.path.join(options.android_sdk, 'android.jar') 108 android_jar = os.path.join(options.android_sdk, 'android.jar')
94 aapt = os.path.join(options.android_sdk_tools, 'aapt') 109 aapt = os.path.join(options.android_sdk_tools, 'aapt')
95 110
96 with build_utils.TempDir() as temp_dir: 111 with build_utils.TempDir() as temp_dir:
97 package_command = [aapt, 112 package_command = [aapt,
98 'package', 113 'package',
99 '--version-code', options.version_code, 114 '--version-code', options.version_code,
100 '--version-name', options.version_name, 115 '--version-name', options.version_name,
(...skipping 12 matching lines...) Expand all
113 128
114 if os.path.exists(options.asset_dir): 129 if os.path.exists(options.asset_dir):
115 package_command += ['-A', options.asset_dir] 130 package_command += ['-A', options.asset_dir]
116 131
117 dep_zips = build_utils.ParseGypList(options.resource_zips) 132 dep_zips = build_utils.ParseGypList(options.resource_zips)
118 for z in dep_zips: 133 for z in dep_zips:
119 subdir = os.path.join(temp_dir, os.path.basename(z)) 134 subdir = os.path.join(temp_dir, os.path.basename(z))
120 if os.path.exists(subdir): 135 if os.path.exists(subdir):
121 raise Exception('Resource zip name conflict: ' + os.path.basename(z)) 136 raise Exception('Resource zip name conflict: ' + os.path.basename(z))
122 build_utils.ExtractAll(z, path=subdir) 137 build_utils.ExtractAll(z, path=subdir)
123 MoveImagesToNonMdpiFolders(subdir) 138 package_command += PrepareExtractedZip(subdir)
124 package_command += ['-S', subdir]
125 139
126 if 'Debug' in options.configuration_name: 140 if 'Debug' in options.configuration_name:
127 package_command += ['--debug-mode'] 141 package_command += ['--debug-mode']
128 142
129 build_utils.CheckOutput( 143 build_utils.CheckOutput(
130 package_command, print_stdout=False, print_stderr=False) 144 package_command, print_stdout=False, print_stderr=False)
131 145
132 if options.depfile: 146 if options.depfile:
133 build_utils.WriteDepfile( 147 build_utils.WriteDepfile(
134 options.depfile, 148 options.depfile,
135 build_utils.GetPythonDependencies()) 149 build_utils.GetPythonDependencies())
136 150
137 151
138 if __name__ == '__main__': 152 if __name__ == '__main__':
139 main() 153 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698