reorganise the initial setup calls

This commit is contained in:
Fischlurch 2012-01-10 05:09:32 +01:00
parent 117851a94a
commit 4d466a2c2e
5 changed files with 52 additions and 83 deletions

View file

@ -39,7 +39,6 @@ import os
import sys import sys
sys.path.append(TOOLDIR) sys.path.append(TOOLDIR)
sys.path.append(SCRIPTDIR)
from Buildhelper import * from Buildhelper import *
from LumieraEnvironment import * from LumieraEnvironment import *
@ -52,10 +51,8 @@ import Platform
##################################################################### #####################################################################
env = Setup.setupBasicEnvironment() env = Setup.defineBuildEnvironment()
env = Platform.configure(env)
if not (isCleanupOperation(env) or isHelpRequest()):
env = Platform.configurePlatform(env)
##################################################################### #####################################################################

View file

@ -22,7 +22,6 @@
##################################################################### #####################################################################
import os
from os import path from os import path
import SCons import SCons
@ -38,9 +37,15 @@ class LumieraEnvironment(Environment):
This allows us to carry structured config data without This allows us to carry structured config data without
using global vars. Idea inspired by Ardour. using global vars. Idea inspired by Ardour.
""" """
def __init__(self, pathConfig, **kw): def __init__(self, buildSetup, buildVars, **kw):
Environment.__init__ (self,**kw) kw.update(VERSION = buildSetup.VERSION
self.path = Record (pathConfig) ,TARGDIR = buildSetup.TARGDIR
,DESTDIR = '$INSTALLDIR/$PREFIX'
,toolpath = [buildSetup.TOOLDIR ]
,variables = buildVars
)
Environment.__init__ (self, **kw)
self.path = Record (extract_localPathDefs(buildSetup)) # e.g. buildExe -> env.path.buildExe
self.libInfo = {} self.libInfo = {}
self.Tool("BuilderGCH") self.Tool("BuilderGCH")
self.Tool("BuilderDoxygen") self.Tool("BuilderDoxygen")
@ -49,6 +54,7 @@ class LumieraEnvironment(Environment):
register_LumieraResourceBuilder(self) register_LumieraResourceBuilder(self)
register_LumieraCustomBuilders(self) register_LumieraCustomBuilders(self)
def Configure (self, *args, **kw): def Configure (self, *args, **kw):
kw['env'] = self kw['env'] = self
return apply(LumieraConfigContext, args, kw) return apply(LumieraConfigContext, args, kw)

View file

@ -22,28 +22,19 @@
##################################################################### #####################################################################
from SCons.Script import PathVariable, EnumVariable, BoolVariable, Help
import os
import sys
from SCons.Script import *
from Buildhelper import *
from LumieraEnvironment import *
#####################################################################
def defineCmdlineVariables(vars):
def defineCmdlineVariables(buildVars):
""" several toggles and configuration variables can be set on the commandline, """ several toggles and configuration variables can be set on the commandline,
current settings will be persisted in a options cache file. current settings will be persisted in a options cache file.
you may define custom variable settings in a separate file. you may define custom variable settings in a separate file.
Commandline will override both. Commandline will override both.
""" """
vars.AddVariables( buildVars.AddVariables(
('ARCHFLAGS', 'Set architecture-specific compilation flags (passed literally to gcc)','') ('ARCHFLAGS', 'Set architecture-specific compilation flags (passed literally to gcc)','')
,('CC', 'Set the C compiler to use.', 'gcc') ,('CC', 'Set the C compiler to use.', 'gcc')
,('CXX', 'Set the C++ compiler to use.', 'g++') ,('CXX', 'Set the C++ compiler to use.', 'g++')
@ -64,11 +55,9 @@ def defineCmdlineVariables(vars):
,PathVariable('PKGDATADIR', 'Installation dir for default config, usually PREFIX/share/lumiera', '',PathVariable.PathAccept) ,PathVariable('PKGDATADIR', 'Installation dir for default config, usually PREFIX/share/lumiera', '',PathVariable.PathAccept)
) )
return vars
def prepareOptionsHelp(buildVars,env):
def prepareOptionsHelp(vars,env):
prelude = """ prelude = """
USAGE: scons [-c] [OPTS] [key=val [key=val...]] [TARGETS] USAGE: scons [-c] [OPTS] [key=val [key=val...]] [TARGETS]
Build and optionally install Lumiera. Build and optionally install Lumiera.
@ -86,7 +75,7 @@ Special Targets:
Configuration Options: Configuration Options:
""" """
Help(prelude + vars.GenerateHelpText(env)) Help(prelude + buildVars.GenerateHelpText(env))

View file

