aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/command_base.py
diff options
context:
space:
mode:
authorUK992 <urbankrajnc92@gmail.com>2017-05-08 16:18:23 +0200
committerUK992 <urbankrajnc92@gmail.com>2017-05-08 16:19:56 +0200
commitd03e52d2405a1b9149e9fc6c86f056525cd7c18d (patch)
treecef49589356a7e9acef6745759490e06bead3675 /python/servo/command_base.py
parenta5fe464e4a2f001ab9b47b1c5c0dd8e3de0fd8e2 (diff)
downloadservo-d03e52d2405a1b9149e9fc6c86f056525cd7c18d.tar.gz
servo-d03e52d2405a1b9149e9fc6c86f056525cd7c18d.zip
Add clobber mechanism
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.")