[pypy-svn] r59030 - in pypy/branch/cbuild-refactor/pypy/translator: c tool

fijal at codespeak.net fijal at codespeak.net
Sun Oct 12 15:08:55 CEST 2008


Author: fijal
Date: Sun Oct 12 15:08:55 2008
New Revision: 59030

Modified:
   pypy/branch/cbuild-refactor/pypy/translator/c/genc.py
   pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py
Log:
(fijal, pedronis) Make test_standalone pass


Modified: pypy/branch/cbuild-refactor/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/c/genc.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/c/genc.py	Sun Oct 12 15:08:55 2008
@@ -202,24 +202,36 @@
             CBuilder.have___thread = self.translator.platform.check___thread()
         if not self.standalone:
             assert not self.config.translation.instrument
-            cfile, extra = gen_source(db, modulename, targetdir, self.eci,
-                                      defines = defines)
+            self.eci, cfile, extra = gen_source(db, modulename, targetdir,
+                                                self.eci,
+                                                defines = defines)
         else:
             if self.config.translation.instrument:
                 defines['INSTRUMENT'] = 1
             if CBuilder.have___thread:
                 if not self.config.translation.no__thread:
                     defines['USE___THREAD'] = 1
-            cfile, extra = gen_source_standalone(db, modulename, targetdir,
+            self.eci, cfile, extra = gen_source_standalone(db, modulename,
+                                                 targetdir,
                                                  self.eci,
                                                  entrypointname = pfname,
                                                  defines = defines)
         self.c_source_filename = py.path.local(cfile)
-        self.extrafiles = extra
-        if self.standalone:
-            self.gen_makefile(targetdir)
+        self.extrafiles = self.eventually_copy(extra)
+        self.gen_makefile(targetdir)
         return cfile
 
+    def eventually_copy(self, cfiles):
+        extrafiles = []
+        for fn in cfiles:
+            fn = py.path.local(fn)
+            if not fn.relto(udir):
+                newname = self.targetdir.join(fn.basename)
+                fn.copy(newname)
+                fn = newname
+            extrafiles.append(fn)
+        return extrafiles
+
 class ModuleWithCleanup(object):
     def __init__(self, mod):
         self.__dict__['mod'] = mod
@@ -336,6 +348,9 @@
         if isinstance(self._module, isolate.Isolate):
             isolate.close_isolate(self._module)
 
+    def gen_makefile(self, targetdir):
+        pass
+
 class CStandaloneBuilder(CBuilder):
     standalone = True
     executable_name = None
@@ -364,22 +379,6 @@
         bk = self.translator.annotator.bookkeeper
         return getfunctionptr(bk.getdesc(self.entrypoint).getuniquegraph())
 
-    def getccompiler(self):
-        cc = self.config.translation.cc
-        # Copy extrafiles to target directory, if needed
-        extrafiles = []
-        for fn in self.extrafiles:
-            fn = py.path.local(fn)
-            if not fn.relto(udir):
-                newname = self.targetdir.join(fn.basename)
-                fn.copy(newname)
-                fn = newname
-            extrafiles.append(fn)
-
-        return CCompiler(
-            [self.c_source_filename] + extrafiles,
-            self.eci, compiler_exe = cc, profbased = self.getprofbased())
-
     def compile(self):
         assert self.c_source_filename
         assert not self._compiled
@@ -415,15 +414,14 @@
             compiler.link_extra.append(self.config.translation.linkerflags)
 
     def gen_makefile(self, targetdir):
+        cfiles = [self.c_source_filename] + self.extrafiles
+        mk = self.translator.platform.gen_makefile(cfiles, self.eci,
+                                                   path=targetdir)
+        mk.write()
+        #self.translator.platform,
+        #                           ,
+        #                           self.eci, profbased=self.getprofbased()
         return
-        def write_list(lst, prefix):
-            for i, fn in enumerate(lst):
-                print >> f, prefix, fn,
-                if i < len(lst)-1:
-                    print >> f, '\\'
-                else:
-                    print >> f
-                prefix = ' ' * len(prefix)
 
         self.eci = self.eci.merge(ExternalCompilationInfo(
             includes=['.', str(self.targetdir)]))
@@ -842,8 +840,8 @@
         fi.close()
 
     eci = eci.convert_sources_to_files(being_main=True)
-    return filename, sg.getextrafiles() + list(eci.separate_module_files)
-
+    files, eci = eci.get_module_files()
+    return eci, filename, sg.getextrafiles() + list(files)
 
 def gen_source(database, modulename, targetdir, eci, defines={}):
     assert not database.standalone
@@ -902,9 +900,8 @@
     f.write(SETUP_PY % locals())
     f.close()
     eci = eci.convert_sources_to_files(being_main=True)
-
-    return filename, sg.getextrafiles() + list(eci.separate_module_files)
-
+    files, eci = eci.get_module_files()
+    return eci, filename, sg.getextrafiles() + list(files)
 
 SETUP_PY = '''
 from distutils.core import setup

Modified: pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py	Sun Oct 12 15:08:55 2008
@@ -255,6 +255,12 @@
         d['separate_module_files'] += tuple(files)
         return ExternalCompilationInfo(**d)
 
+    def get_module_files(self):
+        d = self._copy_attributes()
+        files = d['separate_module_files']
+        d['separate_module_files'] = ()
+        return files, ExternalCompilationInfo(**d)
+
     def compile_shared_lib(self):
         self = self.convert_sources_to_files()
         if not self.separate_module_files:



More information about the Pypy-commit mailing list