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 | 12 |
13 from util import build_utils | 13 from util import build_utils |
14 | 14 |
15 def ParseArgs(): | 15 def ParseArgs(): |
16 """Parses command line options. | 16 """Parses command line options. |
17 | 17 |
18 Returns: | 18 Returns: |
19 An options object as from optparse.OptionsParser.parse_args() | 19 An options object as from optparse.OptionsParser.parse_args() |
20 """ | 20 """ |
21 parser = optparse.OptionParser() | 21 parser = optparse.OptionParser() |
22 parser.add_option('--android-sdk', help='path to the Android SDK folder') | 22 parser.add_option('--android-sdk', help='path to the Android SDK folder') |
23 parser.add_option('--android-sdk-tools', | 23 parser.add_option('--android-sdk-tools', |
24 help='path to the Android SDK platform tools folder') | 24 help='path to the Android SDK build tools folder') |
25 parser.add_option('--R-dir', help='directory to hold generated R.java') | 25 parser.add_option('--R-dir', help='directory to hold generated R.java') |
26 parser.add_option('--res-dirs', | 26 parser.add_option('--res-dirs', |
27 help='directories containing resources to be packaged') | 27 help='directories containing resources to be packaged') |
28 parser.add_option('--crunch-input-dir', | 28 parser.add_option('--crunch-input-dir', |
29 help='directory containing images to be crunched') | 29 help='directory containing images to be crunched') |
30 parser.add_option('--crunch-output-dir', | 30 parser.add_option('--crunch-output-dir', |
31 help='directory to hold crunched resources') | 31 help='directory to hold crunched resources') |
32 parser.add_option('--non-constant-id', action='store_true') | 32 parser.add_option('--non-constant-id', action='store_true') |
33 parser.add_option('--custom-package', help='Java package for R.java') | 33 parser.add_option('--custom-package', help='Java package for R.java') |
34 parser.add_option('--android-manifest', help='AndroidManifest.xml path') | 34 parser.add_option('--android-manifest', help='AndroidManifest.xml path') |
35 parser.add_option('--stamp', help='File to touch on success') | 35 parser.add_option('--stamp', help='File to touch on success') |
36 | 36 |
37 # This is part of a temporary fix for crbug.com/177552. | 37 # This is part of a temporary fix for crbug.com/177552. |
38 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 38 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
39 parser.add_option('--ignore', help='this argument is ignored') | 39 parser.add_option('--ignore', help='this argument is ignored') |
40 (options, args) = parser.parse_args() | 40 (options, args) = parser.parse_args() |
41 | 41 |
42 if args: | 42 if args: |
43 parser.error('No positional arguments should be given.') | 43 parser.error('No positional arguments should be given.') |
44 | 44 |
45 # Check that required options have been provided. | 45 # Check that required options have been provided. |
46 required_options = ('android_sdk', 'android_sdk_tools', 'R_dir', 'res_dirs', | 46 required_options = ('android_sdk', 'android_sdk_tools', 'R_dir', |
47 'crunch_input_dir', 'crunch_output_dir') | 47 'res_dirs', 'crunch_input_dir', 'crunch_output_dir') |
48 build_utils.CheckOptions(options, parser, required=required_options) | 48 build_utils.CheckOptions(options, parser, required=required_options) |
49 | 49 |
50 return options | 50 return options |
51 | 51 |
52 | 52 |
53 def main(): | 53 def main(): |
54 options = ParseArgs() | 54 options = ParseArgs() |
55 android_jar = os.path.join(options.android_sdk, 'android.jar') | 55 android_jar = os.path.join(options.android_sdk, 'android.jar') |
56 aapt = os.path.join(options.android_sdk_tools, 'aapt') | 56 aapt = os.path.join(options.android_sdk_tools, 'aapt') |
57 | 57 |
(...skipping 30 matching lines...) Expand all Loading... |
88 '-S', options.crunch_input_dir, | 88 '-S', options.crunch_input_dir, |
89 '-C', options.crunch_output_dir] | 89 '-C', options.crunch_output_dir] |
90 build_utils.CheckCallDie(aapt_cmd, suppress_output=True) | 90 build_utils.CheckCallDie(aapt_cmd, suppress_output=True) |
91 | 91 |
92 if options.stamp: | 92 if options.stamp: |
93 build_utils.Touch(options.stamp) | 93 build_utils.Touch(options.stamp) |
94 | 94 |
95 | 95 |
96 if __name__ == '__main__': | 96 if __name__ == '__main__': |
97 main() | 97 main() |
OLD | NEW |