aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CLOBBER8
-rw-r--r--python/servo/build_commands.py11
-rw-r--r--python/servo/command_base.py27
3 files changed, 42 insertions, 4 deletions
diff --git a/CLOBBER b/CLOBBER
new file mode 100644
index 00000000000..bd5a74d5625
--- /dev/null
+++ b/CLOBBER
@@ -0,0 +1,8 @@
+# To trigger a clobber replace ALL of the textual description below,
+# giving a pull request number and a one line description of why a clobber is
+# required.
+#
+# Modifying this file will now automatically clobber the buildbot machines \o/
+#
+
+Pull 16722 - Added CLOBBER file
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py
index 3a33f5f3b0d..73c5bd9572d 100644
--- a/python/servo/build_commands.py
+++ b/python/servo/build_commands.py
@@ -24,7 +24,7 @@ from mach.decorators import (
Command,
)
-from servo.command_base import CommandBase, cd, call, BIN_SUFFIX
+from servo.command_base import CommandBase, cd, call, check_call, BIN_SUFFIX
from servo.util import host_triple
@@ -228,6 +228,7 @@ class MachCommands(CommandBase):
opts += ["--target", target]
self.ensure_bootstrapped(target=target)
+ self.ensure_clobbered()
if debug_mozjs:
features += ["debugmozjs"]
@@ -360,6 +361,7 @@ class MachCommands(CommandBase):
def build_cef(self, jobs=None, verbose=False, release=False,
with_debug_assertions=False):
self.ensure_bootstrapped()
+ self.ensure_clobbered()
ret = None
opts = []
@@ -411,6 +413,7 @@ class MachCommands(CommandBase):
def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=False):
self.set_use_stable_rust()
self.ensure_bootstrapped()
+ self.ensure_clobbered()
env = self.build_env(is_build=True, geckolib=True)
@@ -455,7 +458,7 @@ class MachCommands(CommandBase):
help='Print verbose output')
@CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Cargo")
- def clean(self, manifest_path, params, verbose=False):
+ def clean(self, manifest_path=None, params=[], verbose=False):
self.ensure_bootstrapped()
opts = []
@@ -464,5 +467,5 @@ class MachCommands(CommandBase):
if verbose:
opts += ["-v"]
opts += params
- return call(["cargo", "clean"] + opts,
- env=self.build_env(), cwd=self.servo_crate(), verbose=verbose)
+ return check_call(["cargo", "clean"] + opts,
+ env=self.build_env(), cwd=self.servo_crate(), verbose=verbose)
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.")