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

numpy-svn@scip... numpy-svn@scip...
Tue Oct 30 11:21:09 CDT 2007


Author: cdavid
Date: 2007-10-30 11:21:04 -0500 (Tue, 30 Oct 2007)
New Revision: 4361

Modified:
   branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
   branches/numpy.scons/numpy/distutils/scons/checkers/support.py
Log:
Use the refactored check_header in libperf checkers

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-10-30 14:27:00 UTC (rev 4360)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-10-30 16:21:04 UTC (rev 4361)
@@ -71,7 +71,9 @@
     env = context.env
     env.AppendUnique(LIBS = 'atlas')
 
-    # Check whether the library is available
+    # Check whether the library is available (CheckLib-like checker)
+
+    # Check version if requested
     version_code = """
 void ATL_buildinfo(void);
 int main(void) {

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/support.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-10-30 14:27:00 UTC (rev 4360)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-10-30 16:21:04 UTC (rev 4361)
@@ -38,7 +38,7 @@
         else:
             self.linkflags = []
 
-def _check_headers(context, cpppath, cflags, headers):
+def _check_headers(context, cpppath, cflags, headers, autoadd):
     """Try to compile code including the given headers."""
     env = context.env
 
@@ -58,13 +58,41 @@
     src = '\n'.join(hcode)
 
     ret = context.TryCompile(src, '.c')
-    if not ret:
+    if ret == 0 or autoadd == 0:
         env.Replace(CPPPATH = oldCPPPATH)
         env.Replace(CFLAGS = oldCFLAGS)
         return 0
 
     return ret
 
+def _check_libs(context, cpppath, headers, cflags, libpath, libs, linkflags, autoadd):
+    raise NotImplementedError("FIXME")
+    #------------------------------
+    # Check a simple example works
+    #------------------------------
+    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
+    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
+    oldLINKFLAGS = (env.has_key('LINKFLAGS') and deepcopy(env['LINKFLAGS'])) or []
+    # # XXX: RPATH, drawbacks using it ?
+    # oldRPATH = (env.has_key('RPATH') and deepcopy(env['RPATH'])) or []
+    env.AppendUnique(LIBPATH = libpath)
+    env.AppendUnique(LIBS = libs)
+    #env.AppendUnique(RPATH = libpath)
+    env.AppendUnique(LINKFLAGS = linkflags)
+
+    # HACK: we add libpath and libs at the end of the source as a comment, to
+    # add dependency of the check on those.
+    src = '\n'.join(['#include <%s>' % h for h in headers] +\
+                    [run_src, '#if 0', '%s' % libpath, 
+                     '%s' % headers, '%s' % libs, '#endif'])
+    ret = context.TryLink(src, '.c')
+    if (not ret or not autoadd):
+        # If test failed or autoadd = 0, restore everything
+        env.Replace(LIBS = oldLIBS)
+        env.Replace(LIBPATH = oldLIBPATH)
+        env.Replace(RPATH = oldRPATH)
+        env.Replace(LINKFLAGS = oldLINKFLAGS)
+
 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"
@@ -88,27 +116,9 @@
     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)
-
-    # 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)
+    if not ret:
+         context.Result('Failed: %s include not found' % name)
 
     #------------------------------
     # Check a simple example works
@@ -145,4 +155,4 @@
      
 def check_lib(context, library = None, symbols = None, headers = None, language = 'C'):
     if language is not 'C':
-        raise NotImplementedError('FIXME: support languages')
+        raise NotImplementedError('FIXME: support non-C languages')



More information about the Numpy-svn mailing list