[Numpy-svn] r4435 - in branches/numpy.scons/numpy/distutils/scons: . tests

numpy-svn@scip... numpy-svn@scip...
Mon Nov 12 01:32:23 CST 2007


Author: cdavid
Date: 2007-11-12 01:32:05 -0600 (Mon, 12 Nov 2007)
New Revision: 4435

Modified:
   branches/numpy.scons/numpy/distutils/scons/fortran.py
   branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
   branches/numpy.scons/numpy/distutils/scons/tests/fortran_output.py
Log:
More work on gnu fortran / Visual interaction: dummy main and Clibs now works

Modified: branches/numpy.scons/numpy/distutils/scons/fortran.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/fortran.py	2007-11-12 05:12:09 UTC (rev 4434)
+++ branches/numpy.scons/numpy/distutils/scons/fortran.py	2007-11-12 07:32:05 UTC (rev 4435)
@@ -15,7 +15,7 @@
 
 # linkflags which match those are ignored
 LINKFLAGS_IGNORED = [r'-lang*', r'-lcrt[a-zA-Z0-9]*\.o', r'-lc', r'-lgcc*',
-                     r'-lSystem', r'-libmil', r'-LIST:*', r'-LNO:*']
+                     r'-lSystem', r'-libmil', r'-LIST:*', r'-LNO:*', r'-lfrt*', r'-luser32', r'-lkernel32', r'-ladvapi32', r'-lmsvcrt', r'-lshell32', r'-lmingw', r'-lmoldname']
 RLINKFLAGS_IGNORED = [re.compile(i) for i in LINKFLAGS_IGNORED]
 
 # linkflags which match those are the one we are interested in

Modified: branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-11-12 05:12:09 UTC (rev 4434)
+++ branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-11-12 07:32:05 UTC (rev 4435)
@@ -110,36 +110,58 @@
 
 # If need a dummy main
 def _CheckFDummyMain(context, fcomp):
+    # Check whether the Fortran runtime needs a dummy main.
     if not context.env.has_key(fcomp):
         context.Message('Checking dummy main: no %s compiler defined: cannot check dummy main ' % fcomp)
         return 0, None
     else:
         context.Message('Checking if %s needs dummy main - ' % context.env[fcomp])
 
-    fcn_tmpl = """
+    env = context.env
+    if not built_with_mstools(context.env):
+	    savedLINK = env.has_key('LINK') and deepcopy(env['LINK']) or []
+	    try:
+		env['LINK'] = env[fcomp]
+		res, m =_dummy_main_imp(context)
+	    finally:
+		env.Replace(LINK = savedLINK)
+    else:
+            # Using MS tools (Visual studio) with fortran compiler
+	    # XXX: this has to be dirty... As scons is using visual studio, it
+	    # uses the related convention (prefix names for libraries, etc...).
+	    # Here, we want to compile object code with cl.exe, but link with
+	    # the fortran compiler which may be totally different than cl.exe
+	    # (think gnu fortran compiler). So we have to bypass scons
+	    # commands, and use our own: since this is only used for
+	    # configuration, it should not matter much.
+	    savedLINKCOM = env.has_key('LINKCOM') and deepcopy(env['LINKCOM']) or []
+	    try:
+		env['LINKCOM'] = "$F77 -o $TARGET $SOURCES"
+		res, m = _dummy_main_imp(context)
+	    finally:
+		env.Replace(LINKCOM = savedLINKCOM)
+
+    return res, m
+
+def _dummy_main_imp(context):
+    	fcn_tmpl = """
 int %s() { return 0; }
 """
-    env = context.env
-    savedLINK = env.has_key('LINK') and deepcopy(env['LINK']) or []
-    try:
-        env['LINK'] = env[fcomp]
-        mains = ["MAIN__", "__MAIN", "_MAIN", "MAIN_"]
-        mains.extend([string.lower(m) for m in mains])
-        mains.insert(0, "")
-        mains.append("MAIN")
-        mains.append("main")
-        for m in mains:
-            prog = fcn_tmpl % "dummy"
-            if m:
-                prog = fcn_tmpl % m + prog
-            result = context.TryLink(prog, '.c')
-            if result:
-                if not m:
-                    m = None
-                break
-    finally:
-        env.Replace(LINK = savedLINK)
-    return result, m
+	mains = ["MAIN__", "__MAIN", "_MAIN", "MAIN_"]
+	mains.extend([string.lower(m) for m in mains])
+	mains.insert(0, "")
+	mains.append("MAIN")
+	mains.append("main")
+	for m in mains:
+	    prog = fcn_tmpl % "dummy"
+	    if m:
+		prog = fcn_tmpl % m + prog
+	    result = context.TryLink(prog, '.c')
+	    if result:
+		if not m:
+		    m = None
+		break
+	return result, m
 
 # XXX: refactor those by using function templates
 def CheckF77DummyMain(context):
@@ -333,15 +355,13 @@
                                     target = context.env.File(test_prog),
                                     source = context.lastTarget)
 
-	print cmd
         st, out = popen_wrapper(cmd, merge = True)
         if st:
             res = 0
         else:
             res = 1
-        cnt = out.split('\n')
-	print cnt
-	raise "YATA"
+	cnt = out.split('\n')
+	return res, cnt
 
 def _build_empty_program_posix(context, fcomp):
         oldLINK = context.env['LINK']

Modified: branches/numpy.scons/numpy/distutils/scons/tests/fortran_output.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/tests/fortran_output.py	2007-11-12 05:12:09 UTC (rev 4434)
+++ branches/numpy.scons/numpy/distutils/scons/tests/fortran_output.py	2007-11-12 07:32:05 UTC (rev 4435)
@@ -57,6 +57,9 @@
         '-L/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../', '-lifport',
         '-lifcore', '-limf', '-lm', '-lipgo', '-lirc', '-lirc_s', '-ldl']
 
+mingw_g77_link_output = """
+['Driving: g77 -v -o build\\scons\\numpy\\scons_fake\\checkers\\.sconf\\conftest_0 build\\scons\\numpy\\scons_fake\\checkers\\.sconf\\conftest_0.obj -lfrtbegin -lg2c', 'Reading specs from c:/MINGW/bin/../lib/gcc/mingw32/3.4.5/specs', 'Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug', 'Thread model: win32', 'gcc version 3.4.5 (mingw special)', ' c:/MINGW/bin/../libexec/gcc/mingw32/3.4.5/collect2.exe -Bdynamic -o build\\scons\\numpy\\scons_fake\\checkers\\.sconf\\conftest_0.exe /mingw/lib/crt2.o c:/MINGW/bin/../lib/gcc/mingw32/3.4.5/crtbegin.o -Lc:/MINGW/bin/../lib/gcc/mingw32/3.4.5 -Lc:/MINGW/bin/../lib/gcc -L/mingw/lib/gcc/mingw32/3.4.5 -Lc:/MINGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib -L/mingw/lib/gcc/mingw32/3.4.5/../../../../mingw32/lib -L/mingw/lib -Lc:/MINGW/bin/../lib/gcc/mingw32/3.4.5/../../.. -L/mingw/lib/gcc/mingw32/3.4.5/../../.. build\\scons\\numpy\\scons_fake\\checkers\\.sconf\\conftest_0.obj -lfrtbegin -lg2c -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt c:/MINGW/bin/../lib/gcc/mingw32/3.4.5/crtend.o', '']"""
+
 def generate_output(fcomp, verbose):
     import os
     os.system('%s -c %s &> /dev/null ' % (fcomp, 'empty.f'))



More information about the Numpy-svn mailing list