| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Functions for discovering and clearing the build directory.""" | 5 """Functions for discovering and clearing the build directory.""" |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 # compile, so make sure not to delete those generated files, otherwise | 87 # compile, so make sure not to delete those generated files, otherwise |
| 88 # compile will fail. | 88 # compile will fail. |
| 89 if (f.endswith('.ninja') or f.endswith('.manifest') or | 89 if (f.endswith('.ninja') or f.endswith('.manifest') or |
| 90 f == 'args.gn' or f == 'mb_type' or f == 'runtime_deps' or | 90 f == 'args.gn' or f == 'mb_type' or f == 'runtime_deps' or |
| 91 f.startswith('msvc') or # VS runtime DLLs. | 91 f.startswith('msvc') or # VS runtime DLLs. |
| 92 f.startswith('pgort') or # VS PGO runtime DLL. | 92 f.startswith('pgort') or # VS PGO runtime DLL. |
| 93 f.startswith('vccorlib') or # VS2015 core libraries. | 93 f.startswith('vccorlib') or # VS2015 core libraries. |
| 94 f.startswith('vcruntime') or # VS2015 runtime libraries. | 94 f.startswith('vcruntime') or # VS2015 runtime libraries. |
| 95 f.startswith('ucrtbase') or # Win runtime DLLs for VS. | 95 f.startswith('ucrtbase') or # Win runtime DLLs for VS. |
| 96 f.startswith('api-ms-win') or # Win runtime DLLs for VS. | 96 f.startswith('api-ms-win') or # Win runtime DLLs for VS. |
| 97 f in ('gyp-mac-tool', 'gyp-win-tool', | 97 f in ('environment.x86', 'environment.x64')): |
| 98 'environment.x86', 'environment.x64')): | |
| 99 continue | 98 continue |
| 100 # Keep goma related files. | 99 # Keep goma related files. |
| 101 if f == '.goma_deps': | 100 if f == '.goma_deps': |
| 102 continue | 101 continue |
| 103 os.unlink(os.path.join(root, f)) | 102 os.unlink(os.path.join(root, f)) |
| 104 # Delete the directory if empty; this works because the walk is bottom-up. | 103 # Delete the directory if empty; this works because the walk is bottom-up. |
| 105 try: | 104 try: |
| 106 os.rmdir(root) | 105 os.rmdir(root) |
| 107 except OSError, e: | 106 except OSError, e: |
| 108 if e.errno in (39, 41, 66): | 107 if e.errno in (39, 41, 66): |
| 109 # If the directory isn't empty, ignore it. | 108 # If the directory isn't empty, ignore it. |
| 110 # On Windows, os.rmdir will raise WindowsError with winerror 145, | 109 # On Windows, os.rmdir will raise WindowsError with winerror 145, |
| 111 # which e.errno is 41. | 110 # which e.errno is 41. |
| 112 # On Linux, e.errno is 39. | 111 # On Linux, e.errno is 39. |
| 113 pass | 112 pass |
| 114 else: | 113 else: |
| 115 raise | 114 raise |
| OLD | NEW |