| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project 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 """ | 6 """ |
| 7 This script runs every build as the first hook (See DEPS). If it detects that | 7 This script runs every build as the first hook (See DEPS). If it detects that |
| 8 the build should be clobbered, it will delete the contents of the build | 8 the build should be clobbered, it will delete the contents of the build |
| 9 directory. | 9 directory. |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 os.makedirs(out_dir) | 158 os.makedirs(out_dir) |
| 159 except OSError as e: | 159 except OSError as e: |
| 160 if e.errno == errno.EEXIST: | 160 if e.errno == errno.EEXIST: |
| 161 pass | 161 pass |
| 162 | 162 |
| 163 if needs_clobber(landmines_path, new_landmines): | 163 if needs_clobber(landmines_path, new_landmines): |
| 164 # Clobber contents of build directory but not directory itself: some | 164 # Clobber contents of build directory but not directory itself: some |
| 165 # checkouts have the build directory mounted. | 165 # checkouts have the build directory mounted. |
| 166 for f in os.listdir(out_dir): | 166 for f in os.listdir(out_dir): |
| 167 path = os.path.join(out_dir, f) | 167 path = os.path.join(out_dir, f) |
| 168 # Soft version of chromium's clobber. Only delete directories not files | 168 if os.path.basename(out_dir) == 'build': |
| 169 # as e.g. on windows the output dir is the build dir that shares some | 169 # Soft version of chromium's clobber. Only delete build directories not |
| 170 # checked out files. | 170 # files in windows' build dir as the folder shares some checked out |
| 171 if os.path.isdir(path) and re.search(r"(?:[Rr]elease)|(?:[Dd]ebug)", f): | 171 # files and directories. |
| 172 delete_build_dir(path) | 172 if (os.path.isdir(path) and |
| 173 re.search(r'(?:[Rr]elease)|(?:[Dd]ebug)', f)): |
| 174 delete_build_dir(path) |
| 175 else: |
| 176 if os.path.isfile(path): |
| 177 os.unlink(path) |
| 178 elif os.path.isdir(path): |
| 179 delete_build_dir(path) |
| 173 | 180 |
| 174 # Save current set of landmines for next time. | 181 # Save current set of landmines for next time. |
| 175 with open(landmines_path, 'w') as f: | 182 with open(landmines_path, 'w') as f: |
| 176 f.writelines(new_landmines) | 183 f.writelines(new_landmines) |
| 177 | 184 |
| 178 | 185 |
| 179 def process_options(): | 186 def process_options(): |
| 180 """Returns a list of landmine emitting scripts.""" | 187 """Returns a list of landmine emitting scripts.""" |
| 181 parser = optparse.OptionParser() | 188 parser = optparse.OptionParser() |
| 182 parser.add_option( | 189 parser.add_option( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) | 226 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) |
| 220 output, _ = proc.communicate() | 227 output, _ = proc.communicate() |
| 221 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) | 228 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) |
| 222 clobber_if_necessary(landmines) | 229 clobber_if_necessary(landmines) |
| 223 | 230 |
| 224 return 0 | 231 return 0 |
| 225 | 232 |
| 226 | 233 |
| 227 if __name__ == '__main__': | 234 if __name__ == '__main__': |
| 228 sys.exit(main()) | 235 sys.exit(main()) |
| OLD | NEW |