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)
reviewersnalexander
bugs1417264
milestone59.0a1
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
client.mk
python/mozbuild/mozbuild/controller/building.py
--- a/client.mk
+++ b/client.mk
@@ -133,34 +133,28 @@ ifeq ($(TOPSRCDIR),$(OBJDIR))
 else
   CONFIGURE = $(TOPSRCDIR)/configure
 endif
 
 configure-files: $(CONFIGURES)
 
 configure-preqs = \
   configure-files \
-  save-mozconfig \
   $(OBJDIR)/.mozconfig.json \
   $(NULL)
 
 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).
 ifneq (,$(CREATE_MOZCONFIG_JSON))
 endif
 
 $(OBJDIR)/.mozconfig.json: ;
 
-save-mozconfig: $(FOUND_MOZCONFIG)
-ifdef FOUND_MOZCONFIG
-	-cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
-endif
-
 configure:: $(configure-preqs)
 	$(call BUILDSTATUS,TIERS configure)
 	$(call BUILDSTATUS,TIER_START configure)
 	@echo cd $(OBJDIR);
 	@echo $(CONFIGURE) $(CONFIGURE_ARGS)
 	@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
 	  || ( 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):
                                            '.mozconfig-client-mk')
         with FileAvoidWrite(mozconfig_client_mk) as fh:
             fh.write(b'\n'.join(mozconfig_make_lines))
 
         mozconfig_mk = os.path.join(self.topobjdir, '.mozconfig.mk')
         with FileAvoidWrite(mozconfig_mk) as fh:
             fh.write(b'\n'.join(mozconfig_filtered_lines))
 
+        # 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)