reorganise the initial setup calls
This commit is contained in:
parent
117851a94a
commit
4d466a2c2e
5 changed files with 52 additions and 83 deletions
|
|
@ -39,7 +39,6 @@ import os
|
|||
import sys
|
||||
|
||||
sys.path.append(TOOLDIR)
|
||||
sys.path.append(SCRIPTDIR)
|
||||
|
||||
from Buildhelper import *
|
||||
from LumieraEnvironment import *
|
||||
|
|
@ -52,10 +51,8 @@ import Platform
|
|||
|
||||
#####################################################################
|
||||
|
||||
env = Setup.setupBasicEnvironment()
|
||||
|
||||
if not (isCleanupOperation(env) or isHelpRequest()):
|
||||
env = Platform.configurePlatform(env)
|
||||
env = Setup.defineBuildEnvironment()
|
||||
env = Platform.configure(env)
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#####################################################################
|
||||
|
||||
|
||||
import os
|
||||
from os import path
|
||||
|
||||
import SCons
|
||||
|
|
@ -38,9 +37,15 @@ class LumieraEnvironment(Environment):
|
|||
This allows us to carry structured config data without
|
||||
using global vars. Idea inspired by Ardour.
|
||||
"""
|
||||
def __init__(self, pathConfig, **kw):
|
||||
Environment.__init__ (self,**kw)
|
||||
self.path = Record (pathConfig)
|
||||
def __init__(self, buildSetup, buildVars, **kw):
|
||||
kw.update(VERSION = buildSetup.VERSION
|
||||
,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.Tool("BuilderGCH")
|
||||
self.Tool("BuilderDoxygen")
|
||||
|
|
@ -49,6 +54,7 @@ class LumieraEnvironment(Environment):
|
|||
register_LumieraResourceBuilder(self)
|
||||
register_LumieraCustomBuilders(self)
|
||||
|
||||
|
||||
def Configure (self, *args, **kw):
|
||||
kw['env'] = self
|
||||
return apply(LumieraConfigContext, args, kw)
|
||||
|
|
|
|||
|
|
@ -22,28 +22,19 @@
|
|||
#####################################################################
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from SCons.Script import *
|
||||
|
||||
from Buildhelper import *
|
||||
from LumieraEnvironment import *
|
||||
|
||||
|
||||
#####################################################################
|
||||
from SCons.Script import PathVariable, EnumVariable, BoolVariable, Help
|
||||
|
||||
|
||||
|
||||
|
||||
def defineCmdlineVariables(vars):
|
||||
|
||||
def defineCmdlineVariables(buildVars):
|
||||
""" several toggles and configuration variables can be set on the commandline,
|
||||
current settings will be persisted in a options cache file.
|
||||
you may define custom variable settings in a separate file.
|
||||
Commandline will override both.
|
||||
"""
|
||||
vars.AddVariables(
|
||||
buildVars.AddVariables(
|
||||
('ARCHFLAGS', 'Set architecture-specific compilation flags (passed literally to gcc)','')
|
||||
,('CC', 'Set the C compiler to use.', 'gcc')
|
||||
,('CXX', 'Set the C++ compiler to use.', 'g++')
|
||||
|
|
@ -63,12 +54,10 @@ def defineCmdlineVariables(vars):
|
|||
,PathVariable('PKGLIBDIR', 'Installation dir for plugins, defaults to PREFIX/lib/lumiera/modules', '',PathVariable.PathAccept)
|
||||
,PathVariable('PKGDATADIR', 'Installation dir for default config, usually PREFIX/share/lumiera', '',PathVariable.PathAccept)
|
||||
)
|
||||
|
||||
return vars
|
||||
|
||||
|
||||
|
||||
def prepareOptionsHelp(vars,env):
|
||||
def prepareOptionsHelp(buildVars,env):
|
||||
prelude = """
|
||||
USAGE: scons [-c] [OPTS] [key=val [key=val...]] [TARGETS]
|
||||
Build and optionally install Lumiera.
|
||||
|
|
@ -86,7 +75,7 @@ Special Targets:
|
|||
|
||||
Configuration Options:
|
||||
"""
|
||||
Help(prelude + vars.GenerateHelpText(env))
|
||||
Help(prelude + buildVars.GenerateHelpText(env))
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 Buildhelper import *
|
||||
from LumieraEnvironment import *
|
||||
from Buildhelper import isCleanupOperation, isHelpRequest
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def configurePlatform(env):
|
||||
""" locate required libs.
|
||||
def configure(env):
|
||||
""" locate required libraries.
|
||||
setup platform specific options.
|
||||
Abort build in case of failure.
|
||||
"""
|
||||
if isCleanupOperation(env) or isHelpRequest():
|
||||
return env # skip configure in these cases
|
||||
|
||||
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 --------------------------------------------
|
||||
problems = []
|
||||
|
|
@ -63,11 +53,11 @@ def configurePlatform(env):
|
|||
if not conf.CheckLibWithHeader('pthread', 'pthread.h', 'C'):
|
||||
problems.append('Did not find the pthread lib or pthread.h.')
|
||||
else:
|
||||
conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD')
|
||||
conf.env.Append(CCFLAGS = ' -pthread')
|
||||
conf.env.Append(CPPFLAGS = ' -DHAVE_PTHREAD')
|
||||
conf.env.Append(CCFLAGS = ' -pthread')
|
||||
|
||||
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'):
|
||||
conf.env.Append(CPPFLAGS = ' -DHAVE_VALGRIND_H')
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#####################################################################
|
||||
|
||||
from SCons.Script import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
|
||||
|
||||
# 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.
|
||||
from LumieraEnvironment import *
|
||||
from Buildhelper import *
|
||||
import Options
|
||||
|
||||
|
||||
#-----------------------------------Configuration
|
||||
|
||||
#-------------------------------------------------------Configuration
|
||||
TARGDIR = 'target'
|
||||
VERSION = '0.pre.01'
|
||||
TOOLDIR = './admin/scons' # SCons plugins
|
||||
|
|
@ -51,50 +52,33 @@ installIcon = '#$DESTDIR/share/lumiera/icons'
|
|||
installUIRes = '#$DESTDIR/share/lumiera/'
|
||||
installConf = '#$DESTDIR/lib/lumiera/config'
|
||||
|
||||
#-----------------------------------Configuration
|
||||
localDefinitions = locals()
|
||||
#-------------------------------------------------------Configuration
|
||||
buildSetup = Record(locals())
|
||||
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from SCons.Script import *
|
||||
|
||||
from Options import *
|
||||
|
||||
from Buildhelper import *
|
||||
from LumieraEnvironment import *
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
def setupBasicEnvironment():
|
||||
""" define cmdline options, build type decisions
|
||||
def defineBuildEnvironment():
|
||||
""" create a custom build environment,
|
||||
define the basic compiler and linker flags,
|
||||
define locations in source and target tree,
|
||||
parse the commandline and pick up options
|
||||
"""
|
||||
EnsurePythonVersion(2,4)
|
||||
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
|
||||
|
||||
vars = Variables([OPTCACHE, CUSTOPTFILE])
|
||||
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)
|
||||
buildVars = Variables([OPTCACHE, CUSTOPTFILE])
|
||||
Options.defineCmdlineVariables(buildVars)
|
||||
env = LumieraEnvironment(buildSetup, buildVars)
|
||||
|
||||
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
|
||||
, CCFLAGS='-Wall -Wextra '
|
||||
, CFLAGS='-std=gnu99'
|
||||
)
|
||||
handleVerboseMessages(env)
|
||||
handleNoBugSwitches(env)
|
||||
|
||||
env.Append(CPPDEFINES = '_GNU_SOURCE')
|
||||
|
|
@ -110,10 +94,12 @@ def setupBasicEnvironment():
|
|||
appendCppDefine(env,'PKGDATADIR','LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"'
|
||||
,'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"')
|
||||
|
||||
prepareOptionsHelp(vars,env)
|
||||
vars.Save(OPTCACHE, env)
|
||||
Options.prepareOptionsHelp(buildVars,env)
|
||||
buildVars.Save(OPTCACHE, env)
|
||||
return env
|
||||
|
||||
|
||||
|
||||
def appendCppDefine(env,var,cppVar, elseVal=''):
|
||||
if env[var]:
|
||||
env.Append(CPPDEFINES = env.subst(cppVar) )
|
||||
|
|
@ -139,6 +125,7 @@ def handleNoBugSwitches(env):
|
|||
elif level == 'RELEASE':
|
||||
env.Replace( DEBUG = 0 )
|
||||
|
||||
|
||||
def handleVerboseMessages(env):
|
||||
""" toggle verbose build output """
|
||||
if not env['VERBOSE']:
|
||||
|
|
|
|||
Loading…
Reference in a new issue