Bug 1497359 - Detect and reject re-use of objdirs between Make and Tup in configure. r=froydnj
authorChris Manchester <cmanchester@mozilla.com>
Thu, 11 Oct 2018 19:16:49 +0000
changeset 489132 8878ac1f9f36c00d902b7a5d4e636ffbbc9217de
parent 489131 d1c5f2c89b170fc8f60e1b81da1f22d5218dd706
child 489133 7a275e7abf9b88e0d70a14e5a3dea3a7a8ce21e0
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersfroydnj
bugs1497359
milestone64.0a1
Bug 1497359 - Detect and reject re-use of objdirs between Make and Tup in configure. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D8289
moz.configure
python/mozbuild/mozbuild/controller/building.py
--- a/moz.configure
+++ b/moz.configure
@@ -282,16 +282,37 @@ option('--build-backends', nargs='+', de
        choices=build_backends_choices, help='Build backends to generate')
 
 @depends('--build-backends')
 def build_backends(backends):
     return backends
 
 set_config('BUILD_BACKENDS', build_backends)
 
+
+@depends(check_build_environment, build_backends)
+@imports('glob')
+def check_objdir_backend_reuse(build_env, backends):
+    # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
+    # intentionally vague for use with the substring match below.
+    incompatible_backends = (
+        ('Tup', 'Make'),
+        ('Make', 'Tup')
+    )
+    for backend_file in glob.iglob(os.path.join(build_env.topobjdir,
+                                                'backend.*Backend')):
+        for prev, curr in incompatible_backends:
+            if prev in backend_file and any(curr in b for b in backends):
+                die("The active objdir, %s, was previously "
+                    "used to build with a %s based backend. "
+                    "Change objdirs (by setting MOZ_OBJDIR in "
+                    "your mozconfig) or clobber to continue.\n",
+                    build_env.topobjdir, prev)
+
+
 option('--disable-gtest-in-build',
        help='Force disable building the gtest libxul during the build.',
        when='--enable-compile-environment')
 
 # Determine whether to build the gtest xul. This happens in automation
 # on Desktop platforms with the exception of Windows PGO, where linking
 # xul-gtest.dll takes too long.
 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -1045,26 +1045,16 @@ class BuildDriver(MozbuildObject):
                 if config_rc != 0:
                     return config_rc
 
                 config = self.config_environment
 
             status = None
             active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
             if active_backend and 'Make' not in active_backend:
-                for backend_file in glob.iglob(mozpath.join(self.topobjdir,
-                                                            'backend.*Backend')):
-                    if 'Make' in backend_file:
-                        self.log(logging.ERROR, 'backend',
-                                 {'objdir': self.topobjdir},
-                                 "The active objdir, {objdir}, was previously "
-                                 "used to build with a Make-based backend. "
-                                 "Change objdirs (by setting MOZ_OBJDIR in "
-                                 "your mozconfig) to continue.\n")
-                        return 1
                 # Record whether a clobber was requested so we can print
                 # a special message later if the build fails.
                 clobber_requested = False
                 # Write out any changes to the current mozconfig in case
                 # they should invalidate configure.
                 self._write_mozconfig_json()
                 # Even if we have a config object, it may be out of date
                 # if something that influences its result has changed.