Bug 1417684 - Prepare the object directory earlier; r?build draft
authorGregory Szorc <gps@mozilla.com>
Thu, 16 Nov 2017 18:49:15 -0800
changeset 700681 164959135d2ba6ab5e28293bf95cd09b0b103b9d
parent 700680 6f70900c5d4f001d4e709d6bd21c258dda09eef8
child 700682 786dc3581cbf0f9964e1bcd6c78e54fab124c062
push id89935
push userbmo:gps@mozilla.com
push dateMon, 20 Nov 2017 19:05:20 +0000
reviewersbuild
bugs1417684
milestone59.0a1
Bug 1417684 - Prepare the object directory earlier; r?build The code in _run_client_mk() was extracted from client.mk. So far, the bulk of that code deals with initializing the objdir. Future patches uncovered some wonkiness with the ordering of the execution of this code. In this commit, we split out the code for preparing the object directory into its own function. We then call this function very early in the build process. This ensures that files like .mozconfig.json are present and accessible more often. FWIW, I heard glandium say he would like configure to create the objdir. This would presumably also entail configure managing files like .mozconfig.json. I'm not opposed to this idea. However, changing that right now is difficult since things are changing so fast. Let's get functionality out of client.mk then clean things up later. MozReview-Commit-ID: JyvhwJK51Vp
python/mozbuild/mozbuild/controller/building.py
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -992,19 +992,18 @@ class BuildDriver(MozbuildObject):
         target is used.
         """
         warnings_path = self._get_state_filename('warnings.json')
         monitor = self._spawn(BuildMonitor)
         monitor.init(warnings_path)
         ccache_start = monitor.ccache_stats()
         footer = BuildProgressFooter(self.log_manager.terminal, monitor)
 
-        # Disable indexing in objdir because it is not necessary and can slow
-        # down builds.
-        mkdir(self.topobjdir, not_indexed=True)
+        if self._prepare_objdir():
+            return 1
 
         with BuildOutputManager(self.log_manager, monitor, footer) as output:
             monitor.start()
 
             if directory is not None and not what:
                 print('Can only use -C/--directory with an explicit target '
                     'name.')
                 return 1
@@ -1269,19 +1268,18 @@ class BuildDriver(MozbuildObject):
                 # Ignore Exceptions in case we can't find config.status (such
                 # as when doing OSX Universal builds)
                 pass
 
         return status
 
     def configure(self, options=None, buildstatus_messages=False,
                   line_handler=None):
-        # Disable indexing in objdir because it is not necessary and can slow
-        # down builds.
-        mkdir(self.topobjdir, not_indexed=True)
+        if self._prepare_objdir():
+            return 1
 
         def on_line(line):
             self.log(logging.INFO, 'build_output', {'line': line}, '{line}')
 
         line_handler = line_handler or on_line
 
         options = ' '.join(shell_quote(o) for o in options or ())
         append_env = {b'CONFIGURE_ARGS': options.encode('utf-8')}
@@ -1312,27 +1310,30 @@ class BuildDriver(MozbuildObject):
             # If we don't actually have a list of tests to install we install
             # test and support files wholesale.
             self._run_make(target='install-test-files', pass_thru=True,
                            print_directory=False)
         else:
             install_test_files(mozpath.normpath(self.topsrcdir), self.topobjdir,
                                '_tests', test_objs)
 
-    def _run_client_mk(self, target=None, line_handler=None, jobs=0,
-                       verbose=None, keep_going=False, append_env=None):
-        append_env = dict(append_env or {})
-        append_env['TOPSRCDIR'] = self.topsrcdir
+    def _prepare_objdir(self):
+        """Prepare the objdir for performing a build.
 
-        append_env['CONFIG_GUESS'] = self.resolve_config_guess()
-
+        This essentially puts things into place that allow us to invoke
+        client.mk.
+        """
         mozconfig = self.mozconfig
 
         if self._check_clobber(mozconfig, os.environ):
-            return 1
+            return True
+
+        # Disable indexing in objdir because it is not necessary and can slow
+        # down builds.
+        mkdir(self.topobjdir, not_indexed=True)
 
         mozconfig_make_lines = []
         for arg in mozconfig['make_extra'] or []:
             mozconfig_make_lines.append(arg)
 
         if mozconfig['make_flags']:
             mozconfig_make_lines.append(b'MOZ_MAKE_FLAGS=%s' %
                                         b' '.join(mozconfig['make_flags']))
@@ -1380,16 +1381,21 @@ class BuildDriver(MozbuildObject):
                     raise
 
         if mozconfig_make_lines:
             self.log(logging.WARNING, 'mozconfig_content', {
                 'path': mozconfig['path'],
                 'content': '\n    '.join(mozconfig_make_lines),
             }, 'Adding make options from {path}\n    {content}')
 
+    def _run_client_mk(self, target=None, line_handler=None, jobs=0,
+                       verbose=None, keep_going=False, append_env=None):
+        append_env = dict(append_env or {})
+        append_env['TOPSRCDIR'] = self.topsrcdir
+        append_env['CONFIG_GUESS'] = self.resolve_config_guess()
         append_env['OBJDIR'] = mozpath.normsep(self.topobjdir)
 
         return self._run_make(srcdir=True,
                               filename='client.mk',
                               allow_parallel=False,
                               ensure_exit_code=False,
                               print_directory=False,
                               target=target,