Package: cuppa
A simple, extensible build system for use withScons.Cuppais designed to leverage the
capabilities of Scons, while allowing developers to focus on the task of
describing what needs to be built. In generalcuppasupportsmakelike usage on the command-line. That is developers can simply
write:scons-Dand have Scons “do the right thing”; building targets for anysconscriptfiles found in the current directory.Cuppacan be installed as a normal python package or installed
locally into asite_sconsdirectory allowing it to be effortlessly
integrated into any Scons setup.Note:-Dtellssconsto look for ansconstructfile in
the current or in parent directories and if it finds one execute thesconscriptfiles as if called from that directory. This ensures
everything works as expected. For more details refer to theScons
documentationQuick IntroGetcuppaThe simpest way to getcuppais topip installit using:pip install cuppaSamplesconstructfileLet’s look at a minimalsconstructthat makes use ofcuppa. It
could look like this:# Pull in all the Cuppa goodies..importcuppa# Call sconscripts to do the workcuppa.run()Calling therunmethod in thecuppamodule starts the build
process callingsconscriptfiles.SamplesconscriptfileHere is an examplesconscriptfile that builds all *.cpp files in
the directory where it resides:Import('env')# Build all *.cpp source files as executablesforSourceinenv.GlobFiles('*.cpp'):env.Build(Source[:-4],Source)Theenv.Build()method is provided bycuppaand does essentially
whatenv.Program()does but in addition is both toolchain and
variant aware, and further can provide notifications on progress.Note: Source[:-4] simply strips off the file extension.cpp,
that is, the last 4 characters of the file name.If oursconscriptfile was for a directory containing *.cpp files
that are actually tests then we could instead write thesconscriptfile as:Import('env')# Build all *.cpp source files as executables to be run as testsforSourceinenv.GlobFiles('*.cpp'):env.BuildTest(Source[:-4],Source)Theenv.BuildTest()method is provided bycuppaand builds the
sources specified asenv.Build()does.However, in addition, passing--teston the command-line will also
result in the executable produced being run by arunner. The default
test runner simply treats each executable as a test case and each
directory or executables as a test suite. If the process executes
cleanly the test passed, if not it failed.To run this on the command-line we would write:scons-D--testIf we only want to build and testdebugexecutables we can instead
write this:scons-D--dbg--testOr for release only pass--rel.cuppaalso makes it easy to work with dependencies. For example, ifboostwas a default dependency for all yoursconscriptfiles you could write your sconstruct file as follows:importcuppacuppa.run(default_options={'boost-home':'<Location of Boost>'},default_dependencies=['boost'])This will automatically ensure that necessary includes and other compile
options are set for the boost version that is found atboost-home.
If you need to link against specific boost libraries this can also be
done in the sconscript file as follows:Import('env')Test='my_complex_test'Sources=[Test+'.cpp']env.AppendUnique(STATICLIBS=[env.BoostStaticLibrary('system'),env.BoostStaticLibrary('log'),env.BoostStaticLibrary('thread'),env.BoostStaticLibrary('timer'),env.BoostStaticLibrary('chrono'),env.BoostStaticLibrary('filesystem'),])env.BuildTest(Test,Sources)TheBoostStaticLibrary()method ensures that the library is built in
the correct build variant as required. If you preferred to use dynamic
linking then that can also be achieved usingBoostSharedLibrary().The point is the complexities of usingboostas a dependency are encapsulated and managed separately from the
scontruct and sconscript files allowing developers to focus on intent
not method.Design Principlescuppahas been written primarily to provide a clean and structured
way to leverage the power of Scons without the usual problems of hugely
complexscontructfiles that diverge between projects. Key goals ofcuppaare:minimise the need for adding logic intosconscriptfiles, keeping
them as declarative as possible.allow declarativesconscripts that are both much clearer and
significantly simpler than the equivalentmakefile, without the
need to learn a whole new scripting language likemakeorcmake.provide a clear structure for extending the facilities offered bycuppaprovide a clear vocabulary for building projectscodify Scons best practices intocuppaitself so that users just
need to call appropriate methods knowing thatcuppawill do the
right thing with their intentprovide a framework that allows experts to focus on providing
facilities for others to use. Write once, use everywhere. For example
one person who knows how best to makeboostavailable as a dependency can
manage that dependency and allow others to use it seamlessly.More DetailsFor more details refer to theproject homepage.AcknowledgementsThis work is based on the build system used inclearpool.ioduring development of its
next generation exchange platform.