OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """This script provides methods for clobbering build directories.""" | 6 """This script provides methods for clobbering build directories.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 19 matching lines...) Expand all Loading... |
30 line = f.readline() | 30 line = f.readline() |
31 if len(line) == 0: | 31 if len(line) == 0: |
32 return '' # Unexpected EOF. | 32 return '' # Unexpected EOF. |
33 result += line | 33 result += line |
34 if line[0] == '\n': | 34 if line[0] == '\n': |
35 num_blank_lines = num_blank_lines + 1 | 35 num_blank_lines = num_blank_lines + 1 |
36 return result | 36 return result |
37 | 37 |
38 | 38 |
39 def delete_dir(build_dir): | 39 def delete_dir(build_dir): |
| 40 if os.path.islink(build_dir): |
| 41 return |
40 # For unknown reasons (anti-virus?) rmtree of Chromium build directories | 42 # For unknown reasons (anti-virus?) rmtree of Chromium build directories |
41 # often fails on Windows. | 43 # often fails on Windows. |
42 if sys.platform.startswith('win'): | 44 if sys.platform.startswith('win'): |
43 subprocess.check_call(['rmdir', '/s', '/q', build_dir], shell=True) | 45 subprocess.check_call(['rmdir', '/s', '/q', build_dir], shell=True) |
44 else: | 46 else: |
45 shutil.rmtree(build_dir) | 47 shutil.rmtree(build_dir) |
46 | 48 |
47 | 49 |
48 def delete_build_dir(build_dir): | 50 def delete_build_dir(build_dir): |
49 # GN writes a build.ninja.d file. Note that not all GN builds have args.gn. | 51 # GN writes a build.ninja.d file. Note that not all GN builds have args.gn. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 def main(): | 123 def main(): |
122 parser = argparse.ArgumentParser() | 124 parser = argparse.ArgumentParser() |
123 parser.add_argument('out_dir', help='The output directory to clobber') | 125 parser.add_argument('out_dir', help='The output directory to clobber') |
124 args = parser.parse_args() | 126 args = parser.parse_args() |
125 clobber(args.out_dir) | 127 clobber(args.out_dir) |
126 return 0 | 128 return 0 |
127 | 129 |
128 | 130 |
129 if __name__ == '__main__': | 131 if __name__ == '__main__': |
130 sys.exit(main()) | 132 sys.exit(main()) |
OLD | NEW |