add some convenience shortcuts to the SCons build system

This commit is contained in:
Fischlurch 2008-07-10 19:02:47 +02:00
parent 012944a461
commit ce90f1763b
5 changed files with 117 additions and 22 deletions

2
.gitignore vendored
View file

@ -5,7 +5,7 @@
*.os
*.gch
,valgrind.log*
Buildhelper.pyc
admin/scons/*.pyc
optcache
Makefile.in
build/*

View file

@ -26,6 +26,8 @@ sys.path.append("./admin/scons")
import os
from Buildhelper import *
from LumieraEnvironment import *
#-----------------------------------Configuration
OPTIONSCACHEFILE = 'optcache'
@ -53,9 +55,8 @@ def setupBasicEnvironment():
EnsureSConsVersion(0,96,90)
opts = defineCmdlineOptions()
env = Environment(options=opts)
env = LumieraEnvironment(options=opts)
env.Append ( CCCOM=' -std=gnu99') # workaround for a bug: CCCOM currently doesn't honor CFLAGS, only CCFLAGS
env.Replace( VERSION=VERSION
, SRCDIR=SRCDIR
@ -74,7 +75,7 @@ def setupBasicEnvironment():
appendVal(env,'ARCHFLAGS', 'CCFLAGS') # for both C and C++
appendVal(env,'OPTIMIZE', 'CCFLAGS', val=' -O3')
appendVal(env,'DEBUG', 'CCFLAGS', val=' -ggdb')
prepareOptionsHelp(opts,env)
opts.Save(OPTIONSCACHEFILE, env)
return env
@ -127,7 +128,7 @@ def defineCmdlineOptions():
,PathOption('SRCTAR', 'Create source tarball prior to compiling', '..', PathOption.PathAccept)
,PathOption('DOCTAR', 'Create tarball with dev documentaionl', '..', PathOption.PathAccept)
)
return opts
@ -161,38 +162,42 @@ def configurePlatform(env):
setup platform specific options.
Abort build in case of failure.
"""
conf = Configure(env)
# run all configuration checks in the current env
conf = env.Configure()
# run all configuration checks in the given env
# Perform checks for prerequisites --------------------------------------------
if not conf.TryAction('pkg-config --version > $TARGET')[0]:
print 'We need pkg-config for including library configurations, exiting.'
Exit(1)
# Checks for prerequisites ------------
if not conf.CheckLibWithHeader('m', 'math.h','C'):
print 'Did not find math.h / libm, exiting.'
Exit(1)
if not conf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'):
print 'Functions for runtime dynamic loading not available, exiting.'
Exit(1)
if not conf.CheckLibWithHeader('nobugmt', 'nobug.h', 'C'):
print 'Did not find NoBug [http://www.pipapo.org/pipawiki/NoBug], exiting.'
Exit(1)
if not conf.CheckLibWithHeader('pthread', 'pthread.h', 'C'):
print 'Did not find the pthread lib or pthread.h, exiting.'
else:
conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD')
conf.env.Append(CCFLAGS = ' -pthread')
if conf.CheckCHeader('execinfo.h'):
conf.env.Append(CPPFLAGS = ' -DHAS_EXECINFO_H')
if conf.CheckCHeader('valgrind/valgrind.h'):
conf.env.Append(CPPFLAGS = ' -DHAS_VALGRIND_VALGIND_H')
if not conf.CheckCXXHeader('tr1/memory'):
print 'We rely on the std::tr1 proposed standard extension for shared_ptr.'
Exit(1)
if not conf.CheckCXXHeader('boost/config.hpp'):
print 'We need the C++ boost-lib.'
Exit(1)
@ -221,7 +226,7 @@ def definePackagingTargets(env, artifacts):
artifacts['src.tar'] = t
env.Alias('src.tar', t)
env.Alias('tar', t)
t = Tarball(env,location='$DOCTAR',suffix='-doc',dirs='admin doc wiki uml tests')
artifacts['doc.tar'] = t
env.Alias('doc.tar', t)
@ -276,7 +281,7 @@ def definePostBuildTargets(env, artifacts):
# additional files to be cleaned when cleaning 'build'
env.Clean ('build', [ 'scache.conf', '.sconf_temp', '.sconsign.dblite', 'config.log' ])
env.Clean ('build', [ '$SRCDIR/pre.gch' ])
# Doxygen documentation
# Note: at the moment we only depend on Doxyfile
# obviousely, we should depend on all sourcefiles

View file

@ -111,7 +111,7 @@ def RegisterPrecompiledHeader_Builder(env):
def Tarball(env,location,dirs,suffix=''):
""" Custom Command: create Tarball of some subdirs
location: where to create the tar (optionally incl. filename.tar.gz)
location: where to create the tar (may optionally include filename.tar.gz)
suffix: (optional) suffix to include in the tar name
dirs: directories to include in the tar
@ -132,7 +132,7 @@ def Tarball(env,location,dirs,suffix=''):
def createTarball(target,source,env):
""" helper, builds the tar using the python2.3 tarfil lib.
""" helper, builds the tar using the python2.3 tarfile lib.
This allows us to prefix all paths, thus moving the tree
into a virtual subdirectory containing the Version number,
as needed by common packaging systems.

View file

@ -0,0 +1,92 @@
# -*- python -*-
##
## LumieraEnvironment.py - custom SCons Environment
##
# Copyright (C) Lumiera.org
# 2008, Hermann Vosseler <Ichthyostega@web.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#####################################################################
from SCons.SConf import SConf
from SCons.Environment import Environment
from Buildhelper import *
class LumieraEnvironment(Environment):
""" Custom SCons build environment for Lumiera
This allows us to carry structured config data without
using global vars. Idea inspired by Ardour.
"""
def __init__(self,*args,**kw):
Environment.__init__ (self,*args,**kw)
self.libInfo = {}
def Configure (self, *args, **kw):
kw['env'] = self
return apply(LumieraConfigContext, args, kw)
def mergeConf (self,other):
""" extract the library/compiler flags from other Environment.
Optionally accepts a list or just sting(s) representing keys
in our own libInfo Dictionary
"""
if isinstance(other, list):
for elm in other:
self.mergeConf(elm)
elif isinstance(other, str):
if not other in self.libInfo:
raise "Lib-info '%s' not available" % other
else:
self.mergeConf(self.libInfo[other])
else:
self.Append (LIBS = other.get ('LIBS',[]))
self.Append (LIBPATH = other.get ('LIBPATH', []))
self.Append (CPPPATH = other.get('CPPPATH', []))
self.Append (LINKFLAGS = other.get('LINKFLAGS', []))
def addLibInfo (self, libID, minVersion=0):
""" use pkg-config to create an Environment describing the lib.
Don't add this defs to the current Environment, rather store
them in the libInfo Dictionary.
"""
minVersion = str(minVersion)
if 0 != os.system('pkg-config --print-errors --exists "%s >= %s"' % (libID,minVersion)):
print "Problems configuring the Library %s (>= %s)" % (libID,minVersion)
return False
self.libInfo[libID] = libInfo = LumieraEnvironment()
libInfo.ParseConfig ('pkg-config --cflags --libs '+ libID )
return libInfo
class LumieraConfigContext(SConf):
""" Extends the SCons Configure context with some convenience methods
"""
def __init__(self, *args,**kw):
SConf.__init__(self,*args,**kw)
def CheckPkgConfig (self, libID, minVersion=0):
print "Checking for library configuration: %s " % libID
# self.Message(self,"Checking for library configuration: %s " % libID)
return self.env.addLibInfo (libID, minVersion)

View file

@ -114,8 +114,7 @@ liblumiprocmobjectbuilder_a_SOURCES = \
$(liblumiprocmobjectbuilder_a_srcdir)/assembler.cpp \
$(liblumiprocmobjectbuilder_a_srcdir)/conmanager.cpp \
$(liblumiprocmobjectbuilder_a_srcdir)/nodecreatertool.cpp \
$(liblumiprocmobjectbuilder_a_srcdir)/segmentationtool.cpp \
$(liblumiprocmobjectbuilder_a_srcdir)/toolfactory.cpp
$(liblumiprocmobjectbuilder_a_srcdir)/segmentationtool.cpp
liblumiprocmobjectcontroller_a_srcdir = $(top_srcdir)/src/proc/mobject/controller
@ -209,7 +208,6 @@ noinst_HEADERS += \
$(liblumiproc_a_srcdir)/mobject/builder/conmanager.hpp \
$(liblumiproc_a_srcdir)/mobject/builder/nodecreatertool.hpp \
$(liblumiproc_a_srcdir)/mobject/builder/segmentationtool.hpp \
$(liblumiproc_a_srcdir)/mobject/builder/toolfactory.hpp \
$(liblumiproc_a_srcdir)/mobject/builderfacade.hpp \
$(liblumiproc_a_srcdir)/mobject/controller/pathmanager.hpp \
$(liblumiproc_a_srcdir)/mobject/controller/renderstate.hpp \