diff options
author | Michele Calgaro <[email protected]> | 2020-06-13 22:45:28 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2020-06-13 22:45:28 +0900 |
commit | 5f44f7b187093ef290315b7f8766b540a31de35f (patch) | |
tree | 27ffb7b218199ca04f240c390c52426c65f45dce /scons/generic.py | |
download | codeine-5f44f7b187093ef290315b7f8766b540a31de35f.tar.gz codeine-5f44f7b187093ef290315b7f8766b540a31de35f.zip |
Initial code import from debian snapshot
https://snapshot.debian.org/package/codeine/1.0.1-3.dfsg-3.1/
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'scons/generic.py')
-rw-r--r-- | scons/generic.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/scons/generic.py b/scons/generic.py new file mode 100644 index 0000000..3249df7 --- /dev/null +++ b/scons/generic.py @@ -0,0 +1,95 @@ +## Thomas Nagy, 2005 + +""" +Detect and store the most common options +* kdecxxflags : debug=1 (-g) or debug=full (-g3, slower) + else use the user CXXFLAGS if any, - or -O2 by default +* prefix : the installation path +* extraincludes : a list of paths separated by ':' +ie: scons configure debug=full prefix=/usr/local extraincludes=/tmp/include:/usr/local +""" + +BOLD ="\033[1m" +RED ="\033[91m" +GREEN ="\033[92m" +YELLOW ="\033[93m" +CYAN ="\033[96m" +NORMAL ="\033[0m" + +import os + +def exists(env): + return true + +def generate(env): + env.Help(""" +"""+BOLD+ +"""*** Generic options *** +-----------------------"""+NORMAL+""" +"""+BOLD+"""* debug """+NORMAL+""": debug=1 (-g) or debug=full (-g3, slower) else use environment CXXFLAGS, or -O2 by default +"""+BOLD+"""* prefix """+NORMAL+""": the installation path +"""+BOLD+"""* extraincludes """+NORMAL+""": a list of paths separated by ':' +ie: """+BOLD+"""scons configure debug=full prefix=/usr/local extraincludes=/tmp/include:/usr/local +"""+NORMAL) + + # load the options + from SCons.Options import Options, PathOption + opts = Options('generic.cache.py') + opts.AddOptions( + ( 'KDECXXFLAGS', 'debug level for the project : full or just anything' ), + ( 'PREFIX', 'prefix for installation' ), + ( 'EXTRAINCLUDES', 'extra include paths for the project' ), + ) + opts.Update(env) + + # use this to avoid an error message 'how to make target configure ?' + env.Alias('configure', None) + + # configure the environment if needed + if 'configure' in env['TARGS'] or not env.has_key('KDECXXFLAGS'): + # need debugging ? + if env.has_key('KDECXXFLAGS'): + env.__delitem__('KDECXXFLAGS') + if env['ARGS'].get('debug', None): + debuglevel = env['ARGS'].get('debug', None) + print CYAN+'** Enabling debug for the project **' + NORMAL + if (debuglevel == "full"): + env['KDECXXFLAGS'] = ['-DDEBUG', '-ggdb', '-pipe', '-Wall'] + else: + env['KDECXXFLAGS'] = ['-DDEBUG', '-g'] + else: + if os.environ.has_key('CXXFLAGS'): + # user-defined flags (gentooers will be delighted) + import SCons.Util + env['KDECXXFLAGS'] = SCons.Util.CLVar( os.environ['CXXFLAGS'] ) + env.Append( KDECXXFLAGS = ['-DNDEBUG', '-DNO_DEBUG'] ) + else: + env.Append(KDECXXFLAGS = ['-O2', '-DNDEBUG', '-DNO_DEBUG']) + + # user-specified prefix + if env['ARGS'].get('prefix', None): + env['PREFIX'] = env['ARGS'].get('prefix', None) + print CYAN+'** set the installation prefix for the project : ' + env['PREFIX'] +' **'+ NORMAL + elif env.has_key('PREFIX'): + env.__delitem__('PREFIX') + + # user-specified include paths + env['EXTRAINCLUDES'] = env['ARGS'].get('extraincludes', None) + if env['ARGS'].get('extraincludes', None): + print CYAN+'** set extra include paths for the project : ' + env['EXTRAINCLUDES'] +' **'+ NORMAL + elif env.has_key('EXTRAINCLUDES'): + env.__delitem__('EXTRAINCLUDES') + + # and finally save the options in a cache + opts.Save('generic.cache.py', env) + + if env.has_key('KDECXXFLAGS'): + # load the flags + env.AppendUnique( CPPFLAGS = env['KDECXXFLAGS'] ) + + if env.has_key('EXTRAINCLUDES'): + incpaths = [] + for dir in str(env['EXTRAINCLUDES']).split(':'): + incpaths.append( dir ) + env.Append(CPPPATH = incpaths) + |