Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309624
SConstruct
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
SConstruct
View Options
# Defining build options
opts = Options()
opts.AddOptions(
BoolOption( 'precompile', 'Set to 1 for header precompilation', 1 ),
BoolOption( 'ctags' , 'Set to 1 to create a ctags file' , 0 ),
BoolOption( 'java' , 'Set to 1 to create a java interface' , 0 ),
BoolOption( 'debug' , 'Set to 1 create debugging symbols' , 0 ),
BoolOption( 'optimise' , 'Set to 1 produce optimised code' , 0 ),
BoolOption( 'btagging' , 'Enable btagging code' , 0 ),
PathOption( 'prefix' , 'Set the installation prefix' , '/usr' ),
PathOption( 'clhepdir' , 'Set the CLHEP directory' , '/usr' ),
PathOption( 'boostdir' , 'Set the Boost directory' , '/usr' ),
)
# content template for the Rave.pc file (pkg-config metadata)
pkgconfig_data = """# pkg-config metadata file, autogenerated by scons
# define variables
prefix=%s
name=%s
libdir=${prefix}/lib
includedir=${prefix}/include
# metadata
Name: ${name}
Description: Vertex reconstruction library
Version: 0.1.0
URL: http://www.teilchen.at
Libs: -L${libdir} -l${name}
Cflags: -I${includedir}
"""
# starting a new environment
env = Environment( options = opts )
env.build_dir = r'build'
env.pch_name = env.build_dir + r'/rave_precompile.h'
env.pkgconfig_suffix = r'.pc'
env.object_collector = []
# Provide a help text for the -h argument
Help( opts.GenerateHelpText( env ) )
# Centralize the signatures
SConsignFile()
# Import python tools
import os, re, sys, glob
import SCons
if env['ctags']:
os.system ("ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .")
sys.exit(0)
if env['java']:
os.system ("./create_java")
sys.exit(0)
# Define source directories
directories = Split( 'CommonTools DataFormats Environment FWCore Geometry MagneticField RaveBase RecoVertex TrackingTools' )
if env['btagging']:
directories.append ( 'RecoBTag' )
env.Replace( CPPPATH = env.GetLaunchDir() )
env.Replace( LIBPATH = [ '#' + env.build_dir + '/' + dir for dir in directories ] )
env.Append( CPPFLAGS = [ '-I/usr/include', '-Wall', '-pedantic' ] )
if env['debug']:
env.Append ( CPPFLAGS = [ '-g' ] )
if env['optimise']:
env.Append ( CPPFLAGS = [ '-O' ] )
env.Replace( CXXFLAGS = [] )
if os.environ.has_key('CXX'):
env['CXX'] = os.environ['CXX']
env['CC'] = os.environ['CXX']
# Include checking
# Check for CLHEP
def CheckClhep(context, clhepdir):
clhepdir = clhepdir.rstrip() # remove eventual newline characters
context.Message('Checking for CLHEP (at '+clhepdir + ') ... ')
context.env.ParseConfig(clhepdir + '/bin/Matrix-config --ldflags --libs --cppflags' )
ret = context.TryLink("""
#include "CLHEP/Matrix/SymMatrix.h"
#include <iostream>
int main( int argc, char** argv ) {
CLHEP::HepSymMatrix cov6D(6,0);
std::cout << cov6D(1,1) << std::endl;
return 0;
}
""", '.cpp')
context.Result( ret )
return ret
# Check for Boost
def CheckBoost(context, boostdir):
context.Message('Checking for Boost ... ')
boostdir=boostdir.rstrip() # remove eventual newline characters
context.env.Append( CXXFLAGS = '-I'+boostdir+'/include' )
ret = context.TryLink("""
#include "boost/type_traits/is_base_and_derived.hpp"
#include "boost/type_traits/is_polymorphic.hpp"
#include "boost/intrusive_ptr.hpp"
#include <boost/shared_ptr.hpp>
int main( int argc, char** argv ) {
return 0;
}
""", '.cpp')
context.Result( ret )
return ret
# avoid configuring on cleaning
if not env.GetOption('clean'):
conf = Configure( env, custom_tests = { 'CheckClhep': CheckClhep, 'CheckBoost': CheckBoost } )
if env['clhepdir'] == '/usr':
env['clhepdir'] = os.popen('clhep-config --prefix').read()
if not conf.CheckClhep(env['clhepdir']):
print 'Did not find the CLHEP library, exiting!'
Exit( 1 )
if not conf.CheckBoost(env['boostdir']):
print 'Did not find the Boost library, exiting!'
Exit( 1 )
env = conf.Finish()
# Make build directory if it is missing
if not os.path.exists( env.build_dir ):
os.mkdir( env.build_dir )
# Generate header file for precompilation
if env['precompile']:
if not env.GetOption('clean'):
precompile_files = []
for dir in [ 'FWCore', 'Geometry' ]:
precompile_files += glob.glob( dir + r'/*/interface/*.h' )
header_lines = [ '#include "../' + i + '"\n' for i in precompile_files ] + [ '\n' ]
header_file = open( env.pch_name, 'w' )
header_file.writelines( header_lines )
header_file.close()
env.Append( CPPFLAGS='-Winvalid-pch' )
pch_builder = Builder( action = '$CXXCOM', suffix = '.h.gch', src_suffix = '.h', source_scanner = CScan )
env.Append( BUILDERS = { 'MakePCH' : pch_builder } )
env.AppendUnique( CXXFLAGS = [ '-fPIC' ] )
env.pcheader = env.MakePCH( File( env.pch_name ) )
Clean( env.pcheader, env.pcheader )
env.Append( CPPFLAGS = [ '-include' + env.pch_name ] )
if env['btagging']:
# enable b-tagging code
env.Append ( CPPFLAGS = [ '-DWITH_BTAGGING' ] )
env.Append ( CPPFLAGS = [ '-DRAVE' ] )
Export( 'env' )
# Do the hierarchical building
for dir in directories:
env.SConscript( os.path.join( dir, 'SConscript' ), build_dir = os.path.join( env.build_dir, dir ), duplicate = 1 )
Import( 'env' )
libRave = env.SharedLibrary( 'Rave', env.object_collector )
env.Default( libRave )
env.Install( env['prefix'] + '/lib', DEFAULT_TARGETS )
env.Install( env['prefix'] + '/include', source = [ 'rave.i' ] )
libnames = [ os.path.split( x )[-1][3:-3] for x in map(str, DEFAULT_TARGETS) ]
# generate or clean the pkg-config data
if not env.GetOption('clean'):
print 'Generating pkg-config metadata...'
for x in libnames:
pkgconfig_file = open( env.build_dir + '/' + x + env.pkgconfig_suffix, 'w' )
pkgconfig_file.write( pkgconfig_data % ( env['prefix'], x ) )
pkgconfig_file.close()
else:
print 'Cleaning pkg-config metadata...'
for x in libnames:
Execute( Delete( env.build_dir + '/' + x + env.pkgconfig_suffix ) )
for x in libnames:
env.Install( env['prefix'] + '/lib/pkgconfig', env.build_dir + '/' + x + env.pkgconfig_suffix )
# Use generated header file list if existing, otherwise install all header files
try:
filenames = [ x.strip() for x in file( r'public.txt' ).readlines() ]
print "Using public header list file for installation..."
except IOError:
filenames = []
for dir in directories:
filenames += glob.glob( dir + r'/*/interface/*.h' )
for filename in filenames:
env.Install( os.path.split( env['prefix'] + '/include/' + filename )[0] , filename )
env.Alias( 'install', env['prefix'] )
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sat, Dec 21, 3:58 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4004577
Default Alt Text
SConstruct (6 KB)
Attached To
rRAVESVN ravesvn
Event Timeline
Log In to Comment