[pypy-svn] r76051 - pypy/branch/reflex-support/pypy/translator/c

arigo at codespeak.net arigo at codespeak.net
Thu Jul 8 20:23:59 CEST 2010


Author: arigo
Date: Thu Jul  8 20:23:57 2010
New Revision: 76051

Modified:
   pypy/branch/reflex-support/pypy/translator/c/genc.py
Log:
Tentatively fix the Makefile to not call trackgcroot.py on
some C files, and on all other files (.cpp, .cxx...)


Modified: pypy/branch/reflex-support/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/reflex-support/pypy/translator/c/genc.py	(original)
+++ pypy/branch/reflex-support/pypy/translator/c/genc.py	Thu Jul  8 20:23:57 2010
@@ -572,16 +572,15 @@
             mk.rule(*rule)
 
         if self.config.translation.gcrootfinder == 'asmgcc':
-            trackgcfiles = [cfile[:-2] for cfile in mk.cfiles]
-            if self.translator.platform.name == 'msvc':
+            trackgcfiles = [cfile[:-2] for cfile in mk.cfiles
+                                       if cfile.endswith('.c')]
+            if 1:    # XXX do that more cleanly
                 trackgcfiles = [f for f in trackgcfiles
                                 if f.startswith(('implement', 'testing',
                                                  '../module_cache/module'))]
             sfiles = ['%s.s' % (c,) for c in trackgcfiles]
-            lblsfiles = ['%s.lbl.s' % (c,) for c in trackgcfiles]
             gcmapfiles = ['%s.gcmap' % (c,) for c in trackgcfiles]
             mk.definition('ASMFILES', sfiles)
-            mk.definition('ASMLBLFILES', lblsfiles)
             mk.definition('GCMAPFILES', gcmapfiles)
             mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
 
@@ -596,17 +595,32 @@
                 python = ''
 
             if self.translator.platform.name == 'msvc':
-                lblofiles = []
-                for cfile in mk.cfiles:
-                    f = cfile[:-2]
-                    if f in trackgcfiles:
-                        ofile = '%s.lbl.obj' % (f,)
-                    else:
-                        ofile = '%s.obj' % (f,)
-
-                    lblofiles.append(ofile)
-                mk.definition('ASMLBLOBJFILES', lblofiles)
-                mk.definition('OBJECTS', 'gcmaptable.obj $(ASMLBLOBJFILES)')
+                o_ext = '.obj'
+                lbl_ext = '.lbl.obj'
+            else:
+                o_ext = '.o'
+                lbl_ext = '.lbl.s'
+
+            objectfiles = []
+            nontrackgcexts = set()
+            for cfile in mk.cfiles:
+                f = cfile[:-2]
+                if f in trackgcfiles:
+                    ofile = f + lbl_ext
+                else:
+                    f, ext = os.path.splitext(cfile)
+                    nontrackgcexts.add(ext)
+                    ofile = f + o_ext
+                objectfiles.append(ofile)
+            if self.translator.platform.name == 'msvc':
+                objectfiles.append('gcmaptable.obj')
+            else:
+                objectfiles.append('gcmaptable.s')
+            mk.definition('OBJECTS', objectfiles)
+            nontrackgcexts = list(nontrackgcexts)
+            nontrackgcexts.sort()
+
+            if self.translator.platform.name == 'msvc':
                 # /Oi (enable intrinsics) and /Ob1 (some inlining) are mandatory
                 # even in debug builds
                 mk.definition('ASM_CFLAGS', '$(CFLAGS) $(CFLAGSEXTRA) /Oi /Ob1')
@@ -619,14 +633,19 @@
                         )
                 mk.rule('gcmaptable.c', '$(GCMAPFILES)',
                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc $(GCMAPFILES) > $@')
+                for ext in nontrackgcexts:
+                    mk.rule(ext + '.obj', '',
+                            '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $< $(INCLUDEDIRS)')
 
             else:
-                mk.definition('OBJECTS', '$(ASMLBLFILES) gcmaptable.s')
                 mk.rule('%.s', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -frandom-seed=$< -o $@ -S $< $(INCLUDEDIRS)')
                 mk.rule('%.lbl.s %.gcmap', '%.s',
                         python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -m$(PYPY_MAIN_FUNCTION) -t $< > $*.gcmap')
                 mk.rule('gcmaptable.s', '$(GCMAPFILES)',
                         python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py $(GCMAPFILES) > $@')
+                for ext in nontrackgcexts:
+                    mk.rule('%.o', '%' + ext,
+                            '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< $(INCLUDEDIRS)')
 
         else:
             mk.definition('DEBUGFLAGS', '-O1 -g')



More information about the Pypy-commit mailing list