base-cpp/SConstruct

61 lines
1.7 KiB
Text
Raw Normal View History

2014-01-30 14:08:11 -08:00
# SConstruct
# vim: set ft=python:
#
2014-01-30 15:42:25 -08:00
# Toplevel Scons build script. This should be mostly complete and generic enough
# for most builds.
2014-01-30 14:08:11 -08:00
#
# Eryn Wells <eryn@erynwells.me>
2014-01-30 15:09:28 -08:00
import os
2015-09-22 14:44:30 -07:00
import erw
2014-02-27 22:20:29 -08:00
BUILD_DIR = Dir('#build')
LIB_DIR = Dir('#lib')
SRC_DIR = Dir('#src')
TEST_DIR = Dir('#test')
2014-01-30 15:09:28 -08:00
2014-01-31 08:42:41 -08:00
2015-09-22 14:44:30 -07:00
def do_sconscript(env, src_dir, out_dir):
sconscript = src_dir.File('SConscript')
print 'Reading {}'.format(sconscript)
# Swapping env and build_env here is a bit wacky. Doing so means that env is
# always the Environment that the SConscript should be building with, while
# build_env is the Environment we're using to put everything together.
env.SConscript(sconscript,
2015-09-22 14:44:30 -07:00
{'env': env.Clone(), 'build_env': env},
variant_dir=out_dir)
2015-09-22 14:44:30 -07:00
BUILD_CMDS = get_bool_argument(ARGUMENTS.get('BUILD_CMDS', False))
MODE = ARGUMENTS.get('MODE', None)
2014-02-28 17:40:49 -08:00
2014-01-31 08:27:37 -08:00
modes = {
2015-09-22 14:44:30 -07:00
'debug': erw.DebugEnvironment(succinct=not BUILD_CMDS),
'beta': erw.BetaEnvironment(succinct=not BUILD_CMDS),
'release': erw.ReleaseEnvironment(succinct=not BUILD_CMDS),
2014-01-31 08:27:37 -08:00
}
2015-09-22 14:44:30 -07:00
for mode in (MODE.split(',') if MODE else ['debug']):
2014-01-31 08:27:37 -08:00
try:
env = modes[mode]
except KeyError:
2014-02-28 17:39:41 -08:00
print 'Skipping invalid mode: {}'.format(mode)
break
2015-09-22 14:44:30 -07:00
out_dir = BUILD_DIR.Dir(env['_name'])
# Process all lib dirs.
for lib in os.listdir(LIB_DIR.abspath):
lib_out_dir = out_dir.Dir('lib').Dir(lib)
2015-09-22 14:44:30 -07:00
do_sconscript(env, LIB_DIR.Dir(lib), lib_out_dir)
env.Append(LIBPATH=[lib_out_dir])
# Get source files.
src_out_dir = out_dir.Dir('src')
2015-09-22 14:44:30 -07:00
do_sconscript(env, SRC_DIR, src_out_dir)
env.Append(LIBPATH=[src_out_dir])
# Get test binaries.
2015-09-22 14:44:30 -07:00
do_sconscript(env, TEST_DIR, out_dir.Dir('test'))