Skip to content
Snippets Groups Projects
Commit 03b66787 authored by Stephen A. Wood's avatar Stephen A. Wood
Browse files

Update SCons setup to match podd setup and other cleanup

  Eliminate duplicated/redundant configuration code in SCons system
  Let SCons also clean ROOT 6's *_rdict.pcm class layout cache files
  Move helper python script to site_scons
  Remove EVIO from scons as podd build will take care of it.
  Remove define of HALLC_MODS in SConstruct
    (There is no longer any Hall C conditional code in Podd)
parent a27cad91
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ os.system(cmd) ...@@ -33,6 +33,7 @@ os.system(cmd)
hcheaders = Glob('src/*.h',exclude=['src/HallC_LinkDef.h'])+Glob('src/HallC_LinkDef.h') hcheaders = Glob('src/*.h',exclude=['src/HallC_LinkDef.h'])+Glob('src/HallC_LinkDef.h')
pbaseenv.RootCint(roothcdict,hcheaders) pbaseenv.RootCint(roothcdict,hcheaders)
pbaseenv.Clean(roothcdict,re.sub(r'\.C\Z','_rdict.pcm',roothcdict))
pbaseenv.SharedObject(target = roothcobj, source = roothcdict) pbaseenv.SharedObject(target = roothcobj, source = roothcdict)
####### Start of main SConscript ########### ####### Start of main SConscript ###########
...@@ -42,3 +43,4 @@ print ('LIBS = %s\n' % pbaseenv.subst('$LIBS')) ...@@ -42,3 +43,4 @@ print ('LIBS = %s\n' % pbaseenv.subst('$LIBS'))
analyzer = pbaseenv.Program(target = 'hcana', source = 'src/main.o') analyzer = pbaseenv.Program(target = 'hcana', source = 'src/main.o')
pbaseenv.Install('./bin',analyzer) pbaseenv.Install('./bin',analyzer)
pbaseenv.Alias('install',['./bin']) pbaseenv.Alias('install',['./bin'])
#pbaseenv.Clean(analyzer,)
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
###### Author: Edward Brash (brash@jlab.org) June 2013 ###### Author: Edward Brash (brash@jlab.org) June 2013
import os import os
import sys #import sys
import platform #import platform
import commands #import commands
import SCons import SCons
import configure
from rootcint import rootcint
import subprocess import subprocess
####### Check SCons version ################## ####### Check SCons version ##################
...@@ -14,12 +16,7 @@ print('!!! Building the Hall C analyzer and libraries with SCons requires') ...@@ -14,12 +16,7 @@ print('!!! Building the Hall C analyzer and libraries with SCons requires')
print('!!! SCons version 2.5.0 or newer.') print('!!! SCons version 2.5.0 or newer.')
EnsureSConsVersion(2,5,0) EnsureSConsVersion(2,5,0)
baseenv = Environment(ENV = os.environ) baseenv = Environment(ENV = os.environ,tools=["default"],toolpath=['site_scons'])
#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 ############# ####### Hall A Build Environment #############
# #
...@@ -43,163 +40,16 @@ print ("Hall A Main Directory = %s" % baseenv.subst('$HA_DIR')) ...@@ -43,163 +40,16 @@ print ("Hall A Main Directory = %s" % baseenv.subst('$HA_DIR'))
print ("Software Version = %s" % baseenv.subst('$VERSION')) 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'))) 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(VERCODE = ivercode)
baseenv.Append(CPPPATH = ['$HC_SRC','$HA_SRC','$HA_DC'])
######## ROOT Dictionaries ######### configure.FindROOT(baseenv)
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.Append(ROOTCONFIG = 'root-config')
try:
baseenv.PrependENVPath('PATH',baseenv['ENV']['ROOTSYS'] + '/bin')
except KeyError:
pass # ROOTSYS not defined
try:
baseenv.ParseConfig('$ROOTCONFIG --cflags --glibs')
if sys.version_info >= (2, 7):
cmd = baseenv['ROOTCONFIG'] + " --cxx"
baseenv.Replace(CXX = subprocess.check_output(cmd, shell=True).rstrip())
cmd = baseenv['ROOTCONFIG'] + " --version"
baseenv.Replace(ROOTVERS = subprocess.check_output(cmd, shell=True).rstrip())
else:
baseenv.Replace(CXX = subprocess.Popen([baseenv['ROOTCONFIG'], '--cxx'],\
stdout=subprocess.PIPE).communicate()[0].rstrip())
baseenv.Replace(ROOTVERS = subprocess.Popen([baseenv['ROOTCONFIG'],\
'--version'],stdout=subprocess.PIPE).communicate()[0].rstrip())
if platform.system() == 'Darwin':
try:
baseenv.Replace(LINKFLAGS = baseenv['LINKFLAGS'].remove('-pthread'))
except:
pass # '-pthread' was not present in LINKFLAGS
except OSError:
print('!!! Cannot find ROOT. Check if root-config is in your PATH.')
Exit(1)
bld = Builder(action=rootcint) bld = Builder(action=rootcint)
baseenv.Append(BUILDERS = {'RootCint': bld}) baseenv.Append(BUILDERS = {'RootCint': bld})
#
# evio environment
#
evio_libdir = os.getenv('EVIO_LIBDIR')
evio_incdir = os.getenv('EVIO_INCDIR')
if evio_libdir is None or evio_incdir is None:
print ("No external EVIO environment configured !!!")
print ("EVIO_LIBDIR = %s" % evio_libdir)
print ("EVIO_INCDIR = %s" % evio_incdir)
print ("Using local installation ... ")
evio_local = baseenv.subst('$HA_DIR')+'/evio'
evio_version = '4.4.6'
uname = os.uname();
platform = uname[0];
machine = uname[4];
evio_name = platform + '-' + machine
print ("evio_name = %s" % evio_name)
evio_local_lib = "%s/evio-%s/%s/lib" % (evio_local,evio_version,evio_name)
evio_local_inc = "%s/evio-%s/%s/include" % (evio_local,evio_version,evio_name)
evio_tarfile = "%s/evio-%s.tar.gz" % (evio_local,evio_version)
####### Check to see if scons -c has been called #########
if baseenv.GetOption('clean'):
subprocess.call(['echo', '!!!!!!!!!!!!!! EVIO Cleaning Process !!!!!!!!!!!! '])
if not os.path.isdir(evio_local_lib):
if not os.path.exists(evio_tarfile):
evio_command_scons = "rm libevio*.*; cd %s; wget https://github.com/JeffersonLab/hallac_evio/archive/evio-%s.tar.gz; tar xvfz evio-%s.tar.gz; mv hallac_evio-evio-%s evio-%s; cd evio-%s/ ; scons install -c --prefix=." % (evio_local,evio_version,evio_version,evio_version,evio_version,evio_version)
else:
evio_command_scons = "rm libevio*.*; cd %s; tar xvfz evio-%s.tar.gz; mv hallac_evio-evio-%s evio-%s; cd evio-%s/ ; scons install -c --prefix=." % (evio_local,evio_version,evio_version,evio_version,evio_version)
else:
evio_command_scons = "rm libevio*.*; cd %s; cd evio-%s/ ; scons install -c --prefix=." % (evio_local,evio_version)
print ("evio_command_scons = %s" % evio_command_scons)
os.system(evio_command_scons)
else:
if not os.path.isdir(evio_local_lib):
if not os.path.exists(evio_tarfile):
evio_command_scons = "cd %s; wget --no-check-certificate https://coda.jlab.org/drupal/system/files/evio-%s.tgz; tar xvfz evio-%s.tgz; cd evio-%s/ ; scons install --prefix=." % (evio_local,evio_version,evio_version,evio_version)
else:
evio_command_scons = "cd %s; tar xvfz evio-%s.tgz; cd evio-%s/ ; scons install --prefix=." % (evio_local,evio_version,evio_version)
else:
evio_command_scons = "cd %s; cd evio-%s/ ; scons install --prefix=." % (evio_local,evio_version)
print ("evio_command_scons = %s" % evio_command_scons)
os.system(evio_command_scons)
evio_local_lib_files = "%s/*.*" % (evio_local_lib)
evio_command_libcopy = "cp %s %s" % (evio_local_lib_files,baseenv.subst('$HA_DIR'))
print ("evio_command_libcopy = %s" % evio_command_libcopy)
os.system(evio_command_libcopy)
baseenv.Append(EVIO_LIB = evio_local_lib)
baseenv.Append(EVIO_INC = evio_local_inc)
else:
# evio_command_scons = "cd %s; scons install --prefix=." % evio_instdir
# os.system(evio_command_scons)
baseenv.Append(EVIO_LIB = os.getenv('EVIO_LIBDIR'))
baseenv.Append(EVIO_INC = os.getenv('EVIO_INCDIR'))
print ("EVIO lib Directory = %s" % baseenv.subst('$EVIO_LIB'))
print ("EVIO include Directory = %s" % baseenv.subst('$EVIO_INC'))
baseenv.Append(CPPPATH = ['$EVIO_INC'])
#
# end evio environment
#
baseenv.Append(CPPPATH = ['$HC_SRC','$HA_SRC','$HA_DC'])
proceed = "1" or "y" or "yes" or "Yes" or "Y"
######## 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)
if baseenv.subst('$CHECKHEADERS')==proceed:
system_header_list = ['arpa/inet.h','errno.h','assert.h','netdb.h','netinet/in.h','pthread.h','signal.h','stddef.h','stdio.h','stdlib.h','string.h','strings.h','sys/ioctl.h','sys/socket.h','sys/time.h','sys/types.h','time.h','unistd.h','memory.h','math.h','limits.h']
for header_file in system_header_list:
if not conf.CheckHeader(header_file):
print('!! Header file %s not found.' % header_file)
Exit(0)
baseenv = conf.Finish()
######## cppcheck ########################### ######## cppcheck ###########################
def which(program): proceed = "1" or "y" or "yes" or "Yes" or "Y"
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
if baseenv.subst('$CPPCHECK')==proceed: if baseenv.subst('$CPPCHECK')==proceed:
is_cppcheck = which('cppcheck') is_cppcheck = which('cppcheck')
print ("Path to cppcheck is %s\n" % is_cppcheck) print ("Path to cppcheck is %s\n" % is_cppcheck)
...@@ -211,6 +61,30 @@ if baseenv.subst('$CPPCHECK')==proceed: ...@@ -211,6 +61,30 @@ if baseenv.subst('$CPPCHECK')==proceed:
cppcheck_command = baseenv.Command('cppcheck_report.txt',[],"cppcheck --quiet --enable=all src/ 2> $TARGET") cppcheck_command = baseenv.Command('cppcheck_report.txt',[],"cppcheck --quiet --enable=all src/ 2> $TARGET")
baseenv.AlwaysBuild(cppcheck_command) baseenv.AlwaysBuild(cppcheck_command)
######## Configure Section #######
if not (baseenv.GetOption('clean') or baseenv.GetOption('help')):
configure.config(baseenv,ARGUMENTS)
conf = Configure(baseenv)
if not conf.CheckCXX():
print('!!! Your compiler and/or environment is not correctly configured.')
Exit(1)
# if not conf.CheckFunc('printf'):
# print('!!! Your compiler and/or environment is not correctly configured.')
# Exit(1)
if conf.CheckCXXHeader('sstream'):
conf.env.Append(CPPDEFINES = 'HAS_SSTREAM')
baseenv = conf.Finish()
Export('baseenv')
#print (baseenv.Dump())
#print ('CXXFLAGS = ', baseenv['CXXFLAGS'])
#print ('LINKFLAGS = ', baseenv['LINKFLAGS'])
#print ('SHLINKFLAGS = ', baseenv['SHLINKFLAGS'])
####### Start of main SConstruct ############ ####### Start of main SConstruct ############
hallclib = 'HallC' hallclib = 'HallC'
...@@ -220,9 +94,10 @@ eviolib = 'evio' ...@@ -220,9 +94,10 @@ eviolib = 'evio'
baseenv.Append(LIBPATH=['$HC_DIR','$EVIO_LIB','$HA_DIR','$HC_SRC','$HA_SRC','$HA_DC']) baseenv.Append(LIBPATH=['$HC_DIR','$EVIO_LIB','$HA_DIR','$HC_SRC','$HA_SRC','$HA_DC'])
baseenv.Replace(SHLIBSUFFIX = '.so') baseenv.Replace(SHLIBSUFFIX = '.so')
baseenv.Append(CPPDEFINES = '-DHALLC_MODS') baseenv.Replace(SOSUFFIX = baseenv.subst('$SHLIBSUFFIX'))
#baseenv.Replace(SHLIBSUFFIX = '.so')
baseenv.Append(SHLIBSUFFIX = '.'+baseenv.subst('$VERSION'))
baseenv.Append(SHLIBSUFFIX ='.'+baseenv.subst('$VERSION'))
pbaseenv=baseenv.Clone() pbaseenv=baseenv.Clone()
pbaseenv.Prepend(LIBS=[hallclib,hallalib,dclib,eviolib]) pbaseenv.Prepend(LIBS=[hallclib,hallalib,dclib,eviolib])
baseenv.Prepend(LIBS=[hallalib,dclib,eviolib]) baseenv.Prepend(LIBS=[hallalib,dclib,eviolib])
......
Subproject commit bcaa7a496ce8508a81731a2e4c0ee3cf38641d3a Subproject commit f91a6ea6e929b10969f7ce405ac2e409afd8a39a
import sys
import platform import platform
import os import os
import subprocess
def config(env,args): def config(env,args):
...@@ -56,4 +58,54 @@ def config(env,args): ...@@ -56,4 +58,54 @@ def config(env,args):
else: else:
print 'ERROR! unrecognized platform. Twonk.' print 'ERROR! unrecognized platform. Twonk.'
# which() utility
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
####### ROOT Definitions ####################
def FindROOT(env, need_glibs = True):
root_config = 'root-config'
try:
env.PrependENVPath('PATH',env['ENV']['ROOTSYS'] + '/bin')
except KeyError:
pass # ROOTSYS not defined
try:
if need_glibs:
env.ParseConfig(root_config + ' --cflags --glibs')
else:
env.ParseConfig(root_config + ' --cflags --libs')
if sys.version_info >= (2, 7):
cmd = root_config + ' --cxx'
env.Replace(CXX = subprocess.check_output(cmd, shell=True).rstrip())
cmd = root_config + ' --version'
env.Replace(ROOTVERS = subprocess.check_output(cmd, shell=True).rstrip())
else:
env.Replace(CXX = subprocess.Popen([root_config, '--cxx'],\
stdout=subprocess.PIPE).communicate()[0].rstrip())
env.Replace(ROOTVERS = subprocess.Popen([root_config,\
'--version'],stdout=subprocess.PIPE).communicate()[0].rstrip())
if platform.system() == 'Darwin':
try:
env.Replace(LINKFLAGS = env['LINKFLAGS'].remove('-pthread'))
except:
pass # '-pthread' was not present in LINKFLAGS
except OSError:
print('!!! Cannot find ROOT. Check if root-config is in your PATH.')
env.Exit(1)
#end configure.py #end configure.py
File moved
File moved
File moved
# rootcint.py
import os
def rootcint(target,source,env):
"""Executes the ROOT dictionary generator over a list of headers."""
dictname = target[0]
cpppath = env.subst('$_CCCOMCOM')
# ccflags = env.subst('$CCFLAGS')
# print ("Doing rootcint call now ...")
headers = ""
for f in source:
headers += str(f) + " "
command = "rootcint -f %s -c %s %s" % (dictname,cpppath,headers)
# print ('RootCint Command = %s\n' % command)
ok = os.system(command)
return ok
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment