Maven and SCons as Buildsystem
Right now the whole concept is in an evaluation phase.
Idea and Background
Single Buildsystem, used by C/C++/Fortran and Java Projects. Exchange Build-Artifacts between projects. Less dependencies on environment variables. Possibility to build outside of central cluster. Possibility to compile from scratch.
From the final product to the source code:
Final results are stored in an hierachical versioned artifact repository at http://artifacts.acc.gsi.de/nexus
The result of a maven build is (one or more) artifact. Basicly an artifact is an archive. For Java this is a jar, for native code we use a zip. Additionally an artifact has some metadata that describes it.
Every artifact can be referenced by its coordinates. Coordinates consist of a groupname (e.g. de.gsi.bel.something), artifactname (e.g. foobar), version (1.0.0), and packaging type. TODO: the groupname will be de.gsi.cs.co.something in the future.
Artifacts can depend on each other. This is noted in the metadata.
Maven can manage these dependencies and interact with the artifact repository. For Java that is all that is needed, you can stop now.
As maven has no clue how to compile native code, there is the need for a plugin. For gsi there is a custom plugin that glues maven together with scons.
Using the maven-scons-plugin, maven is used to handle dependencies and repository interaction. Once maven prepared the environment for scons the compile process is handled by scons. The results are again packaged using maven.
The default GSI project layout (with maven-scons-plugin) looks like
| +-- SConscript
| +-- *.cc
The file pom.xml describes the project to maven. The SConscript contains the actual build instructions for scons.
After a complete run the structure looks similar to this
| +-- SConscript
| +-- *.cc
| +-- build
| +-- install
| +-- tests
| +-- artifact-version.zip
Nothing is changed in the src folder. Compile steps and intermediate object files are all placed inside of
. Inside of
the final results (programs, libraries, headers) are collected. If any test programs are compiled they are placed in
. The final artifact is packaged as zip-file in the target folder.
A preconfigured version of maven is installed in the cluster. It can be called using
. The preconfigured version of maven automatically uses the GSI artifact repository.
will delete the target folder.
will fetch the dependencies and prepare everything for scons
will execute the actual compile run (leaving out the test programs)
will compile all test programs
will run the test programs
creates the archive
will install the resulting archive in your personal repository. Ready to use for all projects you compile
will deploy your artifact to artifacts.acc.gsi.de. Ready to use by everyone. Once an artifact is deployed you can't overwrite it. You need to deploy a new version.
Except the clean phase, all phases are dependent. So running
will run through generate-sources, compile, test-compile, test, package and install.
scons is installed system-wide for the cluster. If you want to compile somewhere else you need a scons 2.x version.
There is no need to call scons manually, however after running a
everything is prepared for it. Change to the target directory and there you can run
compile the test programs
SConscript files are python code. So watch out for line indentation and whitespace. The sample file below should help you get started.
Sample for pom.xml
get default settings like repository, plugin versions,
scm, bugtracker, etc
known build architectures are amd64, i386, ppc
sample dependency on google test framework
shows the usage of a variable, and the usage
of a version range.
This will automatically add include paths and libraries
to the scons build.
activate the scons plugin
the plugin version and configuration is in the parent
Sample for SConscript
Import('env') # get the preconfigured environment
hello = env.Program('helloworld', ['helloWorld.cc'])
## other builders beside Program
# env.StaticLibrary, env.SharedLibrary
## other installers beside bin
# env.InstallHeader, env.InstallLib
## link with an additional library
test1 = env.Program('gtest_foo', ['tests/helloWorld_unitTest.cc', 'helloWorld.cc'])
- 29 Nov 2011