зеркало из https://github.com/mozilla/gecko-dev.git
Bug 863091 - Make auto clobbering opt-in rather than opt-out; r=glandium
To avoid surprises for devs building locally, auto clobbering is now opt-in, via the use of |mk_add_options AUTOCLOBBER=1| in the mozconfig. Our automation uses build/mozconfig.common which specifies this, so auto clobber will remain enabled for our buildbot machines.
This commit is contained in:
Родитель
8f22491495
Коммит
d46314dc33
|
@ -9,3 +9,5 @@
|
||||||
# architectures, though note that if you want to override options set in
|
# architectures, though note that if you want to override options set in
|
||||||
# another mozconfig file, you'll need to use mozconfig.common.override instead
|
# another mozconfig file, you'll need to use mozconfig.common.override instead
|
||||||
# of this file.
|
# of this file.
|
||||||
|
|
||||||
|
mk_add_options AUTOCLOBBER=1
|
||||||
|
|
|
@ -108,8 +108,8 @@ endef
|
||||||
# before evaluation.
|
# before evaluation.
|
||||||
$(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
|
$(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
|
||||||
|
|
||||||
ifdef NO_AUTOCLOBBER
|
ifdef AUTOCLOBBER
|
||||||
export NO_AUTOCLOBBER=1
|
export AUTOCLOBBER=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Automatically add -jN to make flags if not defined. N defaults to number of cores.
|
# Automatically add -jN to make flags if not defined. N defaults to number of cores.
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Clobberer(object):
|
||||||
with open(self.obj_clobber, 'a'):
|
with open(self.obj_clobber, 'a'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def maybe_do_clobber(self, cwd, allow_auto=True, fh=sys.stderr):
|
def maybe_do_clobber(self, cwd, allow_auto=False, fh=sys.stderr):
|
||||||
"""Perform a clobber if it is required. Maybe.
|
"""Perform a clobber if it is required. Maybe.
|
||||||
|
|
||||||
This is the API the build system invokes to determine if a clobber
|
This is the API the build system invokes to determine if a clobber
|
||||||
|
@ -120,15 +120,15 @@ class Clobberer(object):
|
||||||
return False, False, None
|
return False, False, None
|
||||||
|
|
||||||
# So a clobber is needed. We only perform a clobber if we are
|
# So a clobber is needed. We only perform a clobber if we are
|
||||||
# allowed to perform an automatic clobber (the default) and if the
|
# allowed to perform an automatic clobber (off by default) and if the
|
||||||
# current directory is not under the object directory. The latter is
|
# current directory is not under the object directory. The latter is
|
||||||
# because operating systems, filesystems, and shell can throw fits
|
# because operating systems, filesystems, and shell can throw fits
|
||||||
# if the current working directory is deleted from under you. While it
|
# if the current working directory is deleted from under you. While it
|
||||||
# can work in some scenarios, we take the conservative approach and
|
# can work in some scenarios, we take the conservative approach and
|
||||||
# never try.
|
# never try.
|
||||||
if not allow_auto:
|
if not allow_auto:
|
||||||
return True, False, self._message(
|
return True, False, self._message('Automatic clobbering is not '
|
||||||
'Automatic clobbering has been disabled.')
|
'enabled (add "mk_add_options AUTOCLOBBER=1" to your mozconfig).')
|
||||||
|
|
||||||
if cwd.startswith(self.topobjdir) and cwd != self.topobjdir:
|
if cwd.startswith(self.topobjdir) and cwd != self.topobjdir:
|
||||||
return True, False, self._message(
|
return True, False, self._message(
|
||||||
|
@ -175,7 +175,7 @@ def main(args, env, cwd, fh=sys.stderr):
|
||||||
if not os.path.isabs(topobjdir):
|
if not os.path.isabs(topobjdir):
|
||||||
topobjdir = os.path.abspath(topobjdir)
|
topobjdir = os.path.abspath(topobjdir)
|
||||||
|
|
||||||
auto = False if env.get('NO_AUTOCLOBBER', False) else True
|
auto = True if env.get('AUTOCLOBBER', False) else False
|
||||||
clobber = Clobberer(topsrcdir, topobjdir)
|
clobber = Clobberer(topsrcdir, topobjdir)
|
||||||
required, performed, message = clobber.maybe_do_clobber(cwd, auto, fh)
|
required, performed, message = clobber.maybe_do_clobber(cwd, auto, fh)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class TestClobberer(unittest.TestCase):
|
||||||
self.assertFalse(c.clobber_needed())
|
self.assertFalse(c.clobber_needed())
|
||||||
|
|
||||||
# Side-effect is topobjdir is created with CLOBBER file touched.
|
# Side-effect is topobjdir is created with CLOBBER file touched.
|
||||||
required, performed, reason = c.maybe_do_clobber(os.getcwd())
|
required, performed, reason = c.maybe_do_clobber(os.getcwd(), True)
|
||||||
self.assertFalse(required)
|
self.assertFalse(required)
|
||||||
self.assertFalse(performed)
|
self.assertFalse(performed)
|
||||||
self.assertIsNone(reason)
|
self.assertIsNone(reason)
|
||||||
|
@ -66,7 +66,7 @@ class TestClobberer(unittest.TestCase):
|
||||||
c = Clobberer(self.get_topsrcdir(), self.get_tempdir())
|
c = Clobberer(self.get_topsrcdir(), self.get_tempdir())
|
||||||
self.assertFalse(c.clobber_needed())
|
self.assertFalse(c.clobber_needed())
|
||||||
|
|
||||||
required, performed, reason = c.maybe_do_clobber(os.getcwd())
|
required, performed, reason = c.maybe_do_clobber(os.getcwd(), True)
|
||||||
self.assertFalse(required)
|
self.assertFalse(required)
|
||||||
self.assertFalse(performed)
|
self.assertFalse(performed)
|
||||||
self.assertIsNone(reason)
|
self.assertIsNone(reason)
|
||||||
|
@ -80,7 +80,7 @@ class TestClobberer(unittest.TestCase):
|
||||||
with open(c.obj_clobber, 'a'):
|
with open(c.obj_clobber, 'a'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
required, performed, reason = c.maybe_do_clobber(os.getcwd())
|
required, performed, reason = c.maybe_do_clobber(os.getcwd(), True)
|
||||||
self.assertFalse(required)
|
self.assertFalse(required)
|
||||||
self.assertFalse(performed)
|
self.assertFalse(performed)
|
||||||
self.assertIsNone(reason)
|
self.assertIsNone(reason)
|
||||||
|
@ -103,13 +103,7 @@ class TestClobberer(unittest.TestCase):
|
||||||
|
|
||||||
self.assertTrue(c.clobber_needed())
|
self.assertTrue(c.clobber_needed())
|
||||||
|
|
||||||
required, performed, reason = c.maybe_do_clobber(os.getcwd(), False)
|
required, performed, reason = c.maybe_do_clobber(os.getcwd(), True)
|
||||||
self.assertTrue(required)
|
|
||||||
self.assertFalse(performed)
|
|
||||||
self.assertIn('Automatic clobbering has been disabled', reason)
|
|
||||||
|
|
||||||
# Now let's actually do it.
|
|
||||||
required, performed, reason = c.maybe_do_clobber(os.getcwd())
|
|
||||||
self.assertTrue(required)
|
self.assertTrue(required)
|
||||||
self.assertTrue(performed)
|
self.assertTrue(performed)
|
||||||
|
|
||||||
|
@ -148,7 +142,7 @@ class TestClobberer(unittest.TestCase):
|
||||||
|
|
||||||
self.assertTrue(c.clobber_needed())
|
self.assertTrue(c.clobber_needed())
|
||||||
|
|
||||||
required, performed, reason = c.maybe_do_clobber(c.topobjdir)
|
required, performed, reason = c.maybe_do_clobber(c.topobjdir, True)
|
||||||
self.assertTrue(required)
|
self.assertTrue(required)
|
||||||
self.assertTrue(performed)
|
self.assertTrue(performed)
|
||||||
|
|
||||||
|
@ -169,14 +163,14 @@ class TestClobberer(unittest.TestCase):
|
||||||
d = os.path.join(c.topobjdir, 'dummy_dir')
|
d = os.path.join(c.topobjdir, 'dummy_dir')
|
||||||
os.mkdir(d)
|
os.mkdir(d)
|
||||||
|
|
||||||
required, performed, reason = c.maybe_do_clobber(d)
|
required, performed, reason = c.maybe_do_clobber(d, True)
|
||||||
self.assertTrue(required)
|
self.assertTrue(required)
|
||||||
self.assertFalse(performed)
|
self.assertFalse(performed)
|
||||||
self.assertIn('Cannot clobber while the shell is inside', reason)
|
self.assertIn('Cannot clobber while the shell is inside', reason)
|
||||||
|
|
||||||
|
|
||||||
def test_mozconfig_overrides_auto_clobber(self):
|
def test_mozconfig_opt_in(self):
|
||||||
"""If NO_AUTOCLOBBER is in the environment, don't auto clobber."""
|
"""Auto clobber iff AUTOCLOBBER is in the environment."""
|
||||||
|
|
||||||
topsrcdir = self.get_topsrcdir()
|
topsrcdir = self.get_topsrcdir()
|
||||||
topobjdir = self.get_tempdir()
|
topobjdir = self.get_tempdir()
|
||||||
|
@ -194,15 +188,26 @@ class TestClobberer(unittest.TestCase):
|
||||||
old_time = os.path.getmtime(os.path.join(topsrcdir, 'CLOBBER')) - 60
|
old_time = os.path.getmtime(os.path.join(topsrcdir, 'CLOBBER')) - 60
|
||||||
os.utime(obj_clobber, (old_time, old_time))
|
os.utime(obj_clobber, (old_time, old_time))
|
||||||
|
|
||||||
|
# Check auto clobber is off by default
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env['NO_AUTOCLOBBER'] = '1'
|
if env.get('AUTOCLOBBER', False):
|
||||||
|
del env['AUTOCLOBBER']
|
||||||
|
|
||||||
s = StringIO()
|
s = StringIO()
|
||||||
status = clobber([topsrcdir, topobjdir], env, os.getcwd(), s)
|
status = clobber([topsrcdir, topobjdir], env, os.getcwd(), s)
|
||||||
self.assertEqual(status, 1)
|
self.assertEqual(status, 1)
|
||||||
self.assertIn('Automatic clobbering has been disabled', s.getvalue())
|
self.assertIn('Automatic clobbering is not enabled', s.getvalue())
|
||||||
self.assertTrue(os.path.exists(dummy_file))
|
self.assertTrue(os.path.exists(dummy_file))
|
||||||
|
|
||||||
|
# Check auto clobber opt-in works
|
||||||
|
env['AUTOCLOBBER'] = '1'
|
||||||
|
|
||||||
|
s = StringIO()
|
||||||
|
status = clobber([topsrcdir, topobjdir], env, os.getcwd(), s)
|
||||||
|
self.assertEqual(status, 1)
|
||||||
|
self.assertIn('Successfully completed auto clobber', s.getvalue())
|
||||||
|
self.assertFalse(os.path.exists(dummy_file))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче