You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction 

Navid has been busy setting up a demonstration environment using SCons and the ScienceTools v8r2.

Location of Installation

SCons is installed here at SLAC:  /afs/slac/g/glast/applications/SCons/0.97/bin/scons
There's a copy of SciTools in Navid's area:  /nfs/farm/g/glast/u06/golpa/ST-v8r2-scons/ScienceTools
If you desire to run SCons, please copy the ScienceTools from Navid's area into a place you have write-access.

Interesting Details

There is a top-level SConstruct file which contains configuration/build information to be used "globally".  This includes options to include debug and optimization flags during compilation. 

The virjpk subdirectories are not in place or assumed in this organization.  There is a note out to Riccardo to check if that arrangement is acceptable to MRStudio.

Externals

Special file, SConstruct (a Python script fragment), contains
        config/build info for each package
 - use the "scons" command to invoke functionality (try "scons -h" for hints)
 - system does not yet know about GLAST_EXT directory structure,
        but Navid expect to add that support soon.
 - dependencies put in by hand (for now)

Gory details of the SConstruct file

The SConstruct file begins by setting up the global environment for the build.  This is done by updating SCons' environment variable "baseEnv".  Here is the contents of the SConstruct file: 

import os,platform
#########################
#   Global Environment  #
#########################
baseEnv = Environment();
if ARGUMENTS.get('debug',0):
        baseEnv.Append(CCFLAGS = "-g")
if ARGUMENTS.get('optimized',0):
        baseEnv.Append(CCFLAGS = "-O2")
if ARGUMENTS.get('CC',0):
        baseEnv.Replace(CC = ARGUMENTS.get('CC'))
if ARGUMENTS.get('CXX',0):
        baseEnv.Replace(CXX = ARGUMENTS.get('CXX'))
if ARGUMENTS.get('CCFLAGS',0):
        baseEnv.Append(CCFLAGS = ARGUMENTS.get('CCFLAGS'))
if ARGUMENTS.get('CXXFLAGS',0):
        baseEnv.Append(CXXFLAGS = ARGUMENTS.get('CXXFLAGS'))
helpString = """
Usage:

        scons [target] [compile options]


Targets:
        Default:                Build release binaries and libraries
        test:                   Build test binaries and required libraries
        binaries:               Build release binaries and required libraries
        libraries:              Build all libraries

Compile Options:
        Optimized:              Set to 1 to compile with optimization. Default 0.
        CC:                     Set to the compiler to use for C source code.
        CXX:                    Set to the compiler to use for C++ source code.
        CCFLAGS:                Set to additional flags passed to the C compiler.
        CXXFLAGS:               Set to additional flags passed to the C++ compiler.
"""
Export('baseEnv')

The next section pertains to externals:

#########################
#  External Libraries   #
#########################
helpString += SConscript('externals.scons')

Help(helpString)

The following sets up the directories which will contain the libraries, binaries, and include files: 

#########################
#  Project Environment  #
#########################
libDir = os.path.join(os.path.abspath('.'),'lib')
binDir = os.path.join(os.path.abspath('.'),'bin')
incDir = os.path.join(os.path.abspath('.'),'include')
testDir = binDir

baseEnv.Append(LIBPATH = [libDir])


baseEnv.Append(CPPPATH = [incDir])


baseEnv.Append(CPPPATH = ['.'])


baseEnv.Append(CPPPATH = ['src'])

Export('libDir','binDir','incDir','testDir')

Create a list of packages for this SCons project and define the registerObject env variable.

packages = [


  'tip',
  'facilities',
  'astro',
  'Likelihood',
  'st_app',
  'hoops',
  'st_graph',
  'st_stream',
  'dataSubselector',
  'st_facilities',
  'evtbin',
  'f2c',
  'optimizers',
  'xmlBase',
  'irfs',
  'map_tools',
  'burstFit',
  'catalogAccess',
  'celestialSources',
  'flux',
  'fitsGen',
  'likeGui',
  'observationSim',
  'periodSearch',
  'pulsarDb',
  'pulsePhase',
  'rspgen',
  'sane',
  'sourceIdentify',
  'timeSystem',
  'embed_python'
]

def registerObjects(package, objects):

        libs = []


        bins = []


        incs = []


        test = []


        if objects != None and package != None:
                if 'libraries' in objects:

                        libs = baseEnv.Install(libDir, objects['libraries'])


                if 'binaries' in objects:

                        bins = baseEnv.Install(binDir, objects['binaries'])


                if 'includes' in objects:

                        incs = baseEnv.Install(os.path.join(incDir,package), objects['includes'])


                if 'testApps' in objects:

                        test = baseEnv.Install(testDir, objects['testApps'])


                baseEnv.Alias(package, libs + bins + incs)
                baseEnv.Default(libs + bins + incs)
                baseEnv.Alias('libraries', libs)
                baseEnv.Alias('binaries', bins)
                baseEnv.Alias('test', test)

Export('registerObjects')

Lastly we tell SCons where to find the SConscript file for each package:

for pkg in packages:
        SConscript(os.path.join(pkg,"SConscript"))

  • No labels