Bug 907552 - Add ability to specify cwd to MozbuildObject.from_environment(), r=gps

This commit is contained in:
Andrew Halberstadt 2013-08-22 15:24:40 -04:00
parent b4b181eaf0
commit 6aa2be2268
2 changed files with 6 additions and 5 deletions

View File

@ -87,7 +87,7 @@ class MozbuildObject(ProcessExecutionMixin):
self._config_environment = None
@classmethod
def from_environment(cls):
def from_environment(cls, cwd=None):
"""Create a MozbuildObject by detecting the proper one from the env.
This examines environment state like the current working directory and
@ -111,6 +111,7 @@ class MozbuildObject(ProcessExecutionMixin):
If we're not inside a srcdir or objdir, an exception is raised.
"""
cwd = cwd or os.getcwd()
topsrcdir = None
topobjdir = None
mozconfig = None
@ -122,7 +123,7 @@ class MozbuildObject(ProcessExecutionMixin):
mozconfig = info.get('mozconfig')
return topsrcdir, topobjdir, mozconfig
for dir_path in ancestors(os.getcwd()):
for dir_path in ancestors(cwd):
# If we find a mozinfo.json, we are in the objdir.
mozinfo_path = os.path.join(dir_path, 'mozinfo.json')
if os.path.isfile(mozinfo_path):

View File

@ -12,14 +12,14 @@ from automationutils import addCommonOptions, isURL
from mozprofile import DEFAULT_PORTS
import moznetwork
here = os.path.abspath(os.path.dirname(sys.argv[0]))
try:
from mozbuild.base import MozbuildObject
build_obj = MozbuildObject.from_environment()
build_obj = MozbuildObject.from_environment(cwd=here)
except ImportError:
build_obj = None
here = os.path.abspath(os.path.dirname(sys.argv[0]))
__all__ = ["MochitestOptions", "B2GOptions"]
VMWARE_RECORDING_HELPER_BASENAME = "vmwarerecordinghelper"