Bug 1416052 - Add a wrapper to invoke client.mk; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Thu, 09 Nov 2017 15:50:37 -0800
changeset 436383 13e44d942d707d7bf7a2de4ebed8da9f6759a347
parent 436382 a4cef03e1c9e16e00b37faa0d2455b9b954f11c4
child 436384 7ffce7d50018208119d937c48f99c108b501b397
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersnalexander
bugs1416052
milestone59.0a1
Bug 1416052 - Add a wrapper to invoke client.mk; r=nalexander We're about to start moving logic from client.mk into Python. The transition will require doing things like setting environment variables when we invoke client.mk. Prepare for this by factoring the "call client.mk" logic into a reusable function. The function will obviously be temporary until client.mk is no more. I'm not sure what the end state will be yet. But surely having equivalent code in Python is better than having it in make. MozReview-Commit-ID: F15DxXSV8V3
python/mozbuild/mozbuild/controller/building.py
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -1112,20 +1112,20 @@ class BuildDriver(MozbuildObject):
                     active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
                     if active_backend:
                         backend_cls = get_backend_class(active_backend)(config)
                         status = backend_cls.build(self, output, jobs, verbose)
 
                 # If the backend doesn't specify a build() method, then just
                 # call client.mk directly.
                 if status is None:
-                    status = self._run_make(srcdir=True, filename='client.mk',
-                        line_handler=output.on_line, log=False, print_directory=False,
-                        allow_parallel=False, ensure_exit_code=False, num_jobs=jobs,
-                        silent=not verbose, keep_going=keep_going)
+                    status = self._run_client_mk(line_handler=output.on_line,
+                                                 jobs=jobs,
+                                                 verbose=verbose,
+                                                 keep_going=keep_going)
 
                 self.log(logging.WARNING, 'warning_summary',
                     {'count': len(monitor.warnings_database)},
                     '{count} compiler warnings present.')
 
             monitor.finish(record_usage=status == 0)
 
         # Print the collected compiler warnings. This is redundant with
@@ -1284,20 +1284,19 @@ class BuildDriver(MozbuildObject):
 
         options = ' '.join(shell_quote(o) for o in options or ())
         append_env = {b'CONFIGURE_ARGS': options.encode('utf-8')}
 
         # Only print build status messages when we have an active
         # monitor.
         if not buildstatus_messages:
             append_env[b'NO_BUILDSTATUS_MESSAGES'] =  b'1'
-        status = self._run_make(srcdir=True, filename='client.mk',
-            target='configure', line_handler=line_handler, log=False,
-            print_directory=False, allow_parallel=False, ensure_exit_code=False,
-            append_env=append_env)
+        status = self._run_client_mk(target='configure',
+                                     line_handler=line_handler,
+                                     append_env=append_env)
 
         if not status:
             print('Configure complete!')
             print('Be sure to run |mach build| to pick up any changes');
 
         return status
 
     def install_tests(self, test_objs):
@@ -1311,8 +1310,23 @@ class BuildDriver(MozbuildObject):
         if not test_objs:
             # 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):
+        return self._run_make(srcdir=True,
+                              filename='client.mk',
+                              allow_parallel=False,
+                              ensure_exit_code=False,
+                              print_directory=False,
+                              target=target,
+                              line_handler=line_handler,
+                              log=False,
+                              num_jobs=jobs,
+                              silent=not verbose,
+                              keep_going=keep_going,
+                              append_env=append_env)