aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/command_base.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-08 23:53:05 -0500
committerGitHub <noreply@github.com>2017-05-08 23:53:05 -0500
commit9c9bd178713a1def9bec57e7f96e3365252c0f88 (patch)
tree7f5a9d9c0a837e51f58474a1822e3377f2427d9c /python/servo/command_base.py
parentfc3a7d03f2b0c5292e7414e7555fb75ae0b1d663 (diff)
parentd03e52d2405a1b9149e9fc6c86f056525cd7c18d (diff)
downloadservo-9c9bd178713a1def9bec57e7f96e3365252c0f88.tar.gz
servo-9c9bd178713a1def9bec57e7f96e3365252c0f88.zip
Auto merge of #16722 - UK992:clobber, r=SimonSapin
Add clobber mechanism Solution for https://github.com/servo/servo/issues/16602 and https://github.com/servo/servo/issues/16632 Only work when `AUTOCLOBBER` environment variable is defined. CC @SimonSapin @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16722) <!-- Reviewable:end -->
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r--python/servo/command_base.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index be275347007..7ab5191b41a 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -574,3 +574,30 @@ class CommandBase(object):
Registrar.dispatch("bootstrap-cargo", context=self.context)
self.context.bootstrapped = True
+
+ def ensure_clobbered(self, target_dir=None):
+ if target_dir is None:
+ target_dir = self.get_target_dir()
+ auto = True if os.environ.get('AUTOCLOBBER', False) else False
+ src_clobber = os.path.join(self.context.topdir, 'CLOBBER')
+ target_clobber = os.path.join(target_dir, 'CLOBBER')
+
+ if not os.path.exists(target_dir):
+ os.makedirs(target_dir)
+
+ if not os.path.exists(target_clobber):
+ # Simply touch the file.
+ with open(target_clobber, 'a'):
+ pass
+
+ if auto:
+ if os.path.getmtime(src_clobber) > os.path.getmtime(target_clobber):
+ print('Automatically clobbering target directory: {}'.format(target_dir))
+
+ try:
+ Registrar.dispatch("clean", context=self.context, verbose=True)
+ print('Successfully completed auto clobber.')
+ except subprocess.CalledProcessError as error:
+ sys.exit(error)
+ else:
+ print("Clobber not needed.")