[pypy-svn] r14103 - pypy/dist/pypy/translator/llvm2

bert at codespeak.net bert at codespeak.net
Sat Jul 2 17:57:33 CEST 2005


Author: bert
Date: Sat Jul  2 17:57:32 2005
New Revision: 14103

Modified:
   pypy/dist/pypy/translator/llvm2/build_llvm_module.py
Log:
(bert,ericvrp):

- use distutils instead of hard-coding gcc for llvm2
- this fixes module generation on Mac OS X
- also removes hard-coded python2.3 reference 


Modified: pypy/dist/pypy/translator/llvm2/build_llvm_module.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/build_llvm_module.py	(original)
+++ pypy/dist/pypy/translator/llvm2/build_llvm_module.py	Sat Jul  2 17:57:32 2005
@@ -28,6 +28,8 @@
     modname = pyxfile.purebasename
     b = llvmfile.purebasename
 
+    usedistutils = sys.platform == "darwin"
+
     if sys.maxint == 2147483647:        #32 bit platform
         if optimize:
             ops1 = ["llvm-as %s.ll -f -o %s.bc" % (b, b), 
@@ -38,8 +40,19 @@
             ops1 = ["llvm-as %s.ll -f -o %s.bc" % (b, b),
                     "llc -enable-correct-eh-support %s.bc -f -o %s.s" % (b, b),
                     "as %s.s -o %s.o" % (b, b)]
-        ops2 = ["gcc -c -shared -I/usr/include/python2.3 %s.c" % pyxfile.purebasename,
-                "gcc -shared %s.o %s.o -o %s.so" % (b, modname, modname)]
+        if usedistutils:
+            open("setup.py", "w").write(str(py.code.Source(''' 
+                from distutils.core import setup
+                from distutils.extension import Extension
+                setup(name="%s_wrapper",
+                    ext_modules = [Extension(name = "%s_wrapper",
+                        sources = ["%s_wrapper.c"],
+                        extra_objects = ["%s.o"])])
+                ''' % (b, b, b, b))))
+            ops2 = ["python setup.py build_ext --inplace"]
+        else:
+            ops2 = ["gcc -c -shared -I/usr/include/python2.3 %s.c" % pyxfile.purebasename,
+                    "gcc -shared %s.o %s.o -o %s.so" % (b, modname, modname)]
     else:       #assume 64 bit platform (x86-64?)
         #this special case for x86-64 (called ia64 in llvm) can go as soon as llc supports ia64 assembly output!
         if optimize:



More information about the Pypy-commit mailing list