Fix the PYTHONPATH bits of bug 436062 in a not-hacky way by using a script which can set up the path and then forward to the real script we're trying to run, r=ted
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 15 Apr 2009 09:06:09 -0400
changeset 27351 862693caa32065f0ec654204876f918ae711155b
parent 27350 94f13c5d8aec136d510360bcb69693a18818ff40
child 27352 c41b9f3a9d83a8f9194b5103f22454642e46cf21
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs436062
milestone1.9.2a1pre
Fix the PYTHONPATH bits of bug 436062 in a not-hacky way by using a script which can set up the path and then forward to the real script we're trying to run, r=ted
config/pythonpath.py
js/src/xpconnect/src/Makefile.in
new file mode 100644
--- /dev/null
+++ b/config/pythonpath.py
@@ -0,0 +1,40 @@
+"""
+Run a python script, adding extra directories to the python path.
+"""
+
+import sys, os
+
+def usage():
+    print >>sys.stderr, "pythonpath.py -I directory script.py [args...]"
+    sys.exit(150)
+
+paths = []
+
+while True:
+    try:
+        arg = sys.argv[1]
+    except IndexError:
+        usage()
+
+    if arg == '-I':
+        del sys.argv[1]
+        try:
+            path = sys.argv.pop(1)
+        except IndexError:
+            usage()
+
+        paths.append(path)
+        continue
+
+    if arg.startswith('-I'):
+        path = sys.argv.pop(1)[2:]
+        paths.append(path)
+        continue
+
+    break
+
+sys.argv.pop(0)
+script = sys.argv[0]
+
+sys.path[0:0] = [os.path.dirname(script)] + paths
+execfile(script, {'__name__': '__main__'})
--- a/js/src/xpconnect/src/Makefile.in
+++ b/js/src/xpconnect/src/Makefile.in
@@ -205,18 +205,19 @@ xpcjsruntime.$(OBJ_SUFFIX): dom_quickstu
 
 dom_quickstubs.h: dom_quickstubs.cpp
 
 dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
                     $(srcdir)/qsgen.py \
                     $(topsrcdir)/xpcom/idl-parser/header.py \
                     $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                     $(DEPTH)/js/src/mozilla-config.h
-	PYTHONPATH=$(topsrcdir)/xpcom/idl-parser \
-	  $(PYTHON) $(srcdir)/qsgen.py \
+	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
+	  -I$(topsrcdir)/xpcom/idl-parser \
+	  $(srcdir)/qsgen.py \
 	  --idlpath=$(DEPTH)/dist/idl \
 	  --cachedir=$(DEPTH)/xpcom/idl-parser \
 	  --header-output dom_quickstubs.h \
 	  --stub-output dom_quickstubs.cpp \
 	  --makedepend-output $(MDDEPDIR)/dom_qsgen.pp \
 	  $(ENABLE_TRACEABLE_FLAGS) \
 	  $(srcdir)/dom_quickstubs.qsconf