Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
Setup.py
Go to the documentation of this file.
1# coding: utf-8
2
5
6# Copyright (C)
7# 2012-2025 Hermann Vosseler <Ichthyostega@web.de>
8#
9# **Lumiera** is free software; you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by the
11# Free Software Foundation; either version 2 of the License, or (at your
12# option) any later version. See the file COPYING for further details.
13
14
15from SCons.Script import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
16
17from LumieraEnvironment import *
18from Buildhelper import *
19import Options
20
21
22
23#-------------------------------------------------------Configuration
24TARGDIR = 'target'
25VERSION = '0.pre.04'
26TOOLDIR = './admin/scons' # SCons plugins
27OPTCACHE = 'optcache'
28CUSTOPTFILE = 'custom-options'
29
30# these are accessible via env.path.xxxx
31buildExe = '$TARGDIR'
32buildLib = '$TARGDIR/modules'
33buildPlug = '$TARGDIR/modules'
34buildIcon = '$TARGDIR/gui/icons' # for IconResource() and IconRender()
35buildUIRes = '$TARGDIR/gui/' # for GuiResource()
36buildConf = '$TARGDIR/config' # for ConfigData()
37installExe = '$DESTDIR/lib/lumiera'
38installLib = '$DESTDIR/lib/lumiera/modules'
39installPlug = '$DESTDIR/lib/lumiera/modules'
40installIcon = '$DESTDIR/share/lumiera/icons'
41installUIRes = '$DESTDIR/share/lumiera/'
42installConf = '$DESTDIR/lib/lumiera/config'
43installDoc = '$DESTDIR/share/doc/lumiera/'
44
45#-------------------------------------------------------Configuration
46
47buildSetup = Record(locals())
48# passed to LumieraEnvironment() -> env.path.xxxx
49
50
51
52
53
55 """ create a custom build environment,
56 define the basic compiler and linker flags,
57 define locations in source and target tree,
58 parse the commandline and pick up options
59 """
60 EnsureSConsVersion(4,0)
61 EnsurePythonVersion(3,10)
62 Decider('content-timestamp') # detect changed files by timestamp, then do a MD5
63
64 buildVars = Variables([OPTCACHE, CUSTOPTFILE])
66 env = LumieraEnvironment(buildSetup, buildVars)
67
68 env.Replace( CPPPATH =["#src"] # used to find includes, "#" means always absolute to build-root
69 , CPPDEFINES=['LUMIERA_VERSION='+VERSION ] # note: it's a list to append further defines
70 , CCFLAGS='-Wall -Wextra -Wformat-security'
71 , CXXFLAGS='-std=gnu++23 -Wno-enum-compare'
72 , CFLAGS='-std=gnu99'
73 )
74 env.Append(LINKFLAGS='-Wl,--no-undefined') # require every dependency is given on link, in the right order
75 env.Append(LINKFLAGS='-Wl,--as-needed') # by default only link against dependencies actually needed to resolve symbols
78
79 env.Append(CPPDEFINES = '_GNU_SOURCE')
80 appendCppDefine(env,'DEBUG','DEBUG', 'NDEBUG')
81# appendCppDefine(env,'OPENGL','USE_OPENGL')
82 appendVal(env,'ARCHFLAGS','CCFLAGS') # for both C and C++
83 appendVal(env,'OPTIMIZE', 'CCFLAGS', val=' -O3')
84 appendVal(env,'DEBUG', 'CCFLAGS', val=' -ggdb')
85
86 # NOTE: could define optional compile features here....
87
88 Options.prepareOptionsHelp(buildVars,env)
89 buildVars.Save(OPTCACHE, env)
90 return env
91
92
93
94def appendCppDefine(env,var,cppVar, elseVal=''):
95 if env[var]:
96 env.Append(CPPDEFINES = env.subst(cppVar) )
97 elif elseVal:
98 env.Append(CPPDEFINES = env.subst(elseVal))
99
100def appendVal(env,var,targetVar,val=None):
101 if env[var]:
102 env.Append( **{targetVar: env.subst(val) or env[var]})
103
104
106 """ set the build level for NoBug.
107 Release builds imply no DEBUG
108 whereas ALPHA and BETA require DEBUG
109 """
110 level = env['BUILDLEVEL']
111 if level in ['ALPHA', 'BETA']:
112 if not env['DEBUG']:
113 print('Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!')
114 env.Replace( DEBUG = 1 )
115 env.Append(CPPDEFINES = 'EBUG_'+level)
116 elif level == 'RELEASE':
117 env.Replace( DEBUG = 0 )
118
119
121 """ toggle verbose build output """
122 if not env['VERBOSE']:
123 # SetOption('silent', True)
124 env['CCCOMSTR'] = env['SHCCCOMSTR'] = " Compiling $SOURCE"
125 env['CXXCOMSTR'] = env['SHCXXCOMSTR'] = " Compiling++ $SOURCE"
126 env['LINKCOMSTR'] = " Linking --> $TARGET"
127 env['LDMODULECOMSTR'] = " creating module [ $TARGET ]"
128
129
130
a set of properties with record style access.
Custom SCons build environment for Lumiera This allows us to carry structured config data without usi...
prepareOptionsHelp(buildVars, env)
Definition Options.py:50
defineCmdlineVariables(buildVars)
several toggles and configuration variables can be set on the commandline, current settings will be p...
Definition Options.py:22
appendVal(env, var, targetVar, val=None)
Definition Setup.py:100
handleNoBugSwitches(env)
set the build level for NoBug.
Definition Setup.py:105
defineBuildEnvironment()
create a custom build environment, define the basic compiler and linker flags, define locations in so...
Definition Setup.py:54
handleVerboseMessages(env)
toggle verbose build output
Definition Setup.py:120
appendCppDefine(env, var, cppVar, elseVal='')
Definition Setup.py:94