#!/usr/bin/env python #==================================== # Allpix - build the ROOT dictionary #==================================== import os, inspect import sys import subprocess import fileinput 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()))) # Generate the ROOT dictionary # # Run the rootcint command rootcintcmd = [ "rootcint", \ "-f", \ "allpixDict.cc", \ "-c", \ "../allpix/include/Frames.h", \ "../allpix/include/AllPix_Hits_WriteToEntuple.h", \ "../allpix/include/WriteToNtuple.h", \ "../allpix/include/AllPixDigitAnimation.hh", \ "../allpix/include/LinkDef.h" ] subprocess.call(rootcintcmd) # This generates allpixDict.h and allpicDict.cc in the current directory. # # Remove the "allpix/include/" from the include statements so that # make can find the right files. replace_text("allpixDict.h", "../allpix/include/", "") print(" * Removed '../allpix/include/' from the dictionary header file.") print # # Move allpixDict.h to allpix/include... dictheadername = path + "/allpixDict.h" dictheaderdest = path + "/../allpix/include/allpixDict.h" shutil.move(dictheadername,dictheaderdest) # # ...and allpixDict.cc to allpix/src/. dictimpname = path + "/allpixDict.cc" dictimpdest = path + "/../allpix/src/allpixDict.cc" shutil.move(dictimpname, dictimpdest)