| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 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 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
| 7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
| 8 | 8 |
| 9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
| 10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 BASEDIR = os.path.dirname(os.path.abspath(__file__)) | 41 BASEDIR = os.path.dirname(os.path.abspath(__file__)) |
| 42 DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') | 42 DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') |
| 43 sys.path.append(DEPOT_TOOLS_PATH) | 43 sys.path.append(DEPOT_TOOLS_PATH) |
| 44 try: | 44 try: |
| 45 import download_from_google_storage | 45 import download_from_google_storage |
| 46 except ImportError: | 46 except ImportError: |
| 47 # Allow use of utility functions in this script from package_from_installed | 47 # Allow use of utility functions in this script from package_from_installed |
| 48 # on bare VM that doesn't have a full depot_tools. | 48 # on bare VM that doesn't have a full depot_tools. |
| 49 pass | 49 pass |
| 50 | 50 |
| 51 if sys.platform != 'cygwin': | |
| 52 import ctypes.wintypes | |
| 53 GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW | |
| 54 GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,) | |
| 55 GetFileAttributes.restype = ctypes.wintypes.DWORD | |
| 56 FILE_ATTRIBUTE_HIDDEN = 0x2 | |
| 57 FILE_ATTRIBUTE_SYSTEM = 0x4 | |
| 58 | |
| 59 | |
| 60 def IsHidden(file_path): | |
| 61 """Returns whether the given |file_path| has the 'system' or 'hidden' | |
| 62 attribute set.""" | |
| 63 p = GetFileAttributes(file_path) | |
| 64 assert p != 0xffffffff | |
| 65 return bool(p & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) | |
| 66 | |
| 67 | 51 |
| 68 def GetFileList(root): | 52 def GetFileList(root): |
| 69 """Gets a normalized list of files under |root|.""" | 53 """Gets a normalized list of files under |root|.""" |
| 70 assert not os.path.isabs(root) | 54 assert not os.path.isabs(root) |
| 71 assert os.path.normpath(root) == root | 55 assert os.path.normpath(root) == root |
| 72 file_list = [] | 56 file_list = [] |
| 73 for base, _, files in os.walk(root): | 57 for base, _, files in os.walk(root): |
| 74 paths = [os.path.join(base, f) for f in files] | 58 paths = [os.path.join(base, f) for f in files] |
| 75 file_list.extend(x.lower() for x in paths if not IsHidden(x)) | 59 file_list.extend(x.lower() for x in paths) |
| 76 return sorted(file_list) | 60 return sorted(file_list) |
| 77 | 61 |
| 78 | 62 |
| 79 def MakeTimestampsFileName(root): | 63 def MakeTimestampsFileName(root): |
| 80 return os.path.join(root, '..', '.timestamps') | 64 return os.path.join(root, '..', '.timestamps') |
| 81 | 65 |
| 82 | 66 |
| 83 def CalculateHash(root): | 67 def CalculateHash(root): |
| 84 """Calculates the sha1 of the paths to all files in the given |root| and the | 68 """Calculates the sha1 of the paths to all files in the given |root| and the |
| 85 contents of those files, and returns as a hex string.""" | 69 contents of those files, and returns as a hex string.""" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 311 |
| 328 if options.output_json: | 312 if options.output_json: |
| 329 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 313 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
| 330 options.output_json) | 314 options.output_json) |
| 331 | 315 |
| 332 return 0 | 316 return 0 |
| 333 | 317 |
| 334 | 318 |
| 335 if __name__ == '__main__': | 319 if __name__ == '__main__': |
| 336 sys.exit(main()) | 320 sys.exit(main()) |
| OLD | NEW |