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

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

Issue 321453002: Add creation of v14 compatible resources to process_resources.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « build/android/gyp/generate_v14_compatible_resources.py ('k') | build/grit_action.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library resources to generate R.java and crunched images.""" 7 """Process Android resources to generate R.java, and prepare for packaging.
8
9 This will crunch images and generate v14 compatible resources
10 (see generate_v14_compatible_resources.py).
11 """
8 12
9 import optparse 13 import optparse
10 import os 14 import os
11 import re 15 import re
12 import shlex 16 import shlex
13 import shutil 17 import shutil
14 18
19 import generate_v14_compatible_resources as v14_resources
newt (away) 2014/06/06 01:37:35 do you really need to "import as"? :)
cjhopman 2014/06/06 01:46:55 Ha, the other name was just so long. Done.
20
15 from util import build_utils 21 from util import build_utils
16 22
17 def ParseArgs(): 23 def ParseArgs():
18 """Parses command line options. 24 """Parses command line options.
19 25
20 Returns: 26 Returns:
21 An options object as from optparse.OptionsParser.parse_args() 27 An options object as from optparse.OptionsParser.parse_args()
22 """ 28 """
23 parser = optparse.OptionParser() 29 parser = optparse.OptionParser()
24 parser.add_option('--android-sdk', help='path to the Android SDK folder') 30 parser.add_option('--android-sdk', help='path to the Android SDK folder')
25 parser.add_option('--android-sdk-tools', 31 parser.add_option('--android-sdk-tools',
26 help='path to the Android SDK build tools folder') 32 help='path to the Android SDK build tools folder')
27 parser.add_option('--R-dir', help='directory to hold generated R.java') 33 parser.add_option('--R-dir', help='directory to hold generated R.java')
28 parser.add_option('--dependencies-res-dirs', 34 parser.add_option('--dependencies-res-dirs',
29 help='directories containing resources to be packaged') 35 help='directories containing resources to be packaged')
30 parser.add_option('--resource-dir', 36 parser.add_option('--resource-dir',
31 help='directory containing this target\'s resources.') 37 help='directory containing this target\'s resources.')
32 parser.add_option('--crunch-output-dir', 38 parser.add_option('--crunch-output-dir',
33 help='directory to hold crunched resources') 39 help='directory to hold crunched resources')
34 parser.add_option('--non-constant-id', action='store_true') 40 parser.add_option('--non-constant-id', action='store_true')
35 parser.add_option('--custom-package', help='Java package for R.java') 41 parser.add_option('--custom-package', help='Java package for R.java')
36 parser.add_option('--android-manifest', help='AndroidManifest.xml path') 42 parser.add_option('--android-manifest', help='AndroidManifest.xml path')
37 parser.add_option('--proguard-file', 43 parser.add_option('--proguard-file',
38 help='Path to proguard.txt generated file') 44 help='Path to proguard.txt generated file')
39 parser.add_option('--stamp', help='File to touch on success') 45
46 parser.add_option('--res-v14-compatibility-dir',
47 help='output directory into which '
48 'v14 compatible resources will be generated')
49 parser.add_option(
50 '--v14-verify-only',
51 action='store_true',
52 help='Do not generate v14 resources. Instead, just verify that the '
53 'resources are already compatible with v14, i.e. they don\'t use '
54 'attributes that cause crashes on certain devices.')
40 55
41 parser.add_option( 56 parser.add_option(
42 '--extra-res-packages', 57 '--extra-res-packages',
43 help='Additional package names to generate R.java files for') 58 help='Additional package names to generate R.java files for')
44 parser.add_option( 59 parser.add_option(
45 '--extra-r-text-files', 60 '--extra-r-text-files',
46 help='For each additional package, the R.txt file should contain a ' 61 help='For each additional package, the R.txt file should contain a '
47 'list of resources to be included in the R.java file in the format ' 62 'list of resources to be included in the R.java file in the format '
48 'generated by aapt') 63 'generated by aapt')
49 64
65 parser.add_option('--stamp', help='File to touch on success')
66
50 (options, args) = parser.parse_args() 67 (options, args) = parser.parse_args()
51 68
52 if args: 69 if args:
53 parser.error('No positional arguments should be given.') 70 parser.error('No positional arguments should be given.')
54 71
55 # Check that required options have been provided. 72 # Check that required options have been provided.
56 required_options = ( 73 required_options = (
57 'android_sdk', 74 'android_sdk',
58 'android_sdk_tools', 75 'android_sdk_tools',
59 'android_manifest', 76 'android_manifest',
60 'dependencies_res_dirs', 77 'dependencies_res_dirs',
61 'resource_dir', 78 'resource_dir',
62 'crunch_output_dir', 79 'crunch_output_dir',
63 'R_dir', 80 'R_dir',
81 'res_v14_compatibility_dir',
64 ) 82 )
65 build_utils.CheckOptions(options, parser, required=required_options) 83 build_utils.CheckOptions(options, parser, required=required_options)
66 84
67 return options 85 return options
68 86
69 87
70 def CreateExtraRJavaFiles( 88 def CreateExtraRJavaFiles(
71 r_dir, extra_packages, extra_r_text_files): 89 r_dir, extra_packages, extra_r_text_files):
72 if len(extra_packages) != len(extra_r_text_files): 90 if len(extra_packages) != len(extra_r_text_files):
73 raise Exception('--extra-res-packages and --extra-r-text-files' 91 raise Exception('--extra-res-packages and --extra-r-text-files'
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 153
136 154
137 def main(): 155 def main():
138 options = ParseArgs() 156 options = ParseArgs()
139 android_jar = os.path.join(options.android_sdk, 'android.jar') 157 android_jar = os.path.join(options.android_sdk, 'android.jar')
140 aapt = os.path.join(options.android_sdk_tools, 'aapt') 158 aapt = os.path.join(options.android_sdk_tools, 'aapt')
141 159
142 build_utils.DeleteDirectory(options.R_dir) 160 build_utils.DeleteDirectory(options.R_dir)
143 build_utils.MakeDirectory(options.R_dir) 161 build_utils.MakeDirectory(options.R_dir)
144 162
163 build_utils.DeleteDirectory(options.res_v14_compatibility_dir)
newt (away) 2014/06/06 01:37:35 This directory is deleted and created in generate_
cjhopman 2014/06/06 01:46:55 Done.
164 build_utils.MakeDirectory(options.res_v14_compatibility_dir)
165
166 v14_resources.GenerateV14Resources(
167 options.resource_dir,
168 options.res_v14_compatibility_dir,
169 options.v14_verify_only)
170
145 # Generate R.java. This R.java contains non-final constants and is used only 171 # Generate R.java. This R.java contains non-final constants and is used only
146 # while compiling the library jar (e.g. chromium_content.jar). When building 172 # while compiling the library jar (e.g. chromium_content.jar). When building
147 # an apk, a new R.java file with the correct resource -> ID mappings will be 173 # an apk, a new R.java file with the correct resource -> ID mappings will be
148 # generated by merging the resources from all libraries and the main apk 174 # generated by merging the resources from all libraries and the main apk
149 # project. 175 # project.
150 package_command = [aapt, 176 package_command = [aapt,
151 'package', 177 'package',
152 '-m', 178 '-m',
153 '-M', options.android_manifest, 179 '-M', options.android_manifest,
154 '--auto-add-overlay', 180 '--auto-add-overlay',
(...skipping 30 matching lines...) Expand all
185 build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail) 211 build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail)
186 212
187 MoveImagesToNonMdpiFolders(options.crunch_output_dir) 213 MoveImagesToNonMdpiFolders(options.crunch_output_dir)
188 214
189 if options.stamp: 215 if options.stamp:
190 build_utils.Touch(options.stamp) 216 build_utils.Touch(options.stamp)
191 217
192 218
193 if __name__ == '__main__': 219 if __name__ == '__main__':
194 main() 220 main()
OLDNEW
« no previous file with comments | « build/android/gyp/generate_v14_compatible_resources.py ('k') | build/grit_action.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698