#-*-python-*- # SConstruct file for building user-customized RAT applications # Assumes all *.cc in the current directory should be compiled and linked in. # # Copy this file to any directory to build source contained therein. appname = 'unit_tests' append_platform_name = False # Put '_archname' on end of appname for # multi-plaform builds in same directory mymain = True # Do you have a main function defined in your source files? # If not, default RAT main function is used. ########### Hopefully you won't need to edit below this line ########## import os from copy import copy from warnings import warn from buildhelp import RATENVFILE, ROOTARCH, build_list, rat_path from SCons.Errors import BuildError env = SConscript(RATENVFILE) env['mymain'] = mymain if not os.path.exists(env['RATLIB']): error = BuildError() error.errstr = ("Cannot find static library for RAT " "(expected at path {}). " "Ensure that the standard RAT is fully compiled before " "attempting to compile user-customized RAT application." "".format(env["RATLIB"])) error.filename = "SConstruct" error.status = 2 error.exitstatus = 2 raise error if append_platform_name: appname += "_" + ROOTARCH if env['USE_ROOT6']: # Need to co-locate .pcm file for program. # Not sure why it needs to be in the same directory as executable, # but it does... build_dir = env['BUILDDIR'] # Strip build directory of the SCons specific '#' character, # Indicates relative to top level SConstruct file, # which is not correct. build_dir = build_dir.replace("#/", "") build_dir = build_dir.replace("#", "") # Construct path relative to top level, unless already absolute. if not os.path.isabs(build_dir): build_dir = rat_path(build_dir) # Install the .pcm file here. dict_file_pcm = os.path.join(build_dir, 'RAT_Dict_rdict.pcm') pcm_install = Install(target='#/', source=dict_file_pcm) env.Default(pcm_install) # Set C++ standard (code from Mark's update to main SConstruct) cpp_stds = sorted(set(c for c in env["CXXFLAGS"] if "-std=c++" in c)) if len(cpp_stds) > 1: # Use newest standard. cpp_newest = max(c for c in cpp_stds if "98" not in c) cpp_stds_old = copy(cpp_stds) cpp_stds_old.remove(cpp_newest) warn("Multiple versions of C++ standard have been set. " "Using newest version: {}.".format(cpp_newest), UserWarning) env["CXXFLAGS"] = [f for f in env["CXXFLAGS"] if f not in cpp_stds_old] elif len(cpp_stds) == 0: # If no standard is set, default to C++11, which is the minimum required. env.AppendUnique(CXXFLAGS='-std=c++11') myobj = env.Object(build_list('*.cc', env['BUILDDIR'])) myapp = env.RATApp(appname, myobj) env.Default(myapp)