Skip to main content

Cuppa, an extension package to simplify and extend Scons

Project description

A simple, extensible build system for use with Scons. Cuppa is designed to leverage the capabilities of Scons, while allowing developers to focus on the task of describing what needs to be built. In general cuppa supports make like usage on the command-line. That is developers can simply write:

scons -D

and have Scons “do the right thing”; building targets for any sconscript files found in the current directory.

Cuppa can be installed as a normal python package or installed locally into a site_scons directory allowing it to be effortlessly integrated into any Scons setup.

Note: -D tells scons to look for an sconstruct file in the current or in parent directories and if it finds one execute the sconscript files as if called from that directory. This ensures everything works as expected. For more details refer to the Scons documentation

Quick Intro

Get cuppa

The simpest way to get cuppa is to pip install it using:

pip install cuppa

Sample sconstruct file

Let’s look at a minimal sconstruct that makes use of cuppa. It could look like this:

# Pull in all the Cuppa goodies..
import cuppa

# Call sconscripts to do the work
cuppa.run()

Calling the run method in the cuppa module starts the build process calling sconscript files.

Sample sconscript file

Here is an example sconscript file that builds all *.cpp files in the directory where it resides:

Import( 'env' )

# Build all *.cpp source files as executables
for Source in env.GlobFiles('*.cpp'):
    env.Build( Source[:-4], Source )

The env.Build() method is provided by cuppa and does essentially what env.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 our sconscript file was for a directory containing *.cpp files that are actually tests then we could instead write the sconscript file as:

Import( 'env' )

# Build all *.cpp source files as executables to be run as tests
for Source in env.GlobFiles('*.cpp'):
    env.BuildTest( Source[:-4], Source )

The env.BuildTest() method is provided by cuppa and builds the sources specified as env.Build() does.

However, in addition, passing --test on the command-line will also result in the executable produced being run by a runner. 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 --test

If we only want to build and test debug executables we can instead write this:

scons -D --dbg --test

Or for release only pass --rel.

cuppa also makes it easy to work with dependencies. For example, if boost was a default dependency for all your sconscript files you could write your sconstruct file as follows:

import cuppa

cuppa.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 at boost-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 )

The BoostStaticLibrary() 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 using BoostSharedLibrary().

The point is the complexities of using boost as a dependency are encapsulated and managed separately from the scontruct and sconscript files allowing developers to focus on intent not method.

Design Principles

cuppa has been written primarily to provide a clean and structured way to leverage the power of Scons without the usual problems of hugely complex scontruct files that diverge between projects. Key goals of cuppa are:

  • minimise the need for adding logic into sconscript files, keeping them as declarative as possible.

  • allow declarative sconscripts that are both much clearer and significantly simpler than the equivalent make file, without the need to learn a whole new scripting language like make or cmake.

  • provide a clear structure for extending the facilities offered by cuppa

  • provide a clear vocabulary for building projects

  • codify Scons best practices into cuppa itself so that users just need to call appropriate methods knowing that cuppa will do the right thing with their intent

  • provide 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 make boost available as a dependency can manage that dependency and allow others to use it seamlessly.

More Details

For more details refer to the project homepage.

Acknowledgements

This work is based on the build system used in clearpool.io during development of its next generation exchange platform.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cuppa-0.9.145.tar.gz (181.8 kB view details)

Uploaded Source

Built Distribution

cuppa-0.9.145-py3-none-any.whl (231.4 kB view details)

Uploaded Python 3

File details

Details for the file cuppa-0.9.145.tar.gz.

File metadata

  • Download URL: cuppa-0.9.145.tar.gz
  • Upload date:
  • Size: 181.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cuppa-0.9.145.tar.gz
Algorithm Hash digest
SHA256 1e6686e7d2647a761de4b7b3774943cdbbe1a3aded6176ea6477bb581866e07c
MD5 2f1bd85d3e39ad8fb80095c8a2c96f94
BLAKE2b-256 95271f52ff692c6ef59ec08ff64cd7c33dcac00e9f6bc4ef0381595a86a48095

See more details on using hashes here.

File details

Details for the file cuppa-0.9.145-py3-none-any.whl.

File metadata

  • Download URL: cuppa-0.9.145-py3-none-any.whl
  • Upload date:
  • Size: 231.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cuppa-0.9.145-py3-none-any.whl
Algorithm Hash digest
SHA256 f219ab2098d915c28ac1cd8d0ee1c702725a520145a987d8776babf9fc7c44d4
MD5 ba0d1f2800915b33b7dbbc32d292759f
BLAKE2b-256 145fe83dea166c2c2b28ec5f1fda0452b0673f312feaa303cbf79c2c3cb9f4f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page