| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 from build_paths import SDK_SRC_DIR | 11 import build_version |
| 12 from build_paths import SDK_SRC_DIR, SCRIPT_DIR, OUT_DIR |
| 12 | 13 |
| 13 # Add SDK make tools scripts to the python path. | 14 # Add SDK make tools scripts to the python path. |
| 14 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 15 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
| 15 | 16 |
| 16 import getos | 17 import getos |
| 17 | 18 |
| 18 VALID_PLATFORMS = ['linux', 'mac', 'win'] | 19 VALID_PLATFORMS = ['linux', 'mac', 'win'] |
| 19 PLATFORM_PREFIX_RE = re.compile(r'^\[([^\]]*)\](.*)$') | 20 PLATFORM_PREFIX_RE = re.compile(r'^\[([^\]]*)\](.*)$') |
| 20 | 21 |
| 21 class ParseException(Exception): | 22 class ParseException(Exception): |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 182 |
| 182 | 183 |
| 183 def main(args): | 184 def main(args): |
| 184 parser = optparse.OptionParser(usage='%prog <rule file> <directory>') | 185 parser = optparse.OptionParser(usage='%prog <rule file> <directory>') |
| 185 parser.add_option('-p', '--platform', | 186 parser.add_option('-p', '--platform', |
| 186 help='Test with this platform, instead of the system\'s platform') | 187 help='Test with this platform, instead of the system\'s platform') |
| 187 parser.add_option('-s', '--sort', action='store_true', | 188 parser.add_option('-s', '--sort', action='store_true', |
| 188 help='Sort the file list in place, rather than verifying the contents.') | 189 help='Sort the file list in place, rather than verifying the contents.') |
| 189 options, args = parser.parse_args(args) | 190 options, args = parser.parse_args(args) |
| 190 | 191 |
| 192 if not args: |
| 193 args = [os.path.join(SCRIPT_DIR, 'sdk_files.list')] |
| 194 |
| 191 if options.sort: | 195 if options.sort: |
| 192 if not args: | 196 if not args: |
| 193 parser.error('Expected rule file.') | 197 parser.error('Expected rule file.') |
| 194 SortFile(args[0]) | 198 SortFile(args[0]) |
| 195 return 0 | 199 return 0 |
| 196 | 200 |
| 197 if len(args) != 2: | 201 if len(args) < 2: |
| 198 parser.error('Expected rule file and directory.') | 202 version = build_version.ChromeMajorVersion() |
| 203 args.append(os.path.join(OUT_DIR, 'pepper_%s' % version)) |
| 199 | 204 |
| 200 rule_path, directory_path = args | 205 rule_path, directory_path = args |
| 201 if options.platform: | 206 if options.platform: |
| 202 if options.platform not in VALID_PLATFORMS: | 207 if options.platform not in VALID_PLATFORMS: |
| 203 parser.error('Unknown platform: %s' % options.platform) | 208 parser.error('Unknown platform: %s' % options.platform) |
| 204 platform = options.platform | 209 platform = options.platform |
| 205 else: | 210 else: |
| 206 platform = getos.GetPlatform() | 211 platform = getos.GetPlatform() |
| 207 | 212 |
| 208 try: | 213 try: |
| 209 return Verify(rule_path, directory_path, platform) | 214 return Verify(rule_path, directory_path, platform) |
| 210 except ParseException, e: | 215 except ParseException, e: |
| 211 print >> sys.stderr, 'Error parsing rules:\n', e | 216 print >> sys.stderr, 'Error parsing rules:\n', e |
| 212 return 1 | 217 return 1 |
| 213 except VerifyException, e: | 218 except VerifyException, e: |
| 214 print >> sys.stderr, 'Error verifying file list:\n', e | 219 print >> sys.stderr, 'Error verifying file list:\n', e |
| 215 return 1 | 220 return 1 |
| 216 return 0 | 221 return 0 |
| 217 | 222 |
| 218 | 223 |
| 219 if __name__ == '__main__': | 224 if __name__ == '__main__': |
| 220 sys.exit(main(sys.argv[1:])) | 225 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |