@@ -92,6 +92,7 @@ def createCustomPlugins( self, sources=[], libs=[] ):
9292 dir_output = 'undefined' #
9393 dir_output_bin = 'undefined' # name generated depending on compilation type,
9494 dir_output_lib = 'undefined' # we need to know if we are in debug mode, etc.
95+ dir_output_plugin = 'undefined'
9596 dir_output_header = 'undefined' # (options needs to be initilized)
9697 dir_output_test = 'undefined' #
9798 dir_sconsProject = os .path .abspath (os .path .dirname (__file__ )) # directory containing this file
@@ -106,6 +107,7 @@ def createCustomPlugins( self, sources=[], libs=[] ):
106107 'packaging' ,
107108 'doxygen' ,
108109 'unittest' ,
110+ 'scripttest' ,
109111 ] + (['msvs' ] if windows else []),
110112 toolpath = [os .path .join (dir_sconsProject ,'tools' )] )
111113
@@ -199,6 +201,7 @@ def printInfos(self):
199201 print ':: dir = ' + self .dir
200202 print ':: dir_output_build = ' + self .dir_output_build
201203 print ':: dir_output_bin = ' + self .dir_output_bin
204+ print ':: dir_output_plugin = ' + self .dir_output_plugin
202205 print ':: dir_output_lib = ' + self .dir_output_lib
203206 print ':: dir_output_test = ' + self .dir_output_test
204207 print ':: dir_sconsProject = ' + self .dir_sconsProject
@@ -396,6 +399,15 @@ def inOutputBin(self, *dirs):
396399 l_dirs = SCons .Util .flatten (dirs )
397400 return [ self .inOutputBin (d ) for d in l_dirs ]
398401
402+ def inOutputPlugin (self , * dirs ):
403+ '''Returns "dirs" as subdirectories of "outputPlugin".'''
404+ if not dirs :
405+ return self .dir_output_plugin
406+ if len (dirs ) == 1 and isinstance (dirs [0 ], str ):
407+ return os .path .join ( self .inOutputPlugin (), dirs [0 ] )
408+ l_dirs = SCons .Util .flatten (dirs )
409+ return [ self .inOutputPlugin (d ) for d in l_dirs ]
410+
399411 def inOutputTest (self , * dirs ):
400412 '''Returns "dirs" as subdirectories of "outputTest".'''
401413 if not dirs :
@@ -444,6 +456,8 @@ def initOptions(self):
444456 Read options from configuration files and at last from the command line
445457 (which has the last word)
446458 '''
459+
460+ self .env .Tool ('default' )
447461 # default values
448462 if self .windows :
449463 self .compiler = compiler .visual
@@ -468,11 +482,12 @@ def initOptions(self):
468482 else :
469483 self .env ['CCVERSION' ] = self .compiler .version (self .env ['CC' ])
470484 self .env ['CXXVERSION' ] = self .compiler .version (self .env ['CXX' ])
471-
485+
472486 # select the environment from user options
473487 compilerName = self .env ['compiler' ]
474488 self .compiler = eval ( 'compiler.' + compilerName )
475489 self .CC = self .compiler .CC
490+
476491 if self .windows :
477492 if compilerName == 'visual' :
478493 self .env .Tool ('default' )
@@ -482,8 +497,6 @@ def initOptions(self):
482497 else :
483498 self .env .Tool ('default' )
484499 print 'Error: Unrecognized compiler value on this platform. (' + str (compilerName )+ ')'
485- else :
486- self .env .Tool ('default' )
487500
488501 def createOptions (self , filename , args ):
489502 '''
@@ -514,6 +527,9 @@ def help_format(env, opt, help, default, actual, aliases):
514527 opts .Add ('CC' , 'Specify the C Compiler' , self .compiler .ccBin )
515528 opts .Add ('CXX' , 'Specify the C++ Compiler' , self .compiler .cxxBin )
516529
530+ opts .Add ('SCRIPTTESTXX' , 'Specify the script test binary' , "nosetests" )
531+ opts .Add ('SCRIPTTESTFLAGS' , 'Specify the script test flags' , "" )
532+
517533 opts .Add ('ENVINC' , 'Additional include path (at compilation)' , [] if not self .windows else os .environ .get ('INCLUDE' , '' ).split (':' ))
518534 opts .Add ('ENVPATH' , 'Additional bin path (at compilation)' , [])
519535 opts .Add ('ENVLIBPATH' , 'Additional librairie path (at compilation)' , [] if not self .windows else os .environ .get ('LIB' , '' ).split (':' ))
@@ -615,6 +631,7 @@ def applyOptionsOnProject(self):
615631 self .dir_output = install_dir
616632 self .dir_output_bin = os .path .join (install_dir , 'bin' )
617633 self .dir_output_lib = os .path .join (install_dir , 'lib' )
634+ self .dir_output_plugin = os .path .join (install_dir , 'plugin' )
618635 self .dir_output_header = os .path .join (install_dir , 'include' )
619636 self .dir_output_test = os .path .join (install_dir , 'test' )
620637
@@ -1388,7 +1405,7 @@ def UnitTest( self, target=None, sources=[], dirs=[], env=None, libraries=[], in
13881405 l_sources += self .scanFiles ( l_dirs , accept , reject , inBuildDir = True )
13891406
13901407 if not l_sources :
1391- raise RuntimeError ( 'No source files for the target: ' + l_target )
1408+ raise RuntimeError ( 'No source files for the target: ' + str ( l_target ) )
13921409
13931410 localEnv = None
13941411 localLibraries = l_libraries
@@ -1415,6 +1432,51 @@ def UnitTest( self, target=None, sources=[], dirs=[], env=None, libraries=[], in
14151432
14161433 return dst
14171434
1435+ def ScriptTests ( self , target = None , sources = [], dirs = [], env = None , libraries = [], dependencies = [], envFlags = {}, procEnvFlags = {},
1436+ accept = ['test*.py' ], reject = ['@' ] ):
1437+ '''
1438+ This target is a list of python script files to execute.
1439+ '''
1440+ l_target = target
1441+ if target is None :
1442+ l_target = self .getDirs (0 )
1443+
1444+ l_sources = self .asList (sources )
1445+ l_dirs = self .asList (dirs )
1446+ l_libraries = self .asList (libraries )
1447+ l_dependencies = self .asList (dependencies )
1448+
1449+ if l_dirs :
1450+ l_sources += self .scanFiles ( l_dirs , accept , reject , inBuildDir = True )
1451+
1452+ if not l_sources :
1453+ raise RuntimeError ( 'No source files for the target: ' + str (l_target ) )
1454+
1455+ localEnv = None
1456+ localLibraries = l_libraries
1457+ if env :
1458+ localEnv = env .Clone ()
1459+ if 'SconsProjectLibraries' in localEnv :
1460+ localLibraries += localEnv ['SconsProjectLibraries' ]
1461+ self .appendLibsToEnv (localEnv , localLibraries )
1462+ else :
1463+ # if no environment we create a new one
1464+ localEnv = self .createEnv ( localLibraries , name = '-' .join (l_target ) )
1465+
1466+ if envFlags :
1467+ localEnv .AppendUnique ( ** envFlags )
1468+ if procEnvFlags :
1469+ for k , v in procEnvFlags .iteritems ():
1470+ localEnv .PrependENVPath ( k , v )
1471+
1472+ # create the target
1473+ allDst = []
1474+ for s in l_sources :
1475+ dst = localEnv .ScriptTest ( source = s , target = l_target )
1476+ allDst .append (dst )
1477+
1478+ return dst
1479+
14181480#-------------------- Automatic file/directory search -------------------------#
14191481 def asList (self , v ):
14201482 '''Return v inside a list if not a list.'''
0 commit comments