Skip to content
Snippets Groups Projects
Commit 7484830b authored by Danilo Piparo's avatar Danilo Piparo
Browse files

Translate also makepch.sh in python for Win32 builds

parent fe831938
No related branches found
No related tags found
No related merge requests found
......@@ -137,8 +137,8 @@ add_custom_command(OUTPUT etc/dictpch/allLinkDefs.h
DEPENDS ${CMAKE_SOURCE_DIR}/build/unix/makepchinput.py ${__allFiles})
add_custom_command(OUTPUT etc/allDict.cxx.pch
COMMAND ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.sh etc/allDict.cxx.pch -I${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
DEPENDS ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.sh
COMMAND ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch -I${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
DEPENDS ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py
etc/dictpch/allLinkDefs.h
etc/dictpch/allHeaders.h
etc/dictpch/allCppflags.txt
......
#! /usr/bin/env python
#
# Build a pch for the headers and linkdefs in root-build-dir/etc/dictpch/.
# root-build-dir is first tried as ./ - if that doesn't exist, $ROOTSYS
# is taken as root-build-dir.
#
# $1: PCH output file name
# $2: cxxflags (optional; required if extra headers are supplied)
# $3: extra headers to be included in the PCH (optional)
#
# exit code 1 for invocation errors; else exit code of rootcling invocation.
#
# Copyright (c) 2014 Rene Brun and Fons Rademakers
# Author: Axel Naumann <axel@cern.ch>, 2014-10-16
# Translated to python by Danilo Piparo, 2015-4-23
import sys
import os
import shutil
#-------------------------------------------------------------------------------
def getArgs():
argv = sys.argv
argc = len(argv)
if argc < 2:
print "ERROR: too few arguments specified!"
pchFileName = argv[1]
cxxflags = ""
if argc > 2:
cxxflags = argv[2]
extraHeadersList = ""
if argc > 3:
extraHeadersList = argv[2:]
return pchFileName, cxxflags, extraHeadersList
#-------------------------------------------------------------------------------
def getCppFlags(cppflagsFilename):
ifile = open(cppflagsFilename)
lines = ifile.readlines()
ifile.close()
cppFlags = " ".join(map(lambda line: line[:-1], lines))
return cppFlags
#-------------------------------------------------------------------------------
def makepch():
"""
Create a pch starting from the following arguments
1) pch file name
2) Compiler flags - optional, required if extra headers are supplied
3) Extra headers - optional
"""
rootdir = "."
cfgdir = os.path.join("etc","dictpch")
allheadersFilename = os.path.join(cfgdir,"allHeaders.h")
alllinkdefsFilename = os.path.join(cfgdir,"allLinkDefs.h")
cppflagsFilename = os.path.join(cfgdir,"allCppflags.txt")
pchFileName, extraCppflags, extraHeadersList = getArgs()
extraHeaders = " ".join(extraHeadersList)
rootbuildFlag=""
loc1 = os.path.join(rootdir, allheadersFilename)
rootsys = os.environ["ROOTSYS"]
loc2 = os.path.join(rootsys, allheadersFilename)
if not os.path.exists(loc1):
rootdir = rootsys
if not os.path.exists(loc2):
print "ERROR: cannot find %s file here %s nor here %s" %(allheadersFilename, loc1, loc2)
sys.exit(1)
else:
rootbuildFlag="-rootbuild"
cppFlags = getCppFlags(cppflagsFilename)
cppflagsList=["-D__CLING__",
"-D__STDC_LIMIT_MACROS",
"-D__STDC_CONSTANT_MACROS",
"-DROOT_PCH",
"-I%s" %os.path.join(rootdir,"include"),
"-I%s" %os.path.join(rootdir,"etc"),
"-I%s" %os.path.join(rootdir,cfgdir),
"-I%s" %os.path.join(rootdir,"etc","cling"),
cppFlags]
cppflagsList.append(extraCppflags)
allCppFlags = " ".join(cppflagsList)
rootclingExe = os.path.join(rootdir,"bin","rootcling")
command = "%s %s -1 -f allDict.cxx -noDictSelection -c %s %s %s %s" %(rootclingExe,
rootbuildFlag,
allCppFlags,
allheadersFilename,
extraHeaders,
alllinkdefsFilename)
ret = os.system(command)
if ret == 0:
shutil.move("allDict_rdict.pch",pchFileName)
os.unlink("allDict.cxx")
sys.exit(ret)
if __name__ == "__main__":
ret = makepch()
sys.exit(ret)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment