[Numpy-svn] r4436 - branches/numpy.scons/numpy/distutils/scons

numpy-svn@scip... numpy-svn@scip...
Mon Nov 12 02:42:23 CST 2007


Author: cdavid
Date: 2007-11-12 02:42:18 -0600 (Mon, 12 Nov 2007)
New Revision: 4436

Modified:
   branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
Log:
mangling checks now works with g77 and Visual Studio

Modified: branches/numpy.scons/numpy/distutils/scons/fortran_scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-11-12 07:32:05 UTC (rev 4435)
+++ branches/numpy.scons/numpy/distutils/scons/fortran_scons.py	2007-11-12 08:42:18 UTC (rev 4436)
@@ -188,7 +188,37 @@
 def _CheckFMangling(context, fc, dummym, ext):
     # XXX: rewrite this in a more straightfoward manner, and support prepending
     # underscore
-    subr = """
+    env = context.env
+    # TODO: if does not exist, call the function to get the F77_DUMMY_MAIN
+    if not built_with_mstools(env):
+	    savedLINK = env.has_key('LINK') and deepcopy(env['LINK']) or []
+	    savedLIBS = env.has_key('LIBS') and deepcopy(env['LIBS']) or []
+	    try:
+		env['LINK'] = env[fc]
+		result, mangler, u, du, c = _check_f_mangling_imp(context, fc, dummym, ext)
+	    finally:
+		env.Replace(LINK = savedLINK)
+		env.Replace(LIBS = savedLIBS)
+    else:
+	    # XXX: instead of recreating our own build commands, can we use the
+	    # ones from scons ? (defined in Tools directory)
+	    savedLINKCOM = env.has_key('LINKCOM') and deepcopy(env['LINKCOM']) or []
+	    savedLIBLINKPREFFIX = env.has_key('LIBLINKPREFFIX') and deepcopy(env['LIBLINKPREFFIX']) or []
+	    savedLIBLINKSUFFIX = env.has_key('LIBLINKSUFFIX') and deepcopy(env['LIBLINKSUFFIX']) or []
+	    savedLIBS = env.has_key('LIBS') and deepcopy(env['LIBS']) or []
+	    try:
+		env['LINKCOM'] = '$%s -o $TARGET $SOURCES $_LIBFLAGS' % fc
+		result, mangler, u, du, c = _check_f_mangling_imp(context, fc, dummym, ext)
+ 	    finally:
+		env.Replace(LINKCOM = savedLINKCOM)
+		env.Replace(LIBS = savedLIBS)
+		env.Replace(LIBLINKPREFFIX = savedLIBLINKPREFFIX)
+		env.Replace(LIBLINKSUFFIX = savedLIBLINKSUFFIX)
+    return result, mangler, u, du, c
+
+def _check_f_mangling_imp(context, fc, m, ext):
+    	env = context.env
+    	subr = """
       subroutine foobar()
       return
       end
@@ -196,10 +226,10 @@
       return
       end
 """
-    main_tmpl = """
+    	main_tmpl = """
 int %s() { return 1; }
 """
-    prog_tmpl = """
+    	prog_tmpl = """
 void %s(void);
 void %s(void);
 int my_main() {
@@ -208,13 +238,6 @@
     return 0;
 }
 """
-    env = context.env
-    savedLINK = env.has_key('LINK') and deepcopy(env['LINK']) or []
-    savedLIBS = env.has_key('LIBS') and deepcopy(env['LIBS']) or []
-    # TODO: if does not exist, call the function to get the F77_DUMMY_MAIN
-    m = dummym
-    try:
-        env['LINK'] = env[fc]
         # variants:
         #   lower-case, no underscore, no double underscore: foobar, foo_bar
         #   ...
@@ -244,11 +267,9 @@
             except StopIteration:
                 result = mangler = u = du = c = None
                 break
-    finally:
-        env.Replace(LINK = savedLINK)
-        env.Replace(LIBS = savedLIBS)
-    return result, mangler, u, du, c
 
+	return result, mangler, u, du, c
+
 def _set_mangling_var(context, u, du, case, type = 'F77'):
     env = context.env
     if du == '_':



More information about the Numpy-svn mailing list