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

--HG--
extra : rebase_source : 1b9387bd72f5a8e9bf8274f5764b0db0176fdba2
extra : source : 0cab9a382d817e6fbab9daa37db0f23e7f73e71f
This commit is contained in:
Gregory Szorc 2017-11-13 17:31:14 -08:00
parent c4869e52d7
commit f269a93370
2 changed files with 14 additions and 6 deletions

View File

@ -138,7 +138,6 @@ configure-files: $(CONFIGURES)
configure-preqs = \
configure-files \
save-mozconfig \
$(OBJDIR)/.mozconfig.json \
$(NULL)
@ -151,11 +150,6 @@ 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)

View File

@ -4,6 +4,7 @@
from __future__ import absolute_import, unicode_literals
import errno
import getpass
import io
import json
@ -1371,6 +1372,19 @@ class BuildDriver(MozbuildObject):
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'],