/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 398 by johnpye, Fri Mar 31 07:55:11 2006 UTC revision 400 by johnpye, Fri Mar 31 10:59:36 2006 UTC
# Line 78  opts.Add( Line 78  opts.Add(
78          +" 'c:\msys\1.0\home\john\swigwin-1.3.29\swig.exe'."          +" 'c:\msys\1.0\home\john\swigwin-1.3.29\swig.exe'."
79  )  )
80    
81  # Where will the 'Makefile.bt' file be installed  # Build the test suite?
82    opts.Add(BoolOption(
83  # TODO: add install options      'WITH_CUNIT_TESTS'
84        ,"Whether to build the CUnit tests. Default is off. If set to on,"
85            +" you must have CUnit installed somewhere that SCons can"
86            +" find it."
87        ,False
88    ))
89    
90    # Where are the CUnit includes?
91    opts.Add(PackageOption(
92        'CUNIT_CPPPATH'
93        ,"Where are your CUnit include files?"
94        ,"off"
95    ))
96    
97    # Where are the CUnit includes?
98    opts.Add(PackageOption(
99        'CUNIT_LIBPATH'
100        ,"Where are your CUnit include files?"
101        ,"off"
102    ))
103    
104  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
105    
# Line 88  opts.Add( Line 107  opts.Add(
107    
108  # TODO: turning on/off bintoken functionality  # TODO: turning on/off bintoken functionality
109    
110    # TODO: Where will the 'Makefile.bt' file be installed
111    # ....
112    
113  opts.Update(env)  opts.Update(env)
114  opts.Save('options.cache',env)  opts.Save('options.cache',env)
115    
# Line 99  with_tcltk_gui = (env['WITHOUT_TCLTK_GUI Line 121  with_tcltk_gui = (env['WITHOUT_TCLTK_GUI
121    
122  with_python = (env['WITHOUT_PYTHON']==False)  with_python = (env['WITHOUT_PYTHON']==False)
123    
124    with_cunit_tests = env['WITH_CUNIT_TESTS']
125    
126  print "SOLVERS:",env['WITH_SOLVERS']  print "SOLVERS:",env['WITH_SOLVERS']
127    
128  print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']  print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']
# Line 121  env.Append(SUBST_DICT=subst_dict) Line 145  env.Append(SUBST_DICT=subst_dict)
145  #------------------------------------------------------  #------------------------------------------------------
146  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
147    
148    #----------------
149    # SWIG
150    
151  import os,re  import os,re
152    
153  def CheckSwigVersion(context):  def CheckSwigVersion(context):
# Line 142  def CheckSwigVersion(context): Line 169  def CheckSwigVersion(context):
169      pat = int(m.group('pat'))      pat = int(m.group('pat'))
170            
171      if maj == 1 and (      if maj == 1 and (
172              min > 1              min > 3
173              or (min == 1 and pat >= 24)              or (min == 3 and pat >= 24)
174          ):          ):
175          context.Result("ok, %d.%d.%d" % (maj,min,pat))          context.Result("ok, %d.%d.%d" % (maj,min,pat))
176          return 1;          return 1;
177      context.Result("ok, %d.%d.%d" % (maj,min,pat))      context.Result("ok, %d.%d.%d" % (maj,min,pat))
178      return 0;      return 0;
179    
180    #----------------
181    # General purpose library-and-header test
182    
183    
184    def CheckExtLib(context,libname,text,ext='.c',varprefix=None):
185        """This method will check for variables LIBNAME_LIBPATH
186        and LIBNAME_CPPPATH and try to compile and link the
187        file with the provided text, linking with the
188        library libname."""
189    
190        context.Message( 'Checking for '+libname+'...' )
191        
192        if varprefix==None:
193            varprefix = libname.upper()
194        
195        keep = {}
196        for k in ['LIBS','LIBPATH','CPPPATH']:
197            if context.env.has_key(k):
198                keep[k] = context.env[k]
199        
200        libpath_add = []
201        if context.env.has_key(varprefix+'_LIBPATH'):
202            libpath_add = [env[varprefix+'_LIBPATH']]
203    
204        cpppath_add = []
205        if context.env.has_key(varprefix+'_CPPPATH'):
206            cpppath_add = [env[varprefix+'_CPPPATH']]
207        
208        context.env.Append(
209            LIBS = libname
210            , LIBPATH = libpath_add
211            , CPPPATH = cpppath_add
212        )
213        ret = context.TryLink(cunit_test_text,ext)
214    
215        for k in keep:
216            context.env[k]=keep[k];
217    
218        context.Result( ret )
219        return ret
220    
221    cunit_test_text = """
222    #include <CUnit/Cunit.h>
223    int maxi(int i1, int i2){
224        return (i1 > i2) ? i1 : i2;
225    }
226    
227    void test_maxi(void){
228        CU_ASSERT(maxi(0,2) == 2);
229        CU_ASSERT(maxi(0,-2) == 0);
230        CU_ASSERT(maxi(2,2) == 2);
231    
232    }
233    int main(void){
234    /*  CU_initialize_registry() */
235    }
236    """
237    
238    def CheckCUnit(context):
239        return CheckExtLib(context
240            ,'cunit'
241            ,cunit_test_text
242        )
243    
244            
245  #------------------------------------------------------  #------------------------------------------------------
246  # CONFIGURATION  # CONFIGURATION
247    
248  conf = Configure(env  conf = Configure(env
249      , custom_tests = {      , custom_tests = {
 #       'CheckIsNan' : CheckIsNan  
 #       ,'CheckCppUnitConfig' : CheckCppUnitConfig  
250          'CheckSwigVersion' : CheckSwigVersion          'CheckSwigVersion' : CheckSwigVersion
251            , 'CheckCUnit' : CheckCUnit
252    #       , 'CheckIsNan' : CheckIsNan
253    #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
254      }      }
255      , config_h = "config.h"      , config_h = "config.h"
256  )  )
# Line 190  if not conf.CheckLib('tcl'): Line 283  if not conf.CheckLib('tcl'):
283  if not conf.CheckLib('tk'):  if not conf.CheckLib('tk'):
284      with_tcktk_gui = False      with_tcktk_gui = False
285    
   
