Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • deploySCons.py creates an SConscript file in src subdirectory of each package based on use statements in requirements file:
Code Block
titletip/cmt/requiremets
package tip

version v1r1p1

author James Peachey <peachey@lheamail.gsfc.nasa.gov>
# $Id: requirements,v 1.11 2006/02/01 18:38:35 peachey Exp $

use STpolicy *
use ROOT * IExternal
use cfitsio * IExternal

macro_append tip_linkopts "" Linux "-lHist " Darwin "-lHist "
apply_pattern ST_library 
apply_pattern shared_st_library
application sample sample/sample.cxx
Code Block
titletip/src/SConscript
#-*- python -*-
Import('packageSetup', 'ROOT', 'cfitsio')
env=Environment(CPPPATH=[], LIBPATH=[], LIBS=[])
for item in ('CPPPATH', 'LIBPATH', 'LIBS'):
    env[item].extend(ROOT[item])
    env[item].extend(cfitsio[item])
packageSetup('tip', env)
  • This will only work if the req file has use statements for every library it needs to link against, e.g., in astro req file, the use ROOT * IExternal line has been added. This is preferable to relying on implicit uses inherited from other packages.
code

package astro

version v2r9
#$Id: requirements,v 1.113 2007/05/08 13:55:08 burnett Exp $

author  T. Burnett <tburnett@u.washington.edu>

use GlastPolicy  * -no_auto_imports
use facilities   *
use cfitsio * IExternal 
use CLHEP v3* IExternal
use extFiles * IExternal -no_auto_imports # for jphephem data
use tip *
use ROOT * IExternal

apply_pattern package_include
apply_pattern package_linkopts
apply_pattern package_stamps

private

#the following prepend makes the includes and src folders available locally
macro_prepend includes "-I $(ASTROROOT)/src -I.." WIN32 "/I $(ASTROROOT)\src /I.. "

#kill "truncation from double to float"
macro_append astro_cppflags "" WIN32 " /wd4305"

macro source *.cxx WIN32 "*.h *.cxx"
library astro -no_share \
 -s=../astro $(source) \
 -s=../src $(source) \
 -s=healpix $(source) *.cc \
 -s=wcslib  $(source) *.c\
 -s=jplephem $(source) 


# simple program to test basic functionality

pattern astro_package_test \
 private ; \
 macro test_source "test/*.cxx " WIN32 "-s=../src/test *.h *.cxx " ; \
 application test_<package> -group=test $(test_source) <extra> ; \
 public

apply_pattern astro_package_test

# this is the test program from G. Tosti
# application orbit test/orbit/Orbit.cxx 

#application testHTM test/htm/*.cxx
  • In the top level SConstruct file, source code is found by looking for all filename patterns *.c* and directories to be added to CPPPATH (for includes) are found by matching *.h. Since more than one .cxx file in a given package may contain a main() function, this scheme will fail once one tries to link. It would be better if all source code for the library lived in the src directory. The packages astro and irfs/handoff_response violate this convention.
  • In just the three lowest level packages facilities, tip, and astro there are three different ways to specify application builds. It would be better to have a single convention, with ancillary application-specific source code living in the application subdirectory.
  • It would help if test programs had a standard name, test_<package>.cxx, and there was only one that lives in the src/test subdir.
  • The equivalent of our policy package patterns should be implemented as python functions in the top-level SConstruct file:
Code Block
titleSConstruct
#-*- python -*-
"""
@brief Top-level SConstruct file for example checkout package build.

@author J. Chiang <jchiang@slac.stanford.edu>
"""
#
# $Header: /nfs/slac/g/glast/ground/cvs/users/jchiang/DeploySCons/SConstruct,v 1.7 2007/05/22 01:08:06 jchiang Exp $
#
import os, glob

baseDir = os.path.abspath(os.curdir)

if os.name == 'nt':
    bindir = 'VC8debug'
    env.Append(CCFLAGS=['/EHsc'])
    env['ENV']['TMP'] = os.environ['TMP']
elif os.name == 'posix':
    bindir = 'rh9_gcc32'
