Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Makes sure that all EXE and DLL files in the provided directory were built | 6 """Makes sure that all EXE and DLL files in the provided directory were built |
| 7 correctly. | 7 correctly. |
| 8 | 8 |
| 9 Currently this tool will check that binaries were built with /NXCOMPAT and | 9 Currently this tool will check that binaries were built with /NXCOMPAT and |
| 10 /DYNAMICBASE set. | 10 /DYNAMICBASE set. |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import os | 13 import os |
| 14 import optparse | 14 import optparse |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 # Find /third_party/pefile based on current directory and script path. | |
| 18 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '..', '..', | |
|
M-A Ruel
2009/10/28 19:55:43
Use __file__ instead of sys.argv[0]
| |
| 19 'third_party', 'pefile')) | |
| 17 import pefile | 20 import pefile |
| 18 | 21 |
| 19 PE_FILE_EXTENSIONS = ['.exe', '.dll'] | 22 PE_FILE_EXTENSIONS = ['.exe', '.dll'] |
| 20 DYNAMICBASE_FLAG = 0x0040 | 23 DYNAMICBASE_FLAG = 0x0040 |
| 21 NXCOMPAT_FLAG = 0x0100 | 24 NXCOMPAT_FLAG = 0x0100 |
| 22 | 25 |
| 23 def IsPEFile(path): | 26 def IsPEFile(path): |
| 24 return (os.path.isfile(path) and | 27 return (os.path.isfile(path) and |
| 25 os.path.splitext(path)[1].lower() in PE_FILE_EXTENSIONS) | 28 os.path.splitext(path)[1].lower() in PE_FILE_EXTENSIONS) |
| 26 | 29 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 56 if __name__ == '__main__': | 59 if __name__ == '__main__': |
| 57 usage = "Usage: %prog [options] DIRECTORY" | 60 usage = "Usage: %prog [options] DIRECTORY" |
| 58 option_parser = optparse.OptionParser(usage=usage) | 61 option_parser = optparse.OptionParser(usage=usage) |
| 59 option_parser.add_option("-v", "--verbose", action="store_true", | 62 option_parser.add_option("-v", "--verbose", action="store_true", |
| 60 default=False, help="Print debug logging") | 63 default=False, help="Print debug logging") |
| 61 options, args = option_parser.parse_args() | 64 options, args = option_parser.parse_args() |
| 62 if not args: | 65 if not args: |
| 63 option_parser.print_help() | 66 option_parser.print_help() |
| 64 sys.exit(0) | 67 sys.exit(0) |
| 65 main(options, args) | 68 main(options, args) |
| OLD | NEW |