286  # Python... obviously we're already running python, so we just need to  # Python... obviously we're already running python, so we just need to
287  # check that we can link to the python library OK:  # check that we can link to the python library OK:
288    
# Line 215  else: Line 307  else:
307  #   with_python = False  #   with_python = False
308  #else:  #else:
309    
   
310  # SWIG version  # SWIG version
311    
312  if platform.system()=="Windows":  if platform.system()=="Windows":
# Line 224  if platform.system()=="Windows": Line 315  if platform.system()=="Windows":
315  else:  else:
316      env['ENV']['SWIGFEATURES']='-O'      env['ENV']['SWIGFEATURES']='-O'
317    
318    # CUnit
319    
320    if with_cunit_tests:
321        conf.CheckCUnit()
322    
323  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
324    
325  # TODO: check size of void*  # TODO: check size of void*
# Line 342  if with_python: Line 438  if with_python:
438      env.SConscript(['pygtk/interface/SConscript'],'env')      env.SConscript(['pygtk/interface/SConscript'],'env')
439  else:  else:
440      print "Skipping... Python GUI isn't being built"      print "Skipping... Python GUI isn't being built"
441    
442    if with_cunit_tests:
443        testdirs = ['general','solver','utilities']
444        for testdir in testdirs:
445            path = 'base/generic/'+testdir+'/test/'
446            env.SConscript([path+'SConscript'],'env')
447        env.SConscript(['test/SConscript'],'env')
448        env.SConscript(['base/generic/test/SConscript'],'env')
449        
450        
451    else:
452        print "Skipping... CUnit tests aren't being built"
453    
454    #------------------------------------------------------
455    # INSTALLATION
456    
457    # TODO: add install options

Legend:
Removed from v.398  
changed lines
  Added in v.400

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22