2012-01-09 04:10:00 +01:00
|
|
|
# -*- python -*-
|
|
|
|
|
##
|
|
|
|
|
## Setup.py - SCons build: setup, definitions and compiler flags
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
# Copyright (C) Lumiera.org
|
|
|
|
|
# 2012, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
|
# published by the Free Software Foundation; either version 2 of
|
|
|
|
|
# the License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
#####################################################################
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
from SCons.Script import EnsurePythonVersion, EnsureSConsVersion, Variables, Decider
|
|
|
|
|
|
|
|
|
|
from LumieraEnvironment import *
|
|
|
|
|
from Buildhelper import *
|
|
|
|
|
import Options
|
2012-01-09 04:10:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
#-------------------------------------------------------Configuration
|
2012-01-09 04:10:00 +01:00
|
|
|
TARGDIR = 'target'
|
2015-11-02 21:31:01 +01:00
|
|
|
VERSION = '0.pre.03'
|
2012-01-09 04:10:00 +01:00
|
|
|
TOOLDIR = './admin/scons' # SCons plugins
|
|
|
|
|
OPTCACHE = 'optcache'
|
|
|
|
|
CUSTOPTFILE = 'custom-options'
|
|
|
|
|
|
|
|
|
|
# these are accessible via env.path.xxxx
|
|
|
|
|
buildExe = '#$TARGDIR'
|
|
|
|
|
buildLib = '#$TARGDIR/modules'
|
|
|
|
|
buildPlug = '#$TARGDIR/modules'
|
Global-Layer-Renaming: fix handling of GuiResources in the build
the new structure causes them now to be installed into $TARGET/stage
which is simply not what I want. I still consider $TARGET/gui the better choice,
since an administrator or packager is not aware of our layer namings.
The existing solution was half baked anyway, it did not really replicate the source tree.
On the other hand, I want to retain the location of the CSS files within the GUI tree,
since I consider it a good practice, to keep "code-like" resources with the actual code,
and not far away in some arcane "data" directory.
No I've noticed, that the env.GuiResource() function is only used once, for this very task.
So, for the time being, we can keep it simple and deditaced to that task, i.e
we pick up all CSS files we find and install it into a single target directory.
NOTE: this issue has brought to my attention two further, completely unrelated issues
* Ticket #1192 (Lumiera hangs on failed GUI start)
* The ProcDispatcher does an idle wait, due to an error in timed-wait implementation
2018-11-16 18:18:33 +01:00
|
|
|
buildIcon = '#$TARGDIR/gui/icons' # for IconResource() and IconRender()
|
|
|
|
|
buildUIRes = '#$TARGDIR/gui/' # for GuiResource()
|
|
|
|
|
buildConf = '#$TARGDIR/config' # for ConfigData()
|
2012-01-09 04:10:00 +01:00
|
|
|
installExe = '#$DESTDIR/lib/lumiera'
|
|
|
|
|
installLib = '#$DESTDIR/lib/lumiera/modules'
|
|
|
|
|
installPlug = '#$DESTDIR/lib/lumiera/modules'
|
|
|
|
|
installIcon = '#$DESTDIR/share/lumiera/icons'
|
|
|
|
|
installUIRes = '#$DESTDIR/share/lumiera/'
|
|
|
|
|
installConf = '#$DESTDIR/lib/lumiera/config'
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
#-------------------------------------------------------Configuration
|
|
|
|
|
buildSetup = Record(locals())
|
2012-01-09 04:10:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
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
|
2012-01-09 04:10:00 +01:00
|
|
|
"""
|
2013-10-06 05:20:22 +02:00
|
|
|
EnsureSConsVersion(2,0)
|
|
|
|
|
EnsurePythonVersion(2,6)
|
2012-01-10 05:09:32 +01:00
|
|
|
Decider('MD5-timestamp') # detect changed files by timestamp, then do a MD5
|
2012-01-09 04:10:00 +01:00
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
buildVars = Variables([OPTCACHE, CUSTOPTFILE])
|
|
|
|
|
Options.defineCmdlineVariables(buildVars)
|
|
|
|
|
env = LumieraEnvironment(buildSetup, buildVars)
|
2012-01-09 04:10:00 +01:00
|
|
|
|
|
|
|
|
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
|
2015-11-03 03:06:24 +01:00
|
|
|
, CCFLAGS='-Wall -Wextra -Wformat-security'
|
2020-02-21 21:08:31 +01:00
|
|
|
, CXXFLAGS='-std=gnu++17 -Wno-enum-compare'
|
2012-01-09 04:10:00 +01:00
|
|
|
, CFLAGS='-std=gnu99'
|
|
|
|
|
)
|
2013-11-02 23:59:13 +01:00
|
|
|
env.Append(LINKFLAGS='-Wl,--no-undefined') # require every dependency is given on link, in the right order
|
2014-09-30 04:40:24 +02:00
|
|
|
env.Append(LINKFLAGS='-Wl,--as-needed') # by default only link against dependencies actually needed to resolve symbols
|
2012-01-10 05:09:32 +01:00
|
|
|
handleVerboseMessages(env)
|
2012-01-09 04:10:00 +01:00
|
|
|
handleNoBugSwitches(env)
|
|
|
|
|
|
|
|
|
|
env.Append(CPPDEFINES = '_GNU_SOURCE')
|
|
|
|
|
appendCppDefine(env,'DEBUG','DEBUG', 'NDEBUG')
|
|
|
|
|
# appendCppDefine(env,'OPENGL','USE_OPENGL')
|
|
|
|
|
appendVal(env,'ARCHFLAGS','CCFLAGS') # for both C and C++
|
|
|
|
|
appendVal(env,'OPTIMIZE', 'CCFLAGS', val=' -O3')
|
|
|
|
|
appendVal(env,'DEBUG', 'CCFLAGS', val=' -ggdb')
|
|
|
|
|
|
|
|
|
|
# setup search path for Lumiera plugins
|
|
|
|
|
appendCppDefine(env,'PKGLIBDIR','LUMIERA_PLUGIN_PATH=\\"$PKGLIBDIR/:ORIGIN/modules\\"'
|
|
|
|
|
,'LUMIERA_PLUGIN_PATH=\\"ORIGIN/modules\\"')
|
|
|
|
|
appendCppDefine(env,'PKGDATADIR','LUMIERA_CONFIG_PATH=\\"$PKGLIBDIR/:.\\"'
|
|
|
|
|
,'LUMIERA_CONFIG_PATH=\\"$DESTDIR/share/lumiera/:.\\"')
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
Options.prepareOptionsHelp(buildVars,env)
|
|
|
|
|
buildVars.Save(OPTCACHE, env)
|
2012-01-09 04:10:00 +01:00
|
|
|
return env
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
|
|
|
|
|
|
2012-01-09 04:10:00 +01:00
|
|
|
def appendCppDefine(env,var,cppVar, elseVal=''):
|
|
|
|
|
if env[var]:
|
|
|
|
|
env.Append(CPPDEFINES = env.subst(cppVar) )
|
|
|
|
|
elif elseVal:
|
|
|
|
|
env.Append(CPPDEFINES = env.subst(elseVal))
|
|
|
|
|
|
|
|
|
|
def appendVal(env,var,targetVar,val=None):
|
|
|
|
|
if env[var]:
|
|
|
|
|
env.Append( **{targetVar: env.subst(val) or env[var]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handleNoBugSwitches(env):
|
|
|
|
|
""" set the build level for NoBug.
|
|
|
|
|
Release builds imply no DEBUG
|
|
|
|
|
whereas ALPHA and BETA require DEBUG
|
|
|
|
|
"""
|
|
|
|
|
level = env['BUILDLEVEL']
|
|
|
|
|
if level in ['ALPHA', 'BETA']:
|
|
|
|
|
if not env['DEBUG']:
|
|
|
|
|
print 'Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!'
|
|
|
|
|
env.Replace( DEBUG = 1 )
|
|
|
|
|
env.Append(CPPDEFINES = 'EBUG_'+level)
|
|
|
|
|
elif level == 'RELEASE':
|
|
|
|
|
env.Replace( DEBUG = 0 )
|
|
|
|
|
|
2012-01-10 05:09:32 +01:00
|
|
|
|
2012-01-09 04:10:00 +01:00
|
|
|
def handleVerboseMessages(env):
|
|
|
|
|
""" toggle verbose build output """
|
|
|
|
|
if not env['VERBOSE']:
|
2012-01-09 04:58:21 +01:00
|
|
|
# SetOption('silent', True)
|
|
|
|
|
env['CCCOMSTR'] = env['SHCCCOMSTR'] = " Compiling $SOURCE"
|
|
|
|
|
env['CXXCOMSTR'] = env['SHCXXCOMSTR'] = " Compiling++ $SOURCE"
|
|
|
|
|
env['LINKCOMSTR'] = " Linking --> $TARGET"
|
|
|
|
|
env['LDMODULECOMSTR'] = " creating module [ $TARGET ]"
|
2012-01-09 04:10:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|