15 from SCons.Script
import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
17 from LumieraEnvironment
import *
18 from Buildhelper
import *
26 TOOLDIR =
'./admin/scons' 28 CUSTOPTFILE =
'custom-options' 31 buildExe =
'#$TARGDIR' 32 buildLib =
'#$TARGDIR/modules' 33 buildPlug =
'#$TARGDIR/modules' 34 buildIcon =
'#$TARGDIR/gui/icons' 35 buildUIRes =
'#$TARGDIR/gui/' 36 buildConf =
'#$TARGDIR/config' 37 installExe =
'#$DESTDIR/lib/lumiera' 38 installLib =
'#$DESTDIR/lib/lumiera/modules' 39 installPlug =
'#$DESTDIR/lib/lumiera/modules' 40 installIcon =
'#$DESTDIR/share/lumiera/icons' 41 installUIRes =
'#$DESTDIR/share/lumiera/' 42 installConf =
'#$DESTDIR/lib/lumiera/config' 45 buildSetup = Record(locals())
51 def defineBuildEnvironment():
52 """ create a custom build environment, 53 define the basic compiler and linker flags, 54 define locations in source and target tree, 55 parse the commandline and pick up options 57 EnsureSConsVersion(2,0)
58 EnsurePythonVersion(2,6)
59 Decider(
'MD5-timestamp')
61 buildVars = Variables([OPTCACHE, CUSTOPTFILE])
65 env.Replace( CPPPATH =[
"#src"]
66 , CPPDEFINES=[
'LUMIERA_VERSION='+VERSION ]
67 , CCFLAGS=
'-Wall -Wextra -Wformat-security' 68 , CXXFLAGS=
'-std=gnu++17 -Wno-enum-compare' 71 env.Append(LINKFLAGS=
'-Wl,--no-undefined')
72 env.Append(LINKFLAGS=
'-Wl,--as-needed')
73 handleVerboseMessages(env)
74 handleNoBugSwitches(env)
76 env.Append(CPPDEFINES =
'_GNU_SOURCE')
77 appendCppDefine(env,
'DEBUG',
'DEBUG',
'NDEBUG')
79 appendVal(env,
'ARCHFLAGS',
'CCFLAGS')
80 appendVal(env,
'OPTIMIZE',
'CCFLAGS', val=
' -O3')
81 appendVal(env,
'DEBUG',
'CCFLAGS', val=
' -ggdb')
84 appendCppDefine(env,
'PKGLIBDIR',
'LUMIERA_PLUGIN_PATH=\\"$PKGLIBDIR/:ORIGIN/modules\\"' 85 ,
'LUMIERA_PLUGIN_PATH=\\"ORIGIN/modules\\"')
86 appendCppDefine(env,
'PKGDATADIR',
'LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"' 87 ,
'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"')
90 buildVars.Save(OPTCACHE, env)
95 def appendCppDefine(env,var,cppVar, elseVal=''):
97 env.Append(CPPDEFINES = env.subst(cppVar) )
99 env.Append(CPPDEFINES = env.subst(elseVal))
101 def appendVal(env,var,targetVar,val=None):
103 env.Append( **{targetVar: env.subst(val)
or env[var]})
106 def handleNoBugSwitches(env):
107 """ set the build level for NoBug. 108 Release builds imply no DEBUG 109 whereas ALPHA and BETA require DEBUG 111 level = env[
'BUILDLEVEL']
112 if level
in [
'ALPHA',
'BETA']:
114 print 'Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!' 115 env.Replace( DEBUG = 1 )
116 env.Append(CPPDEFINES =
'EBUG_'+level)
117 elif level ==
'RELEASE':
118 env.Replace( DEBUG = 0 )
121 def handleVerboseMessages(env):
122 """ toggle verbose build output """ 123 if not env[
'VERBOSE']:
125 env[
'CCCOMSTR'] = env[
'SHCCCOMSTR'] =
" Compiling $SOURCE" 126 env[
'CXXCOMSTR'] = env[
'SHCXXCOMSTR'] =
" Compiling++ $SOURCE" 127 env[
'LINKCOMSTR'] =
" Linking --> $TARGET" 128 env[
'LDMODULECOMSTR'] =
" creating module [ $TARGET ]" def defineCmdlineVariables(buildVars)
def prepareOptionsHelp(buildVars, env)