Created
May 14, 2013 15:46
-
-
Save vvuk/5577003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client.mk b/client.mk | |
index de4de4c..726653b 100644 | |
--- a/client.mk | |
+++ b/client.mk | |
@@ -78,7 +78,6 @@ ifdef CONFIG_GUESS_SCRIPT | |
CONFIG_GUESS := $(shell $(CONFIG_GUESS_SCRIPT)) | |
endif | |
- | |
#################################### | |
# Sanity checks | |
@@ -89,6 +88,16 @@ $(error This source tree appears to have Windows-style line endings. To \ | |
convert it to Unix-style line endings, run \ | |
"python mozilla/build/win32/mozilla-dos2unix.py") | |
endif | |
+ | |
+# On windows, if $PYTHON is set in the environment, we need to make | |
+# sure that it's quoted -- if it's a windows-style path | |
+# (e.g. 'C:\Python27\python'), using $(PYTHON) as-is will cause the | |
+# backslashes to not get treated as path separators. | |
+ PYTHON := $(subst \\,/,$(PYTHON)) | |
+ PYTHON := $(subst \,/,$(PYTHON)) | |
+ | |
+ TOPSRCDIR := $(subst \\,/,$(TOPSRCDIR)) | |
+ TOPSRCDIR := $(subst \,/,$(TOPSRCDIR)) | |
endif | |
#################################### | |
@@ -118,6 +127,10 @@ ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS))) | |
MOZ_MAKE_FLAGS += -j$(cores) | |
endif | |
+ifndef MOZ_OBJDIR | |
+ # Pull it in from environment | |
+ MOZ_OBJDIR ?= | |
+endif | |
ifndef MOZ_OBJDIR | |
MOZ_OBJDIR = obj-$(CONFIG_GUESS) | |
@@ -127,6 +140,11 @@ else | |
ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR)))) | |
$(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.) | |
endif | |
+ | |
+ # Then replace any forward slashes with slashes; first | |
+ # doing double-forward-slashes in case of overzealous quoting | |
+ MOZ_OBJDIR := $(subst \\,/,$(MOZ_OBJDIR)) | |
+ MOZ_OBJDIR := $(subst \,/,$(MOZ_OBJDIR)) | |
endif | |
endif | |
diff --git a/config/writemozinfo.py b/config/writemozinfo.py | |
index abe9457..3ba19f6 100755 | |
--- a/config/writemozinfo.py | |
+++ b/config/writemozinfo.py | |
@@ -35,6 +35,9 @@ def build_dict(env=os.environ): | |
if 'TOPSRCDIR' in env: | |
d["topsrcdir"] = env["TOPSRCDIR"] | |
+ if 'MOZ_OBJDIR' in env: | |
+ d["topobjdir"] = env["MOZ_OBJDIR"] | |
+ | |
# os | |
o = env["OS_TARGET"] | |
known_os = {"Linux": "linux", | |
diff --git a/mach b/mach | |
index 9aba282..635c7d4 100755 | |
--- a/mach | |
+++ b/mach | |
@@ -20,6 +20,13 @@ def load_mach(topsrcdir): | |
import mach_bootstrap | |
return mach_bootstrap.bootstrap(topsrcdir) | |
+def try_run_mach(dir_path): | |
+ mach_path = os.path.join(dir_path, "build/mach_bootstrap.py") | |
+ if os.path.isfile(mach_path): | |
+ mach = load_mach(dir_path) | |
+ sys.exit(mach.run(sys.argv[1:])) | |
+ return False | |
+ | |
# Check whether the current directory is within a mach src or obj dir. | |
for dir_path in ancestors(os.getcwd()): | |
# If we find a "mozinfo.json" file, we are in the objdir. | |
@@ -37,15 +44,28 @@ for dir_path in ancestors(os.getcwd()): | |
# 2.7.2 and earlier on Windows. | |
os.environ[b"MOZCONFIG"] = str(info["mozconfig"]) | |
+ if "topobjdir" in info and "MOZ_OBJDIR" not in os.environ: | |
+ os.environ[b"MOZ_OBJDIR"] = str(info["topobjdir"]) | |
+ | |
if "topsrcdir" in info: | |
# Continue searching for mach_bootstrap in the source directory. | |
dir_path = info["topsrcdir"] | |
# If we find the mach bootstrap module, we are in the srcdir. | |
- mach_path = os.path.join(dir_path, "build/mach_bootstrap.py") | |
- if os.path.isfile(mach_path): | |
- mach = load_mach(dir_path) | |
- sys.exit(mach.run(sys.argv[1:])) | |
+ try_run_mach(dir_path) | |
+ | |
+# Then check if we have an explicit path, e.g. | |
+# ../gecko/mach | |
+# then use cwd as the objdir and the dirname as the srcdir | |
+dir_path = os.path.dirname(sys.argv[0]) | |
+if dir_path: | |
+ dir_path = os.path.abspath(dir_path) | |
+ if dir_path == os.getcwd(): | |
+ print("implicit objdir must not be the same as the source directory!") | |
+ sys.exit(1) | |
+ print("USing implicit objdir: '%s'" % os.getcwd()) | |
+ os.environ[b"MOZ_OBJDIR"] = str(os.getcwd()) | |
+ try_run_mach(dir_path) | |
print("Could not run mach: No mach source directory found") | |
sys.exit(1) | |
diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py | |
index e9df738..82d9bb6 100644 | |
--- a/python/mozbuild/mozbuild/base.py | |
+++ b/python/mozbuild/mozbuild/base.py | |
@@ -57,7 +57,7 @@ class MozbuildObject(ProcessExecutionMixin): | |
@property | |
def topobjdir(self): | |
if self._topobjdir is None: | |
- topobj = self.mozconfig['topobjdir'] or 'obj-@CONFIG_GUESS@' | |
+ topobj = self.mozconfig['topobjdir'] or os.getenv('MOZ_OBJDIR') or 'obj-@CONFIG_GUESS@' | |
self._topobjdir = topobj.replace("@CONFIG_GUESS@", | |
self._config_guess) | |
return self._topobjdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment