#!/usr/bin/env python #=============================== # Allpix - configuration script #=============================== import os, inspect import sys import argparse import fileinput import subprocess import shutil def replace_text(filename, stringtomatch, stringtoreplace): for line in fileinput.input(filename, inplace = 1): print line.replace(stringtomatch, stringtoreplace), if __name__=="__main__": # Get the path of the current directory path = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) # Get the arguments from the command line parser = argparse.ArgumentParser() parser.add_argument("rootsys", help="Path to your ROOT installation" ) parser.add_argument("geant4sys", help="Path to your GEANT4 installation") parser.add_argument("geant4ver", help="GEANT4 version" ) parser.add_argument("--novis", help="Build without visualisation.") parser.add_argument("--libdirname", help="lib or lib64") args = parser.parse_args() rootsysdir = args.rootsys geant4installdir = args.geant4sys geant4ver = args.geant4ver print print(" * Current working directory is %s" % (path)) print(" *") print(" * ROOT is installed in '%s'" % (rootsysdir) ) print(" * GEANT4 is installed in '%s'" % (geant4installdir)) print(" * GEANT4 version is '%s'" % (geant4ver) ) print # Create the setup script (for setting the environment variables) sf = open("allpix-build/setup.sh", "w") sf.write("#!bin/bash\n") sf.write("#--------------------------------------------------\n") sf.write("# Allpix setup script - autogenerated, DO NOT EDIT \n") sf.write("#--------------------------------------------------\n") sf.write("#\n") sf.write("source %s/bin/thisroot.sh\n" % (rootsysdir)) sf.write("source %s/share/%s/geant4make/geant4make.sh\n" % \ (geant4installdir, geant4ver)) sf.close() # Create the build and make script bf = open("allpix-build/buildandmake.sh", "w") bf.write("#!bin/bash\n") bf.write("#--------------------------------------------------\n") bf.write("# Allpix build script - autogenerated, DO NOT EDIT \n") bf.write("#--------------------------------------------------\n") bf.write("#\n") bf.write("echo 'Generating the ROOT dictionary...'\n") bf.write("python rootdict.py\n") bf.write("echo\n") bf.write("#\n") bf.write("cmake ") lname = "lib" if args.libdirname: lname = "lib64" bf.write("-DGeant4_DIR=%s/%s/%s/ " % (geant4installdir, lname, geant4ver)) bf.write("-DCMAKE_MODULE_PATH=%s/%s/%s/Modules/ " \ % (geant4installdir, lname, geant4ver)) if args.novis: bf.write("-DWITH_GEANT4_UIVIS=OFF ") bf.write("../allpix\n") bf.write("make\n") bf.close()