#    bindir = 'rhel4_gcc34'

def srcFiles(path):
    query = '/usr/bin/find %s -name \*.c\* -print' % path
    files = [item.strip() for item in os.popen(query)
             if item.find('./test') == -1]
    query = '/usr/bin/find %s -name \*.h -print' % path
    hfiles = [item.strip() for item in os.popen(query)
              if item.find('./test') == -1]
    cpppaths = {}
    for item in hfiles:
        cpppaths[os.path.abspath(os.path.split(item)[0])] = 1
    return files, cpppaths.keys()

def packageSetup(package, env):
    packagedir = os.path.abspath('..')
    src_files, paths = srcFiles(os.curdir)
    cpppath = [packagedir]
    cpppath.extend(paths)
    env.Append(CPPPATH=cpppath, CCFLAGS=['-g'])
    library = env.StaticLibrary(package, src_files)
    installdir = os.path.join(packagedir, bindir)
    env.Install(installdir, library)
    env.Alias(package, installdir)
    env.Default(package)
    Export('package', 'packagedir', 'env', 'installdir')
    SConscript(os.path.join('test', 'SConstruct'))

def extlibEnv(package, version, libs=None):
    packageDir = os.path.join(os.environ['GLAST_EXT'], package, version)
    if libs is None:
        libs = [package]
    return Environment(CPPPATH=[os.path.join(packageDir, 'include')],
                       LIBPATH=[os.path.join(packageDir, 'lib')],
                       LIBS=libs)

CLHEP = extlibEnv('CLHEP', '1.9.2.2')
cfitsio = extlibEnv('cfitsio', 'v3006')
ROOT = extlibEnv('ROOT', os.path.join('v5.10.00', 'root'),
                 libs=['Core', 'Cint', 'Tree', 'Matrix', 'Physics',
                       'Graf', 'Graf3d', 'Gpad', 'Rint', 'Postscript',
                       'TreePlayer', 'Hist', 'pthread', 'm', 'dl'])
fftw = extlibEnv('fftw', '3.0.1')
pil = extlibEnv('pil', '2.0.1')
xerces = extlibEnv('xerces', '2.6.0')
cppunit = extlibEnv('cppunit', '1.10.2')

exports = ['bindir', 'packageSetup', 'cfitsio', 'CLHEP', 'ROOT', 
           'fftw', 'pil', 'xerces', 'cppunit']

def packageEnv(package, version):
    packageDir = os.path.join(baseDir, package, version)
    return Environment(CPPPATH=[os.path.join(packageDir)],
                       LIBPATH=[os.path.join(packageDir, bindir)],
                       LIBS=[package]), packageDir

packages = {'facilities' : 'v2r12p5',
            'tip' : 'v2r12',
            'astro' : 'v2r9',
            'st_stream' : 'v0r5',
            'hoops' : 'v0r4p5',
            'st_graph' : 'v1r7',
            'st_app' : 'v2'}

for package in packages:
    exec('%s, %sDir = packageEnv("%s", "%s")' % (package, package,
                                                 package, packages[package]))
    exports.append(package)

Export(*exports)

for package in packages:    
    exec('SConscript(os.path.join(%sDir, "src", "SConscript"))' % package)
  • In the top level SConstruct file, source code is found by looking for all filename patterns *.c* and directories to be added to CPPPATH (for includes) are found by matching *.h. Since more than one .cxx file in a given package may contain a main() function, this scheme will fail once one tries to link. It would be better if all source code for the library lived in the src directory. The packages astro and irfs/handoff_response violate this convention.
  • So far, the implementation will build only libraries. When the building of applications is implemented, it would be desireable to have each req file contain use statements for every library it needs to link against. This is preferable to relying on implicit uses inherited from other packages.
  • In just the three lowest level packages facilities, tip, and astro there are three different ways to specify application builds. It would be better to have a single convention, with ancillary application-specific source code living in the application subdirectory.
  • It would help if test programs had a standard name, test_<package>.cxx, and there was only one that lives in the src/test subdir.