@ -22,32 +22,22 @@
##################################################################### #####################################################################
# NOTE: scons -h for help.
# Read more about the SCons build system at: http://www.scons.org
# Basically, this script just /defines/ the components and how they
# fit together. SCons will derive the necessary build steps.
import os
import sys
from SCons.Script import Exit from SCons.Script import Exit
from Buildhelper import isCleanupOperation, isHelpRequest
from Buildhelper import *
from LumieraEnvironment import *
def configure(env):
def configurePlatform(env): """ locate required libraries.
""" locate required libs.
setup platform specific options. setup platform specific options.
Abort build in case of failure. Abort build in case of failure.
""" """
if isCleanupOperation(env) or isHelpRequest():
return env # skip configure in these cases
conf = env.Configure() conf = env.Configure()
# run all configuration checks in the given env # run all configuration checks in the build environment defined thus far
# Perform checks for prerequisites -------------------------------------------- # Perform checks for prerequisites --------------------------------------------
problems = [] problems = []
@ -63,11 +53,11 @@ def configurePlatform(env):
if not conf.CheckLibWithHeader('pthread', 'pthread.h', 'C'): if not conf.CheckLibWithHeader('pthread', 'pthread.h', 'C'):
problems.append('Did not find the pthread lib or pthread.h.') problems.append('Did not find the pthread lib or pthread.h.')
else: else:
conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD') conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD')
conf.env.Append(CCFLAGS = ' -pthread') conf.env.Append(CCFLAGS = ' -pthread')
if conf.CheckCHeader('execinfo.h'): if conf.CheckCHeader('execinfo.h'):
conf.env.Append(CPPFLAGS = ' -DHAVE_EXECINFO_H') conf.env.Append(CPPFLAGS = ' -DHAVE_EXECINFO_H')
if conf.CheckCHeader('valgrind/valgrind.h'): if conf.CheckCHeader('valgrind/valgrind.h'):
conf.env.Append(CPPFLAGS = ' -DHAVE_VALGRIND_H') conf.env.Append(CPPFLAGS = ' -DHAVE_VALGRIND_H')

View file

@ -21,14 +21,15 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##################################################################### #####################################################################
from SCons.Script import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
# NOTE: scons -h for help. from LumieraEnvironment import *
# Read more about the SCons build system at: http://www.scons.org from Buildhelper import *
# Basically, this script just /defines/ the components and how they import Options
# fit together. SCons will derive the necessary build steps.
#-----------------------------------Configuration
#-------------------------------------------------------Configuration
TARGDIR = 'target' TARGDIR = 'target'
VERSION = '0.pre.01' VERSION = '0.pre.01'
TOOLDIR = './admin/scons' # SCons plugins TOOLDIR = './admin/scons' # SCons plugins
@ -51,50 +52,33 @@ installIcon = '#$DESTDIR/share/lumiera/icons'
installUIRes = '#$DESTDIR/share/lumiera/' installUIRes = '#$DESTDIR/share/lumiera/'
installConf = '#$DESTDIR/lib/lumiera/config' installConf = '#$DESTDIR/lib/lumiera/config'
#-----------------------------------Configuration #-------------------------------------------------------Configuration
localDefinitions = locals() buildSetup = Record(locals())
import os
import sys
from SCons.Script import * def defineBuildEnvironment():
""" create a custom build environment,
from Options import * define the basic compiler and linker flags,
define locations in source and target tree,
from Buildhelper import * parse the commandline and pick up options
from LumieraEnvironment import *
#####################################################################
def setupBasicEnvironment():
""" define cmdline options, build type decisions
""" """
EnsurePythonVersion(2,4)
EnsureSConsVersion(1,0) EnsureSConsVersion(1,0)
EnsurePythonVersion(2,4)
Decider('MD5-timestamp') # detect changed files by timestamp, then do a MD5
Decider('MD5-timestamp') # detect changed files by timestamp, then do a MD5 buildVars = Variables([OPTCACHE, CUSTOPTFILE])
Options.defineCmdlineVariables(buildVars)
vars = Variables([OPTCACHE, CUSTOPTFILE]) env = LumieraEnvironment(buildSetup, buildVars)
vars = defineCmdlineVariables(vars)
env = LumieraEnvironment(variables=vars
,toolpath = [TOOLDIR]
,pathConfig = extract_localPathDefs(localDefinitions) # e.g. buildExe -> env.path.buildExe
,TARGDIR = TARGDIR
,DESTDIR = '$INSTALLDIR/$PREFIX'
,VERSION = VERSION
)
handleVerboseMessages(env)
env.Replace( CPPPATH =["#src"] # used to find includes, "#" means always absolute to build-root env.Replace( CPPPATH =["#src"] # used to find includes, "#" means always absolute to build-root
, CPPDEFINES=['LUMIERA_VERSION='+VERSION ] # note: it's a list to append further defines , CPPDEFINES=['LUMIERA_VERSION='+VERSION ] # note: it's a list to append further defines
, CCFLAGS='-Wall -Wextra ' , CCFLAGS='-Wall -Wextra '
, CFLAGS='-std=gnu99' , CFLAGS='-std=gnu99'
) )
handleVerboseMessages(env)
handleNoBugSwitches(env) handleNoBugSwitches(env)
env.Append(CPPDEFINES = '_GNU_SOURCE') env.Append(CPPDEFINES = '_GNU_SOURCE')
@ -110,10 +94,12 @@ def setupBasicEnvironment():
appendCppDefine(env,'PKGDATADIR','LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"' appendCppDefine(env,'PKGDATADIR','LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"'
,'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"') ,'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"')
prepareOptionsHelp(vars,env) Options.prepareOptionsHelp(buildVars,env)
vars.Save(OPTCACHE, env) buildVars.Save(OPTCACHE, env)
return env return env
def appendCppDefine(env,var,cppVar, elseVal=''): def appendCppDefine(env,var,cppVar, elseVal=''):
if env[var]: if env[var]:
env.Append(CPPDEFINES = env.subst(cppVar) ) env.Append(CPPDEFINES = env.subst(cppVar) )
@ -139,6 +125,7 @@ def handleNoBugSwitches(env):
elif level == 'RELEASE': elif level == 'RELEASE':
env.Replace( DEBUG = 0 ) env.Replace( DEBUG = 0 )
def handleVerboseMessages(env): def handleVerboseMessages(env):
""" toggle verbose build output """ """ toggle verbose build output """
if not env['VERBOSE']: if not env['VERBOSE']: