Bug 1282256 - Make MozbuildObject.resolve_mozconfig_topobjdir an instance method. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 04 Aug 2016 13:41:57 +0900
changeset 396570 4f28f9512ae389e78d65adef035d9b766b8f8461
parent 396569 6474eb370154e1f7976a984d7a7f30a41c4cee58
child 396571 9db5cd594b7a148d76a16f7dff21c8d79494c51a
push id25054
push userbmo:mh+mozilla@glandium.org
push dateThu, 04 Aug 2016 04:59:59 +0000
reviewersgps
bugs1282256
milestone51.0a1
Bug 1282256 - Make MozbuildObject.resolve_mozconfig_topobjdir an instance method. r?gps The only use that didn't have an existing instance was just removed.
python/mozbuild/mozbuild/base.py
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -167,36 +167,36 @@ class MozbuildObject(ProcessExecutionMix
                     'to be the same as your source directory (%s). This build '
                     'configuration is not supported.' % topsrcdir)
 
         # If we can't resolve topobjdir, oh well. We'll figure out when we need
         # one.
         return cls(topsrcdir, None, None, topobjdir=topobjdir,
                    mozconfig=mozconfig)
 
-    @staticmethod
-    def resolve_mozconfig_topobjdir(topsrcdir, mozconfig, default=None):
-        topobjdir = mozconfig['topobjdir'] or default
+    def resolve_mozconfig_topobjdir(self, default=None):
+        topobjdir = self.mozconfig['topobjdir'] or default
         if not topobjdir:
             return None
 
         if '@CONFIG_GUESS@' in topobjdir:
             topobjdir = topobjdir.replace('@CONFIG_GUESS@',
-                MozbuildObject.resolve_config_guess(mozconfig, topsrcdir))
+                MozbuildObject.resolve_config_guess(self.mozconfig,
+                                                    self.topsrcdir))
 
         if not os.path.isabs(topobjdir):
-            topobjdir = os.path.abspath(os.path.join(topsrcdir, topobjdir))
+            topobjdir = os.path.abspath(os.path.join(self.topsrcdir, topobjdir))
 
         return mozpath.normsep(os.path.normpath(topobjdir))
 
     @property
     def topobjdir(self):
         if self._topobjdir is None:
-            self._topobjdir = MozbuildObject.resolve_mozconfig_topobjdir(
-                self.topsrcdir, self.mozconfig, default='obj-@CONFIG_GUESS@')
+            self._topobjdir = self.resolve_mozconfig_topobjdir(
+                default='obj-@CONFIG_GUESS@')
 
         return self._topobjdir
 
     @property
     def virtualenv_manager(self):
         if self._virtualenv_manager is None:
             self._virtualenv_manager = VirtualenvManager(self.topsrcdir,
                 self.topobjdir, os.path.join(self.topobjdir, '_virtualenv'),
@@ -666,18 +666,17 @@ class MachCommandBase(MozbuildObject):
             topsrcdir = dummy.topsrcdir
             topobjdir = dummy._topobjdir
             if topobjdir:
                 # If we're inside a objdir and the found mozconfig resolves to
                 # another objdir, we abort. The reasoning here is that if you
                 # are inside an objdir you probably want to perform actions on
                 # that objdir, not another one. This prevents accidental usage
                 # of the wrong objdir when the current objdir is ambiguous.
-                config_topobjdir = MozbuildObject.resolve_mozconfig_topobjdir(
-                    topsrcdir, dummy.mozconfig)
+                config_topobjdir = dummy.resolve_mozconfig_topobjdir()
                 if config_topobjdir and not samepath(topobjdir,
                                                      config_topobjdir):
                     raise ObjdirMismatchException(topobjdir, config_topobjdir)
         except BuildEnvironmentNotFoundException:
             pass
         except ObjdirMismatchException as e:
             print('Ambiguous object directory detected. We detected that '
                 'both %s and %s could be object directories. This is '