Bug 936555 - make mozinfo use MozconfigLoader to locate the mozconfig; r=gps
☠☠ backed out by 426237492954 ☠ ☠
authorNathan Froyd <froydnj@mozilla.com>
Mon, 27 Jan 2014 11:35:59 -0500
changeset 165415 f9d83ec11ca9458f5bfed87771d4950636bc93c2
parent 165414 778b8bd2b5b620d532100308d5c20561fdca982a
child 165416 a37e6c57ae0f7aef9b041f6955f11c2a89f08622
push id26092
push usercbook@mozilla.com
push dateTue, 28 Jan 2014 12:43:09 +0000
treeherdermozilla-central@ff2a3e1b5faf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs936555
milestone29.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 936555 - make mozinfo use MozconfigLoader to locate the mozconfig; r=gps
CLOBBER
python/mozbuild/mozbuild/mozconfig.py
python/mozbuild/mozbuild/mozinfo.py
python/mozbuild/mozbuild/test/test_mozinfo.py
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-bug 960811 - clobber to rebuild preprocessed files when enabling synthetic APKs
+Bug 936555 - changes to mozconfig finding require clobbers, given that builds on try were green
--- a/python/mozbuild/mozbuild/mozconfig.py
+++ b/python/mozbuild/mozbuild/mozconfig.py
@@ -70,36 +70,36 @@ class MozconfigLoader(ProcessExecutionMi
         self.topsrcdir = topsrcdir
 
     @property
     def _loader_script(self):
         our_dir = os.path.abspath(os.path.dirname(__file__))
 
         return os.path.join(our_dir, 'mozconfig_loader')
 
-    def find_mozconfig(self):
+    def find_mozconfig(self, env=os.environ):
         """Find the active mozconfig file for the current environment.
 
         This emulates the logic in mozconfig-find.
 
         1) If ENV[MOZCONFIG] is set, use that
         2) If $TOPSRCDIR/mozconfig or $TOPSRCDIR/.mozconfig exists, use it.
         3) If both exist or if there are legacy locations detected, error out.
 
         The absolute path to the found mozconfig will be returned on success.
         None will be returned if no mozconfig could be found. A
         MozconfigFindException will be raised if there is a bad state,
         including conditions from #3 above.
         """
         # Check for legacy methods first.
 
-        if 'MOZ_MYCONFIG' in os.environ:
+        if 'MOZ_MYCONFIG' in env:
             raise MozconfigFindException(MOZ_MYCONFIG_ERROR)
 
-        env_path = os.environ.get('MOZCONFIG', None)
+        env_path = env.get('MOZCONFIG', None)
         if env_path is not None:
             if not os.path.exists(env_path):
                 raise MozconfigFindException(
                     'MOZCONFIG environment variable refers to a path that '
                     'does not exist: ' + env_path)
 
             if not os.path.isfile(env_path):
                 raise MozconfigFindException(
@@ -123,17 +123,17 @@ class MozconfigLoader(ProcessExecutionMi
             path = existing[0]
 
         if path is not None:
             return os.path.abspath(path)
 
         deprecated_paths = [os.path.join(self.topsrcdir, s) for s in
             self.DEPRECATED_TOPSRCDIR_PATHS]
 
-        home = os.environ.get('HOME', None)
+        home = env.get('HOME', None)
         if home is not None:
             deprecated_paths.extend([os.path.join(home, s) for s in
             self.DEPRECATED_HOME_PATHS])
 
         for path in deprecated_paths:
             if os.path.exists(path):
                 raise MozconfigFindException(
                     MOZCONFIG_LEGACY_PATH % (path, self.topsrcdir))
--- a/python/mozbuild/mozbuild/mozinfo.py
+++ b/python/mozbuild/mozbuild/mozinfo.py
@@ -3,17 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # This module produces a JSON file that provides basic build info and
 # configuration metadata.
 
 import os
 import re
 import json
-
+import mozbuild.mozconfig as mozconfig
 
 def build_dict(config, env=os.environ):
     """
     Build a dict containing data about the build configuration from
     the environment.
     """
     substs = config.substs
 
@@ -22,20 +22,19 @@ def build_dict(config, env=os.environ):
     missing = [r for r in required if r not in substs]
     if missing:
         raise Exception("Missing required environment variables: %s" %
                         ', '.join(missing))
 
     d = {}
     d['topsrcdir'] = config.topsrcdir
 
-    if 'MOZCONFIG' in env:
-        mozconfig = env["MOZCONFIG"]
-        mozconfig = os.path.join(config.topsrcdir, mozconfig)
-        d['mozconfig'] = os.path.normpath(mozconfig)
+    the_mozconfig = mozconfig.MozconfigLoader(config.topsrcdir).find_mozconfig(env)
+    if the_mozconfig:
+        d['mozconfig'] = the_mozconfig
 
     # os
     o = substs["OS_TARGET"]
     known_os = {"Linux": "linux",
                 "WINNT": "win",
                 "Darwin": "mac",
                 "Android": "b2g" if substs["MOZ_WIDGET_TOOLKIT"] == "gonk" else "android"}
     if o in known_os:
--- a/python/mozbuild/mozbuild/test/test_mozinfo.py
+++ b/python/mozbuild/mozbuild/test/test_mozinfo.py
@@ -14,16 +14,18 @@ import mozunit
 
 from mozbuild.backend.configenvironment import ConfigEnvironment
 
 from mozbuild.mozinfo import (
     build_dict,
     write_mozinfo,
 )
 
+from mozfile.mozfile import NamedTemporaryFile
+
 
 class Base(object):
     def _config(self, substs={}):
         d = os.path.dirname(__file__)
         return ConfigEnvironment(d, d, substs=substs)
 
 
 class TestBuildDict(unittest.TestCase, Base):
@@ -234,25 +236,28 @@ class TestWriteMozinfo(unittest.TestCase
         Test that writing to a file produces correct output.
         """
         c = self._config(dict(
             OS_TARGET='WINNT',
             TARGET_CPU='i386',
             MOZ_WIDGET_TOOLKIT='windows',
         ))
         c.topsrcdir = '/tmp'
-        write_mozinfo(self.f, c, {'MOZCONFIG': 'foo'})
-        with open(self.f) as f:
-            d = json.load(f)
-            self.assertEqual('win', d['os'])
-            self.assertEqual('x86', d['processor'])
-            self.assertEqual('windows', d['toolkit'])
-            self.assertEqual('/tmp', d['topsrcdir'])
-            self.assertEqual(os.path.normpath('/tmp/foo'), d['mozconfig'])
-            self.assertEqual(32, d['bits'])
+        with NamedTemporaryFile(dir=c.topsrcdir) as mozconfig:
+            mozconfig.write('unused contents')
+            mozconfig.flush()
+            write_mozinfo(self.f, c, {'MOZCONFIG': mozconfig.name})
+            with open(self.f) as f:
+                d = json.load(f)
+                self.assertEqual('win', d['os'])
+                self.assertEqual('x86', d['processor'])
+                self.assertEqual('windows', d['toolkit'])
+                self.assertEqual('/tmp', d['topsrcdir'])
+                self.assertEqual(os.path.normpath(mozconfig.name), d['mozconfig'])
+                self.assertEqual(32, d['bits'])
 
     def test_fileobj(self):
         """
         Test that writing to a file-like object produces correct output.
         """
         s = StringIO()
         c = self._config(dict(
             OS_TARGET='WINNT',