| OLD | NEW |
| 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 library resources to generate R.java and crunched images.""" |
| 8 | 8 |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| 11 import shlex | 11 import shlex |
| 12 import subprocess | |
| 13 | 12 |
| 14 from pylib import build_utils | 13 from pylib import build_utils |
| 15 | 14 |
| 16 def ParseArgs(): | 15 def ParseArgs(): |
| 17 """Parses command line options. | 16 """Parses command line options. |
| 18 | 17 |
| 19 Returns: | 18 Returns: |
| 20 An options object as from optparse.OptionsParser.parse_args() | 19 An options object as from optparse.OptionsParser.parse_args() |
| 21 """ | 20 """ |
| 22 parser = optparse.OptionParser() | 21 parser = optparse.OptionParser() |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 '-I', android_jar, | 72 '-I', android_jar, |
| 74 '--output-text-symbols', options.R_dir, | 73 '--output-text-symbols', options.R_dir, |
| 75 '-J', options.R_dir] | 74 '-J', options.R_dir] |
| 76 res_dirs = shlex.split(options.res_dirs) | 75 res_dirs = shlex.split(options.res_dirs) |
| 77 for res_dir in res_dirs: | 76 for res_dir in res_dirs: |
| 78 package_command += ['-S', res_dir] | 77 package_command += ['-S', res_dir] |
| 79 if options.non_constant_id: | 78 if options.non_constant_id: |
| 80 package_command.append('--non-constant-id') | 79 package_command.append('--non-constant-id') |
| 81 if options.custom_package: | 80 if options.custom_package: |
| 82 package_command += ['--custom-package', options.custom_package] | 81 package_command += ['--custom-package', options.custom_package] |
| 83 subprocess.check_call(package_command) | 82 build_utils.CheckCallDie(package_command) |
| 84 | 83 |
| 85 # Crunch image resources. This shrinks png files and is necessary for 9-patch | 84 # Crunch image resources. This shrinks png files and is necessary for 9-patch |
| 86 # images to display correctly. | 85 # images to display correctly. |
| 87 build_utils.MakeDirectory(options.crunch_output_dir) | 86 build_utils.MakeDirectory(options.crunch_output_dir) |
| 88 subprocess.check_call([aapt, | |
| 89 'crunch', | |
| 90 '-S', options.crunch_input_dir, | |
| 91 '-C', options.crunch_output_dir]) | |
| 92 | 87 |
| 93 build_utils.Touch(options.stamp) | 88 aapt_cmd = [aapt, |
| 89 'crunch', |
| 90 '-S', options.crunch_input_dir, |
| 91 '-C', options.crunch_output_dir] |
| 92 build_utils.CheckCallDie(aapt_cmd) |
| 93 |
| 94 if options.stamp: |
| 95 build_utils.Touch(options.stamp) |
| 94 | 96 |
| 95 | 97 |
| 96 if __name__ == '__main__': | 98 if __name__ == '__main__': |
| 97 main() | 99 main() |
| OLD | NEW |