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:// 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(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(self) Attempt to auto-detect Python
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(self): Create current and declare targets; we'll add Declare to class Environment
InstallEups(env, dest, files) Install a ups directory, setting absolute versions as appropriate
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:

		The name of the product
		A version name; can be a CVS $Name$ or an SVN $HeadURL$
		A list of products that this product depends on.  Each product can
		have up to four elements:
			Name of product
		        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
		        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" 
			A symbol that should be in lib


        r"$HeadURL: svn+ssh:// $",
        [["python", "Python.h"],
         ["numarray", ["Python.h", "numarray/numarray.h"]],
         ["wcslib", "wcslib/wcslib.h", "wcs", "wcsini"],

LoadableModuleIncomplete(self, target, source, keywords) Like LoadableModule, but don't insist that all symbols are resolved
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(self, target, source, keywords) Like SharedLibrary, but don't insist that all symbols are resolved

Changed Functionality

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:// $",
                    [["python", "Python.h"],
                     ["numarray", ["Python.h", "numarray/numarray.h"]],
                     ["wcslib", "wcslib/wcslib.h", "wcs", "wcsini"],
# Build/install things

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

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

The lowest level of the LSST infrastructure