[pypy-svn] r19054 - pypy/dist/pypy/translator/llvm

rxe at codespeak.net rxe at codespeak.net
Thu Oct 27 05:40:50 CEST 2005


Author: rxe
Date: Thu Oct 27 05:40:48 2005
New Revision: 19054

Modified:
   pypy/dist/pypy/translator/llvm/externs2ll.py
Log:
Small fix to pass tests again.

This same trick will need to be employed if there are more relative '#include's
from the ll_xxx.h genc files.  These disgusting hacks are there in genllvm
because we run the llvm-gcc on a different machine (which I am not entirely
sure is a good idea anymore :-( )



Modified: pypy/dist/pypy/translator/llvm/externs2ll.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/externs2ll.py	(original)
+++ pypy/dist/pypy/translator/llvm/externs2ll.py	Thu Oct 27 05:40:48 2005
@@ -116,6 +116,12 @@
     return decls
 
 
+def path_join(root_path, *paths):
+    path = root_path
+    for p in paths:
+        path = os.path.join(path, p)
+    return path
+
 def generate_llfile(db, extern_decls, support_functions, debug=False):
     ccode = []
     function_names = []
@@ -140,22 +146,29 @@
                 predeclarefn(c_name, db.repr_name(obj._obj))
 
     include_files = []
-    # append local file
-    j = os.path.join
-    include_files.append(j(j(os.path.dirname(__file__), "module"), "genexterns.c"))
+    add = include_files.append 
+    add(path_join(os.path.dirname(__file__), "module", "genexterns.c"))
 
     from pypy.translator.c import extfunc
+    src_path = path_join(os.path.dirname(extfunc.__file__), "src")
+
     for f in ["ll_os", "ll_math", "ll_time", "ll_strtod", "stack"]:
-        include_files.append(j(j(os.path.dirname(extfunc.__file__), "src"), f + ".h"))
+        add(path_join(src_path, f + ".h"))
 
     for f in include_files:
         s = open(f).read()
-        if f.find('genexterns.c'):
+        if f.find('genexterns.c') > 0:
             if sys.platform == 'darwin':
                 python_h = '"/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3/Python.h"'
             else:
                 python_h = '<python2.3/Python.h>'
             s = s.replace('__PYTHON_H__', python_h)
+
+        elif f.find("ll_os") > 0:
+            # XXX this is getting a tad ridiculous
+            ll_osdefs = open(path_join(src_path, "ll_osdefs.h")).read()
+            s = s.replace('#include "ll_osdefs.h"', ll_osdefs)
+            
         ccode.append(s)
     ccode = "".join(ccode)
 



More information about the Pypy-commit mailing list