24 from SCons.Script
import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
26 from LumieraEnvironment
import *
27 from Buildhelper
import *
35 TOOLDIR =
'./admin/scons' 37 CUSTOPTFILE =
'custom-options' 40 buildExe =
'#$TARGDIR' 41 buildLib =
'#$TARGDIR/modules' 42 buildPlug =
'#$TARGDIR/modules' 43 buildIcon =
'#$TARGDIR/gui/icons' 44 buildUIRes =
'#$TARGDIR/gui/' 45 buildConf =
'#$TARGDIR/config' 46 installExe =
'#$DESTDIR/lib/lumiera' 47 installLib =
'#$DESTDIR/lib/lumiera/modules' 48 installPlug =
'#$DESTDIR/lib/lumiera/modules' 49 installIcon =
'#$DESTDIR/share/lumiera/icons' 50 installUIRes =
'#$DESTDIR/share/lumiera/' 51 installConf =
'#$DESTDIR/lib/lumiera/config' 54 buildSetup = Record(locals())
60 def defineBuildEnvironment():
61 """ create a custom build environment, 62 define the basic compiler and linker flags, 63 define locations in source and target tree, 64 parse the commandline and pick up options 66 EnsureSConsVersion(2,0)
67 EnsurePythonVersion(2,6)
68 Decider(
'MD5-timestamp')
70 buildVars = Variables([OPTCACHE, CUSTOPTFILE])
74 env.Replace( CPPPATH =[
"#src"]
75 , CPPDEFINES=[
'LUMIERA_VERSION='+VERSION ]
76 , CCFLAGS=
'-Wall -Wextra -Wformat-security' 77 , CXXFLAGS=
'-std=gnu++17 -Wno-enum-compare' 80 env.Append(LINKFLAGS=
'-Wl,--no-undefined')
81 env.Append(LINKFLAGS=
'-Wl,--as-needed')
82 handleVerboseMessages(env)
83 handleNoBugSwitches(env)
85 env.Append(CPPDEFINES =
'_GNU_SOURCE')
86 appendCppDefine(env,
'DEBUG',
'DEBUG',
'NDEBUG')
88 appendVal(env,
'ARCHFLAGS',
'CCFLAGS')
89 appendVal(env,
'OPTIMIZE',
'CCFLAGS', val=
' -O3')
90 appendVal(env,
'DEBUG',
'CCFLAGS', val=
' -ggdb')
93 appendCppDefine(env,
'PKGLIBDIR',
'LUMIERA_PLUGIN_PATH=\\"$PKGLIBDIR/:ORIGIN/modules\\"' 94 ,
'LUMIERA_PLUGIN_PATH=\\"ORIGIN/modules\\"')
95 appendCppDefine(env,
'PKGDATADIR',
'LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"' 96 ,
'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"')
99 buildVars.Save(OPTCACHE, env)
104 def appendCppDefine(env,var,cppVar, elseVal=''):
106 env.Append(CPPDEFINES = env.subst(cppVar) )
108 env.Append(CPPDEFINES = env.subst(elseVal))
110 def appendVal(env,var,targetVar,val=None):
112 env.Append( **{targetVar: env.subst(val)
or env[var]})
115 def handleNoBugSwitches(env):
116 """ set the build level for NoBug. 117 Release builds imply no DEBUG 118 whereas ALPHA and BETA require DEBUG 120 level = env[
'BUILDLEVEL']
121 if level
in [
'ALPHA',
'BETA']:
123 print 'Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!' 124 env.Replace( DEBUG = 1 )
125 env.Append(CPPDEFINES =
'EBUG_'+level)
126 elif level ==
'RELEASE':
127 env.Replace( DEBUG = 0 )
130 def handleVerboseMessages(env):
131 """ toggle verbose build output """ 132 if not env[
'VERBOSE']:
134 env[
'CCCOMSTR'] = env[
'SHCCCOMSTR'] =
" Compiling $SOURCE" 135 env[
'CXXCOMSTR'] = env[
'SHCXXCOMSTR'] =
" Compiling++ $SOURCE" 136 env[
'LINKCOMSTR'] =
" Linking --> $TARGET" 137 env[
'LDMODULECOMSTR'] =
" creating module [ $TARGET ]" def defineCmdlineVariables(buildVars)
def prepareOptionsHelp(buildVars, env)