[pypy-svn] r25845 - in pypy/dist/pypy/translator: . goal

arigo at codespeak.net arigo at codespeak.net
Sat Apr 15 11:05:04 CEST 2006


Author: arigo
Date: Sat Apr 15 11:05:02 2006
New Revision: 25845

Modified:
   pypy/dist/pypy/translator/driver.py
   pypy/dist/pypy/translator/goal/   (props changed)
   pypy/dist/pypy/translator/goal/targetpypystandalone.py
   pypy/dist/pypy/translator/goal/translate.py
Log:
Convince translate.py to produce executables that are not all called
pypy-c or pypy-llvm no matter what the target is.



Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py	(original)
+++ pypy/dist/pypy/translator/driver.py	Sat Apr 15 11:05:02 2006
@@ -41,7 +41,8 @@
 
 class TranslationDriver(SimpleTaskEngine):
 
-    def __init__(self, options=None, default_goal=None, disable=[]): 
+    def __init__(self, options=None, default_goal=None, disable=[],
+                 exe_name = 'target-%(backend)s'):
         SimpleTaskEngine.__init__(self)
 
         self.log = log
@@ -49,7 +50,8 @@
         if options is None:
             options = DEFAULT_OPTIONS
         self.options = options
- 
+        self.exe_name = exe_name
+
         self.done = {}
 
         self.disable(disable)
@@ -261,7 +263,10 @@
     def create_exe(self):
         import shutil
         exename = mkexename(self.c_entryp)
-        newexename = mkexename('./pypy-%s' % self.options.backend)
+        newexename = self.exe_name % self.options.__dict__
+        if '/' not in newexename and '\\' not in newexename:
+            newexename = './' + newexename
+        newexename = mkexename(newexename)
         shutil.copy(exename, newexename)
         self.c_entryp = newexename
         self.log.info("created: %s" % (self.c_entryp,))
@@ -335,7 +340,8 @@
     def task_compile_llvm(self):
         gen = self.llvmgen
         if self.standalone:
-            self.c_entryp = gen.compile_llvm_source(exe_name='pypy-llvm')
+            exe_name = self.exe_name % self.options.__dict__
+            self.c_entryp = gen.compile_llvm_source(exe_name=exe_name)
             self.create_exe()
         else:
             self.c_entryp = gen.compile_llvm_source(return_fn=True)
@@ -372,7 +378,9 @@
             options = DEFAULT_OPTIONS
 
         driver = TranslationDriver(options, default_goal, disable)
-            
+        if '__name__' in targetspec_dic:
+            driver.exe_name = targetspec_dic['__name__'] + '-%(backend)s'
+
         target = targetspec_dic['target']
         spec = target(driver, args)
 

Modified: pypy/dist/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetpypystandalone.py	(original)
+++ pypy/dist/pypy/translator/goal/targetpypystandalone.py	Sat Apr 15 11:05:02 2006
@@ -63,6 +63,7 @@
 
 
 def target(driver, args):
+    driver.exe_name = 'pypy-%(backend)s'
     options = driver.options
 
     tgt_options, _ = opt_parser().parse_args(args)

Modified: pypy/dist/pypy/translator/goal/translate.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate.py	(original)
+++ pypy/dist/pypy/translator/goal/translate.py	Sat Apr 15 11:05:02 2006
@@ -154,8 +154,9 @@
     if not targetspec.endswith('.py'):
         targetspec += '.py'
     thismod = sys.modules[__name__]
-    targetspec_dic = {'__name__':'__rpythonmain__',
-                      'translate': thismod}
+    targetspec_dic = {
+        '__name__': os.path.splitext(os.path.basename(targetspec))[0],
+        'translate': thismod}
     sys.path.insert(0, os.path.dirname(targetspec))
     execfile(targetspec, targetspec_dic)
     return targetspec_dic



More information about the Pypy-commit mailing list