wiki:BuildSystem
Last modified 12 years ago Last modified on 05/09/2007 12:58:38 PM

Using SCons in the LSST Build System

InstallingScons tells you how to install or upgrade SCons

Once you've finished installing you can say:

$ setup scons
$ scons
$ man scons

An example SCons product

If you'd like to try building something with scons, check out support's scons branch:

svn co svn+ssh://svn.lsstcorp.org/DC2/support/branches/scons support-scons

Note: I had to fiddle my eups setup a little to make this work. Ray assumed that you had a product WCSlib 4.2 (I had wcslib v4_2), and $NUMARRAY_DIR/include/numarray/numarray.h must exist; I had to say

cd $NUMARRAY_DIR/include
ln -s ../numarray .

LSST Features added to SCons

To use these features, you need to say

import LSST.SConsUtils

in your SConstruct file.

What SConsUtils does for You

Added Functionality

CheckSwig
CheckSwig(language="python", swigdir=None) Adjust the construction environment to allow the use of swig; if swigdir is specified it's the path to the swig binary, otherwise the calling process' PATH is searched
CheckPython
CheckPython(self) Attempt to auto-detect Python
CleanTree
CleanTree(files, dir=".", recurse=True, verbose=False) Remove files matching the argument list starting at dir when scons is invoked with -c/--clean E.g. CleanTree(r"*~ core")

If recurse is True, recursively descend the file system; if verbose is True, print each filename after deleting it

Declare
Declare(self): Create current and declare targets; we'll add Declare to class Environment
InstallEups
InstallEups(env, dest, files) Install a ups directory, setting absolute versions as appropriate
MakeEnv
MakeEnv(eups_product, versionString=None, dependencies=[], traceback=False) Setup a standard SCons environment, add our dependencies, and fix some os/x problems.

The arguments are:

    	eups_product
		The name of the product
	version
		A version name; can be a CVS $Name$ or an SVN $HeadURL$
	dependencies
		A list of products that this product depends on.  Each product can
		have up to four elements:
		     name
			Name of product
		     incfile
		        An include file that product should provide; can be a list of which
			the last is to be tested, and the others are required to
			compile the last one
		     lib
		        The name of a library that product should provide; can be a list of
                        which the last is the one to be tested, and the others are required
                        to link.  Additionally, the list of libraries can be followed by :LANG
                        where lang maybe any language supported by CheckLib (currently C (default)
                        or C++).  E.g. "m cfitsio:C" 
		     symbol
			A symbol that should be in lib

E.g.

MakeEnv("support",
        r"$HeadURL: svn+ssh://svn.lsstcorp.org/DC2/support/branches/rhl/configure.ac $",
        [["python", "Python.h"],
         ["numarray", ["Python.h", "numarray/numarray.h"]],
         ["wcslib", "wcslib/wcslib.h", "wcs", "wcsini"],
	 ])

LoadableModuleIncomplete
LoadableModuleIncomplete(self, target, source, keywords) Like LoadableModule, but don't insist that all symbols are resolved
PkgConfigEUPS
PkgConfigEUPS(self, product, function=None, unique=1) Load pkg-config options into the environment. Look for packages in PRODUCT_DIR, if they're not in the path, and suppress error messages about failing to find config files
SharedLibraryIncomplete
SharedLibraryIncomplete(self, target, source, keywords) Like SharedLibrary, but don't insist that all symbols are resolved

Changed Functionality

Install
Install(env, dest, files) Like Install, but remove the target when cleaning if files is a directory

Also obeys the variable env['IgnoreFiles'] which is a python regular expression matching files that should be ignored.

An Example SConstruct File

# -*- python -*-
#
# Setup our environment
#
import glob, sys
import LSST.SConsUtils as scons

env = scons.MakeEnv("support",
                    r"$HeadURL: svn+ssh://svn.lsstcorp.org/DC2/support/branches/rhl/configure.ac $",
                    [["python", "Python.h"],
                     ["numarray", ["Python.h", "numarray/numarray.h"]],
                     ["wcslib", "wcslib/wcslib.h", "wcs", "wcsini"],
                     ])
#
# Build/install things
#
SConscript("python/support/PyWCSlib/SConscript")

env['IgnoreFiles'] = r"(~$|.pyc$|^.svn$)"

Alias("install", env.Install(env['prefix'], "python"))
Alias("install", env.InstallEups(env['prefix'] + "/ups", glob.glob("ups/*.table")))

env.Declare()
env.Help(
The lowest level of the LSST infrastructure
)