[Numpy-svn] r4360 - branches/numpy.scons/numpy/distutils/scons/checkers

numpy-svn@scip... numpy-svn@scip...
Tue Oct 30 09:27:05 CDT 2007


Author: cdavid
Date: 2007-10-30 09:27:00 -0500 (Tue, 30 Oct 2007)
New Revision: 4360

Modified:
   branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
   branches/numpy.scons/numpy/distutils/scons/checkers/support.py
Log:
Put checking header in a separate function for reuse.

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-10-30 12:22:10 UTC (rev 4359)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-10-30 14:27:00 UTC (rev 4360)
@@ -62,11 +62,16 @@
 def _CheckATLASVersion(context):
     pass
 
-def CheckATLAS2(context, autoadd = 1):
+def CheckATLAS2(context, check_version = 1, autoadd = 1):
     """Check whether ATLAS is usable in C."""
     opts = CheckOptions(libs = ['atlas'])
 
     context.Message("Checking ATLAS ... ")
+
+    env = context.env
+    env.AppendUnique(LIBS = 'atlas')
+
+    # Check whether the library is available
     version_code = """
 void ATL_buildinfo(void);
 int main(void) {
@@ -74,8 +79,6 @@
   return 0;
 }
 """
-    env = context.env
-    env.AppendUnique(LIBS = 'atlas')
     if not context.TryLink(version_code, '.c'):
         return "blas blas"
 

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/support.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-10-30 12:22:10 UTC (rev 4359)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-10-30 14:27:00 UTC (rev 4360)
@@ -38,6 +38,33 @@
         else:
             self.linkflags = []
 
+def _check_headers(context, cpppath, cflags, headers):
+    """Try to compile code including the given headers."""
+    env = context.env
+
+    #----------------------------
+    # Check headers are available
+    #----------------------------
+    oldCPPPATH = (env.has_key('CPPPATH') and deepcopy(env['CPPPATH'])) or []
+    oldCFLAGS = (env.has_key('CFLAGS') and deepcopy(env['CFLAGS'])) or []
+    env.AppendUnique(CPPPATH = cpppath)
+    env.AppendUnique(CFLAGS = cflags)
+    # XXX: handle context
+    hcode = ['#include <%s>' % h for h in headers]
+
+    # HACK: we add cpppath in the command of the source, to add dependency of
+    # the check on the cpppath.
+    hcode.extend(['#if 0', '%s' % cpppath, '#endif\n'])
+    src = '\n'.join(hcode)
+
+    ret = context.TryCompile(src, '.c')
+    if not ret:
+        env.Replace(CPPPATH = oldCPPPATH)
+        env.Replace(CFLAGS = oldCFLAGS)
+        return 0
+
+    return ret
+
 def check_include_and_run(context, name, cpppath, headers, run_src, libs,
                           libpath, linkflags, cflags, autoadd = 1):
     """This is a basic implementation for generic "test include and run"
@@ -57,29 +84,31 @@
         - libs: list of libraries to link
         - libpath: list of library path.
         - linkflags: list of link flags to add."""
+
     context.Message('Checking for %s ... ' % name)
     env = context.env
 
-    #----------------------------
-    # Check headers are available
-    #----------------------------
-    oldCPPPATH = (env.has_key('CPPPATH') and deepcopy(env['CPPPATH'])) or []
-    oldCFLAGS = (env.has_key('CFLAGS') and deepcopy(env['CFLAGS'])) or []
-    env.AppendUnique(CPPPATH = cpppath)
-    env.AppendUnique(CFLAGS = cflags)
-    # XXX: handle context
-    hcode = ['#include <%s>' % h for h in headers]
-    # HACK: we add cpppath in the command of the source, to add dependency of
-    # the check on the cpppath.
-    hcode.extend(['#if 0', '%s' % cpppath, '#endif\n'])
-    src = '\n'.join(hcode)
+    # #----------------------------
+    # # Check headers are available
+    # #----------------------------
+    # oldCPPPATH = (env.has_key('CPPPATH') and deepcopy(env['CPPPATH'])) or []
+    # oldCFLAGS = (env.has_key('CFLAGS') and deepcopy(env['CFLAGS'])) or []
+    # env.AppendUnique(CPPPATH = cpppath)
+    # env.AppendUnique(CFLAGS = cflags)
+    # # XXX: handle context
+    # hcode = ['#include <%s>' % h for h in headers]
+    # # HACK: we add cpppath in the command of the source, to add dependency of
+    # # the check on the cpppath.
+    # hcode.extend(['#if 0', '%s' % cpppath, '#endif\n'])
+    # src = '\n'.join(hcode)
 
-    ret = context.TryCompile(src, '.c')
-    if not ret:
-        env.Replace(CPPPATH = oldCPPPATH)
-        env.Replace(CFLAGS = oldCFLAGS)
-        context.Result('Failed: %s include not found' % name)
-        return 0
+    # ret = context.TryCompile(src, '.c')
+    # if not ret:
+    #     env.Replace(CPPPATH = oldCPPPATH)
+    #     env.Replace(CFLAGS = oldCFLAGS)
+    #     context.Result('Failed: %s include not found' % name)
+    #     return 0
+    ret = _check_headers(context, cpppath, cflags, headers)
 
     #------------------------------
     # Check a simple example works
@@ -114,3 +143,6 @@
     context.Result(ret)
     return ret
      
+def check_lib(context, library = None, symbols = None, headers = None, language = 'C'):
+    if language is not 'C':
+        raise NotImplementedError('FIXME: support languages')



More information about the Numpy-svn mailing list