From 35d92d701c18e431550eaccbd67fbefc9ba52d17 Mon Sep 17 00:00:00 2001 From: Edward Brash <brash@jlab.org> Date: Tue, 6 Aug 2013 11:37:15 -0400 Subject: [PATCH] Initial version of SCons-based build package --- SConscript.py | 29 ++++++++++++ SConstruct | 1 + SConstruct.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++ configure.py | 55 +++++++++++++++++++++++ darwin64.py | 32 ++++++++++++++ linux32.py | 32 ++++++++++++++ linux6432.py | 32 ++++++++++++++ src/SConscript.py | 37 ++++++++++++++++ 8 files changed, 327 insertions(+) create mode 100644 SConscript.py create mode 120000 SConstruct create mode 100644 SConstruct.py create mode 100644 configure.py create mode 100644 darwin64.py create mode 100644 linux32.py create mode 100644 linux6432.py create mode 100644 src/SConscript.py diff --git a/SConscript.py b/SConscript.py new file mode 100644 index 0000000..ff43c90 --- /dev/null +++ b/SConscript.py @@ -0,0 +1,29 @@ +###### Hall C Software Main SConscript File ##### +###### Author: Edward Brash (brash@jlab.org) June 2013 + +import os +import re +import SCons.Util +Import ('baseenv') + +######## ROOT Dictionaries ######### + +roothcdict = baseenv.subst('$HC_DIR')+'/HallCDict.C' +roothcobj = baseenv.subst('$HC_SRC')+'/HallCDict.so' +hcheaders = Split(""" + src/THcInterface.h src/THcParmList.h src/THcAnalyzer.h src/THcHallCSpectrometer.h + src/THcDetectorMap.h src/THcRawHit.h src/THcHitList.h src/THcSignalHit.h src/THcHodoscope.h + src/THcScintillatorPlane.h src/THcHodoscopeHit.h src/THcDC.h src/THcDriftChamberPlane.h + src/THcDriftChamber.h src/THcRawDCHit.h src/THcDCHit.h src/THcDCWire.h src/THcSpacePoint.h + src/THcDCLookupTTDConv.h src/THcDCTimeToDistConv.h src/THcShower.h src/THcShowerPlane.h + src/THcShowerHit.h src/THcAerogel.h src/THcAerogelHit.h src/THcGlobals.h src/HallC_LinkDef.h + """) +baseenv.RootCint(roothcdict,hcheaders) +baseenv.SharedObject(target = roothcobj, source = roothcdict) + + +####### Start of main SConscript ########### + +analyzer = baseenv.Program(target = 'hcana', source = 'src/main.o') +baseenv.Install('./bin',analyzer) +baseenv.Alias('install',['./bin']) diff --git a/SConstruct b/SConstruct new file mode 120000 index 0000000..0fe1cae --- /dev/null +++ b/SConstruct @@ -0,0 +1 @@ +SConstruct.py \ No newline at end of file diff --git a/SConstruct.py b/SConstruct.py new file mode 100644 index 0000000..f4f6277 --- /dev/null +++ b/SConstruct.py @@ -0,0 +1,109 @@ +###### Hall C Software Main SConstruct Build File ##### +###### Author: Edward Brash (brash@jlab.org) June 2013 + +import os +import sys +import platform +import commands + +def rootcint(target,source,env): + """Executes the ROOT dictionary generator over a list of headers.""" + dictname = target[0] + headers = "" + cpppath = env.subst('$_CCCOMCOM') + ccflags = env.subst('$CCFLAGS') + rootcint = env.subst('$ROOTCINT') + print "Doing rootcint call now ..." + for f in source: + headers += str(f) + " " + command = rootcint + " -f %s -c -pthread -fPIC %s %s" % (dictname,cpppath,headers) + print ('RootCint Command = %s\n' % command) + ok = os.system(command) + return ok + +baseenv = Environment(ENV = os.environ) + +#dict = baseenv.Dictionary() +#keys = dict.keys() +#keys.sort() +#for key in keys: +# print "Construction variable = '%s', value = '%s'" % (key, dict[key]) + +####### Hall A Build Environment ############# +# +# Edit for the location of your root installation here ... +# +#baseenv.Append(ROOTSYS = '/usr/local/root') +# +baseenv.Append(MAIN_DIR = Dir('.').abspath) +baseenv.Append(HC_DIR = baseenv.subst('$MAIN_DIR')) +baseenv.Append(HC_SRC = baseenv.subst('$HC_DIR')+'/src ') +baseenv.Append(HA_DIR = baseenv.subst('$HC_DIR')+'/podd ') +baseenv.Append(HA_SRC = baseenv.subst('$HA_DIR')+'/src ') +baseenv.Append(HA_DC = baseenv.subst('$HA_DIR')+'/hana_decode ') +baseenv.Append(HA_SCALER = baseenv.subst('$HA_DIR')+'/hana_scaler ') +baseenv.Append(SOVERSION = '1.5') +baseenv.Append(PATCH = '24') +baseenv.Append(VERSION = baseenv.subst('$SOVERSION')+'.'+baseenv.subst('$PATCH')) +baseenv.Append(EXTVERS = '') +baseenv.Append(HA_VERSION = baseenv.subst('$VERSION')+baseenv.subst('$EXTVERS')) +print "Hall C Main Directory = %s" % baseenv.subst('$HC_DIR') +print "Hall C Source Directory = %s" % baseenv.subst('$HC_SRC') +print "Hall A Main Directory = %s" % baseenv.subst('$HA_DIR') +print "Software Version = %s" % baseenv.subst('$VERSION') +ivercode = 65536*int(float(baseenv.subst('$SOVERSION')))+ 256*int(10*(float(baseenv.subst('$SOVERSION'))-int(float(baseenv.subst('$SOVERSION')))))+ int(float(baseenv.subst('$PATCH'))) +baseenv.Append(VERCODE = ivercode) +baseenv.Append(CPPPATH = ['$HC_SRC','$HA_SRC','$HA_DC','$HA_SCALER']) + +######## Configure Section ####### + +import configure +configure.config(baseenv,ARGUMENTS) + +Export('baseenv') + +conf = Configure(baseenv) + +if not conf.CheckCXX(): + print('!!! Your compiler and/or environment is not correctly configured.') + Exit(0) + +if not conf.CheckFunc('printf'): + print('!! Your compiler and/or environment is not correctly configured.') + Exit(0) + +baseenv = conf.Finish() + +######## ROOT Dictionaries ######### + +rootsys = baseenv['ENV']['ROOTSYS'] +baseenv.Append(ROOTCONFIG = rootsys+'/bin/root-config') +baseenv.Append(ROOTCINT = rootsys+'/bin/rootcint') + +try: + baseenv.ParseConfig('$ROOTCONFIG --cflags') + baseenv.ParseConfig('$ROOTCONFIG --libs') + #baseenv.MergeFlags('-fPIC') +except OSError: + print "ROOT not found!!" + exit(1) + +bld = Builder(action=rootcint) +baseenv.Append(BUILDERS = {'RootCint': bld}) + +####### Start of main SConstruct ############ + +hallclib = 'HallC' +hallalib = 'HallA' +dclib = 'dc' +scalerlib = 'scaler' + +baseenv.Append(LIBPATH=['$HC_SRC','$HA_SRC','$HA_DC','$HA_SCALER']) +baseenv.Append(LIBS=[hallclib,hallalib,dclib,scalerlib]) +baseenv.Replace(SHLIBSUFFIX = '.so') + +directorylist = ['./','src','podd','podd/src','podd/hana_decode','podd/hana_scaler'] + +SConscript(dirs = directorylist,name='SConscript.py',exports='baseenv') + +####### End of SConstruct ######### diff --git a/configure.py b/configure.py new file mode 100644 index 0000000..0a927b1 --- /dev/null +++ b/configure.py @@ -0,0 +1,55 @@ +import platform +import os + +def config(env,args): + + if env['PLATFORM'] == 'posix': + if (platform.machine() == 'x86_64'): + print "Got a 64-bit processor, I can do a 64-bit build in theory..." + if args.get('32bit', 0): + print '32-bit Linux build' + env['MEMORYMODEL'] = '32bit' + #import linux6432 + #linux6432.config(env, args) + elif args.get('64bit', 0): + env['MEMORYMODEL'] = '64bit' + #import linux64 + #linux64.config(env, args) + else: + print 'Memory model not specified, so I\'m building 32-bit...' + env['MEMORYMODEL'] = '32bit' + import linux6432 + linux6432.config(env, args) + else: + print '32-bit Linux Build.' + env['MEMORYMODEL'] = '32bit' + import linux32 + linux32.config(env, args) + elif env['PLATFORM'] == 'win32': + if (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or (os.environ.has_key('PROCESSOR_ARCHITEW6432') and os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64')): + print "Got a 64-bit processor, I can do a 64-bit build in theory..." + if args.get('32bit', 0): + print '32-bit Windows build.' + #import win6432 + #win6432.config(env, args) + elif args.get('64bit', 0): + print '64-bit Windows build.' + #import win64 + #win64.config(env, args) + else: + print 'Memory model not specified, so I\'m building 32-bit.' + #import win6432 + #win6432.config(env, args) + else: + print '32-bit Windows build.' + #import win32 + #win32.config(env, args) + elif env['PLATFORM'] == 'darwin': + print 'OS X Darwin is a 64-bit build.' + env['MEMORYMODEL'] = '64bit' + import darwin64 + darwin64.config(env, args) + else: + print 'ERROR! unrecognized platform. Twonk.' + +#end configure.py diff --git a/darwin64.py b/darwin64.py new file mode 100644 index 0000000..5fc4f47 --- /dev/null +++ b/darwin64.py @@ -0,0 +1,32 @@ +import platform +import os + +def config(env,args): + + debug = args.get('debug',0) + standalone = args.get('standalone',0) + if int(debug): + env.Append(CXXFLAGS = '-g -O0') + else: + env.Append(CXXFLAGS = '-O') + env.Append(CPPDEFINES= '-DNDEBUG') + + if int(standalone): + env.Append(STANDALONE= '1') + + env.Append(CXXFLAGS = '-Wall -Woverloaded-virtual -pthread -rdynamic') + env.Append(CPPDEFINES = '-DMACVERS') + + cxxversion = env.subst('$CXXVERSION') + +# if float(cxxversion[0:2])>=4.0: +# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') + + if float(cxxversion[0:2])>=3.0: + env.Append(CPPDEFINES = '-DHAS_SSTREAM') + + env['SHLINKFLAGS'] = '$LINKFLAGS -shared -Wl,-undefined,dynamic_lookup' + env['SHLIBSUFFIX'] = '.so' + + +#end darwin64.py diff --git a/linux32.py b/linux32.py new file mode 100644 index 0000000..035ccb5 --- /dev/null +++ b/linux32.py @@ -0,0 +1,32 @@ +import platform +import os + +def config(env,args): + + debug = args.get('debug',0) + standalone = args.get('standalone',0) + if int(debug): + env.Append(CXXFLAGS = '-g -O0') + else: + env.Append(CXXFLAGS = '-O') + env.Append(CPPDEFINES= '-DNDEBUG') + + if int(standalone): + env.Append(STANDALONE= '1') + + env.Append(CXXFLAGS = '-Wall -Woverloaded-virtual') + env.Append(CPPDEFINES = '-DLINUXVERS') + + cxxversion = env.subst('$CXXVERSION') + +# if float(cxxversion[0:2])>=4.0: +# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') + + if float(cxxversion[0:2])>=3.0: + env.Append(CPPDEFINES = '-DHAS_SSTREAM') + + env['SHLINKFLAGS'] = '$LINKFLAGS -shared' + env['SHLIBSUFFIX'] = '.so' + + +#end linux32.py diff --git a/linux6432.py b/linux6432.py new file mode 100644 index 0000000..d45f862 --- /dev/null +++ b/linux6432.py @@ -0,0 +1,32 @@ +import platform +import os + +def config(env,args): + + debug = args.get('debug',0) + standalone = args.get('standalone',0) + if int(debug): + env.Append(CXXFLAGS = '-g -O0') + else: + env.Append(CXXFLAGS = '-O') + env.Append(CPPDEFINES= '-DNDEBUG') + + if int(standalone): + env.Append(STANDALONE= '1') + + env.Append(CXXFLAGS = '-Wall -Woverloaded-virtual') + env.Append(CPPDEFINES = '-DLINUXVERS') + + cxxversion = env.subst('$CXXVERSION') + +# if float(cxxversion[0:2])>=4.0: +# env.Append(CXXFLAGS = '-Wextra -Wno-missing-field-initializers') + + if float(cxxversion[0:2])>=3.0: + env.Append(CPPDEFINES = '-DHAS_SSTREAM') + + env['SHLINKFLAGS'] = '$LINKFLAGS -shared' + env['SHLIBSUFFIX'] = '.so' + + +#end linux6432.py diff --git a/src/SConscript.py b/src/SConscript.py new file mode 100644 index 0000000..14510b3 --- /dev/null +++ b/src/SConscript.py @@ -0,0 +1,37 @@ +###### Hall C Software Source SConscript Build File ##### +###### Author: Edward Brash (brash@jlab.org) June 2013 + +import os +import re +import SCons.Util +Import('baseenv') + +list = Split(""" +THcInterface.cxx THcParmList.cxx THcAnalyzer.cxx \ +THcHallCSpectrometer.cxx \ +THcDetectorMap.cxx \ +THcRawHit.cxx THcHitList.cxx \ +THcSignalHit.cxx \ +THcHodoscope.cxx THcScintillatorPlane.cxx \ +THcHodoscopeHit.cxx \ +THcDC.cxx THcDriftChamberPlane.cxx \ +THcDriftChamber.cxx \ +THcRawDCHit.cxx THcDCHit.cxx \ +THcDCWire.cxx \ +THcSpacePoint.cxx \ +THcDCLookupTTDConv.cxx THcDCTimeToDistConv.cxx \ +THcShower.cxx THcShowerPlane.cxx \ +THcShowerHit.cxx \ +THcAerogel.cxx THcAerogelHit.cxx +""") + +baseenv.Object('main.C') + +sotarget = 'HallC' + +#srclib = baseenv.SharedLibrary(target = sotarget, source = list+['HallCDict.so'],SHLIBVERSION=['$VERSION'],LIBS=['']) +srclib = baseenv.SharedLibrary(target = sotarget, source = list+['HallCDict.so'],LIBS=['']) +print ('Source shared library = %s\n' % srclib) +baseenv.Install('../',srclib) +baseenv.Alias('install',['../']) + -- GitLab