Bug 1417264 - Write objdir .mozconfig from Python; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Mon, 13 Nov 2017 17:31:14 -0800
changeset 443994 41492b2ba4e147fb22de42989582978d9e624729
parent 443993 523f39e23b7f90c8e91bdc0c275324ac85e21c0a
child 443995 249a8177ad915734b83c357d49213e26d889b377
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1417264 - Write objdir .mozconfig from Python; r=nalexander This is a pretty straightforward port of the logic. But we even go a step further: we delete the file in the objdir if there is no source mozconfig! MozReview-Commit-ID: AHFFzy6mXRY
--- a/client.mk
+++ b/client.mk
@@ -133,34 +133,28 @@ ifeq ($(TOPSRCDIR),$(OBJDIR))
   CONFIGURE = $(TOPSRCDIR)/configure
 configure-files: $(CONFIGURES)
 configure-preqs = \
   configure-files \
-  save-mozconfig \
   $(OBJDIR)/.mozconfig.json \
 CREATE_MOZCONFIG_JSON = $(shell $(TOPSRCDIR)/mach environment --format=json -o $(OBJDIR)/.mozconfig.json)
 # Force CREATE_MOZCONFIG_JSON above to be resolved, without side effects in
 # case the result is non empty, and allowing an override on the make command
 # line not running the command (using := $(shell) still runs the shell command).
 $(OBJDIR)/.mozconfig.json: ;
-save-mozconfig: $(FOUND_MOZCONFIG)
-	-cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
 configure:: $(configure-preqs)
 	$(call BUILDSTATUS,TIERS configure)
 	$(call BUILDSTATUS,TIER_START configure)
 	@echo cd $(OBJDIR);
 	  || ( echo '*** Fix above errors and then restart with\
                "$(MAKE) -f client.mk build"' && exit 1 )
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import, unicode_literals
+import errno
 import getpass
 import io
 import json
 import logging
 import os
 import subprocess
 import sys
 import time
@@ -1366,16 +1367,29 @@ class BuildDriver(MozbuildObject):
         with FileAvoidWrite(mozconfig_client_mk) as fh:
         mozconfig_mk = os.path.join(self.topobjdir, '.mozconfig.mk')
         with FileAvoidWrite(mozconfig_mk) as fh:
+        # Copy the original mozconfig to the objdir.
+        mozconfig_objdir = os.path.join(self.topobjdir, '.mozconfig')
+        if mozconfig['path']:
+            with open(mozconfig['path'], 'rb') as ifh:
+                with FileAvoidWrite(mozconfig_objdir) as ofh:
+                    ofh.write(ifh.read())
+        else:
+            try:
+                os.unlink(mozconfig_objdir)
+            except OSError as e:
+                if e.errno != errno.ENOENT:
+                    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}')
         append_env['OBJDIR'] = mozpath.normsep(self.topobjdir)