[pypy-svn] r75405 - in pypy/trunk/pypy/translator: . c platform

afa at codespeak.net afa at codespeak.net
Tue Jun 15 16:34:00 CEST 2010


Author: afa
Date: Tue Jun 15 16:33:58 2010
New Revision: 75405

Modified:
   pypy/trunk/pypy/translator/c/genc.py
   pypy/trunk/pypy/translator/driver.py
   pypy/trunk/pypy/translator/platform/posix.py
   pypy/trunk/pypy/translator/platform/windows.py
Log:
Fix inconsistencies between the genc builder and the Makefile.
now the --shared option works with or without a makefile,
and also with the mingw32 compiler on Windows.

The shared library is named consistently.
for example: libpypy-c.dll for pypy-c.exe


Modified: pypy/trunk/pypy/translator/c/genc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/genc.py	(original)
+++ pypy/trunk/pypy/translator/c/genc.py	Tue Jun 15 16:33:58 2010
@@ -227,7 +227,7 @@
                     funcgen.patch_graph(copy_graph=False)
         return db
 
-    def generate_source(self, db=None, defines={}):
+    def generate_source(self, db=None, defines={}, exe_name=None):
         assert self.c_source_filename is None
         translator = self.translator
 
@@ -271,7 +271,7 @@
                                                  defines = defines)
         self.c_source_filename = py.path.local(cfile)
         self.extrafiles = self.eventually_copy(extra)
-        self.gen_makefile(targetdir)
+        self.gen_makefile(targetdir, exe_name=exe_name)
         return cfile
 
     def eventually_copy(self, cfiles):
@@ -482,7 +482,7 @@
         # build main program
         eci = self.get_eci()
         kw = {}
-        if self.translator.platform.so_ext == 'so':
+        if self.translator.platform.cc == 'gcc':
             kw['libraries'] = [self.shared_library_name.purebasename[3:]]
             kw['library_dirs'] = [self.targetdir]
         else:
@@ -516,6 +516,10 @@
                 extra_opts += ['-j', str(self.config.translation.make_jobs)]
             self.translator.platform.execute_makefile(self.targetdir,
                                                       extra_opts)
+            if shared:
+                self.shared_library_name = self.executable_name.new(
+                    purebasename='lib' + self.executable_name.purebasename,
+                    ext=self.translator.platform.so_ext)
         else:
             compiler = CCompilerDriver(self.translator.platform,
                                        [self.c_source_filename] + self.extrafiles,
@@ -531,6 +535,8 @@
 
     def gen_makefile(self, targetdir, exe_name=None):
         cfiles = [self.c_source_filename] + self.extrafiles
+        if exe_name is not None:
+            exe_name = targetdir.join(exe_name)
         mk = self.translator.platform.gen_makefile(
             cfiles, self.eci,
             path=targetdir, exe_name=exe_name,

Modified: pypy/trunk/pypy/translator/driver.py
==============================================================================
--- pypy/trunk/pypy/translator/driver.py	(original)
+++ pypy/trunk/pypy/translator/driver.py	Tue Jun 15 16:33:58 2010
@@ -513,7 +513,12 @@
             defines = cbuilder.DEBUG_DEFINES
         else:
             defines = {}
-        c_source_filename = cbuilder.generate_source(database, defines)
+        if self.exe_name is not None:
+            exe_name = self.exe_name % self.get_info()
+        else:
+            exe_name = None
+        c_source_filename = cbuilder.generate_source(database, defines,
+                                                     exe_name=exe_name)
         self.log.info("written: %s" % (c_source_filename,))
         if self.config.translation.dump_static_data_info:
             from pypy.translator.tool.staticsizereport import dump_static_data_info
@@ -530,19 +535,20 @@
         newexename = self.exe_name % self.get_info()
         if '/' not in newexename and '\\' not in newexename:
             newexename = './' + newexename
-        return mkexename(py.path.local(newexename))
+        return py.path.local(newexename)
 
     def create_exe(self):
         """ Copy the compiled executable into translator/goal
         """
         if self.exe_name is not None:
-            exename = mkexename(self.c_entryp)
-            newexename = self.compute_exe_name()
+            exename = self.c_entryp
+            newexename = mkexename(self.compute_exe_name())
             shutil.copy(str(exename), str(newexename))
             if self.cbuilder.shared_library_name is not None:
                 soname = self.cbuilder.shared_library_name
                 newsoname = newexename.new(basename=soname.basename)
                 shutil.copy(str(soname), str(newsoname))
+                self.log.info("copied: %s" % (newsoname,))
             self.c_entryp = newexename
         self.log.info("created: %s" % (self.c_entryp,))
 

Modified: pypy/trunk/pypy/translator/platform/posix.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/posix.py	(original)
+++ pypy/trunk/pypy/translator/platform/posix.py	Tue Jun 15 16:33:58 2010
@@ -83,6 +83,8 @@
 
         if exe_name is None:
             exe_name = cfiles[0].new(ext=self.exe_ext)
+        else:
+            exe_name = exe_name.new(ext=self.exe_ext)
 
         linkflags = self.link_flags[:]
         if shared:
@@ -146,6 +148,7 @@
 
         if shared:
             m.definition('SHARED_IMPORT_LIB', libname),
+            m.definition('PYPY_MAIN_FUNCTION', "pypy_main_startup")
             m.rule('main.c', '',
                    'echo "'
                    'int $(PYPY_MAIN_FUNCTION)(int, char*[]); '

Modified: pypy/trunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/windows.py	(original)
+++ pypy/trunk/pypy/translator/platform/windows.py	Tue Jun 15 16:33:58 2010
@@ -208,6 +208,8 @@
 
         if exe_name is None:
             exe_name = cfiles[0].new(ext=self.exe_ext)
+        else:
+            exe_name = exe_name.new(ext=self.exe_ext)
 
         m = NMakefile(path)
         m.exe_name = exe_name
@@ -220,7 +222,8 @@
         linkflags += self._exportsymbols_link_flags(eci)
 
         if shared:
-            so_name = exe_name.new(ext=self.so_ext)
+            so_name = exe_name.new(purebasename='lib' + exe_name.purebasename,
+                                   ext=self.so_ext)
             target_name = so_name.basename
         else:
             target_name = exe_name.basename
@@ -334,6 +337,7 @@
     shared_only = []
     cflags = ['-O3']
     link_flags = []
+    exe_ext = 'exe'
     so_ext = 'dll'
 
     def __init__(self, cc=None):



More information about the Pypy-commit mailing list