Skip to content

Commit 516da79

Browse files
committed
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into precompiled_header_proposal
2 parents 08d679a + 2765030 commit 516da79

File tree

13 files changed

+316
-84
lines changed

13 files changed

+316
-84
lines changed

__init__.py

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.'''

autoconf/boost_atomic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from _external import *
2+
from boost import *
3+
4+
boost_atomic = HeaderChecker(
5+
'boost_atomic',
6+
['boost/atomic.hpp'],
7+
'c++',
8+
dependencies=[boost] )
9+

autoconf/boost_thread.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from _external import *
22
from boost import *
3+
from boost_system import *
34

4-
boost_thread = LibWithHeaderChecker( 'boost_thread', 'boost/thread.hpp', 'c++',
5-
name='boost_thread', dependencies=[boost] )
5+
boost_thread = LibWithHeaderChecker(
6+
'boost_thread',
7+
'boost/thread.hpp',
8+
'c++',
9+
name='boost_thread',
10+
dependencies=[boost, boost_system]
11+
)
612

autoconf/corefoundation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from _external import *
2+
3+
corefoundation = LibWithHeaderChecker('CoreFoundation',
4+
'CoreFoundation.h',
5+
'c++',
6+
name='corefoundation')

autoconf/freeglut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from glu import *
44

55
freeglut = LibWithHeaderChecker(
6-
'freeglut',
6+
'glut',
77
['GL/freeglut.h'],
88
'c',
99
dependencies=[gl,glu]

autoconf/numpy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from _external import *
2+
3+
numpy = LibWithHeaderChecker( name='numpy',
4+
libs='npymath',
5+
header='numpy/numpyconfig.h',
6+
language='c')

autoconf/openimageio.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
from _external import *
2+
from boost_filesystem import *
3+
from boost_regex import *
4+
from boost_system import *
5+
from boost_thread import *
6+
from half import *
27
from dl import *
38

49
openimageio = LibWithHeaderChecker(
510
['OpenImageIO'], 'imageio.h', 'c++',
611
name='openimageio',
712
call='',
8-
dependencies =[dl] )
13+
dependencies = [
14+
boost_filesystem,
15+
boost_regex,
16+
boost_system,
17+
boost_thread,
18+
half,
19+
dl] )
920

1021

autoconf/raw.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _external import *
2+
from m import *
23
from gomp import *
34
from littlecms import *
45

@@ -7,6 +8,7 @@
78
'libraw/libraw.h',
89
'c',
910
dependencies = [
11+
m,
1012
gomp,
1113
littlecms,
1214
]

autoconf/turbojpeg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from _external import *
2+
3+
turbojpeg = LibWithHeaderChecker('turbojpeg', ['turbojpeg.h'], 'c')

compiler/gcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
linkBin = ccBin
1313
linkxxBin = cxxBin
1414

15-
def version( bin = 'gcc' ):
15+
def version( bin = ccBin ):
1616
import subprocess
1717
try:
1818
return subprocess.Popen( [bin, CC['version']], stdout=subprocess.PIPE, stderr=subprocess.PIPE ).communicate()[0].strip()

0 commit comments

Comments
 (0)