def set_nvcc_environment(installDir, hostCompiler, hostInstallDir, addressModel): oldPathEnv = os.environ.get('PATH') or "" if os.name == 'nt': os.environ['PATH'] = "%s\\bin%s%s" % (installDir, os.pathsep, oldPathEnv) else: os.environ['PATH'] = "%s/bin%s%s" % (installDir, os.pathsep, oldPathEnv) if "gcc" in hostCompiler: import gcc_common gcc_common.set_gcc_environment(hostInstallDir) else: import msvc_common arch = "x86" if addressModel == "-m32" else "amd64" msvc_common.set_msvc_environment(hostInstallDir, arch)
import os import sys import re import gcc_common if __name__ == '__main__': script, workingDir, srcPath, objPath, depPath, logPath, installDir, executable, rspPath = sys.argv def cpp_compile(): cmd = "%s \"@%s\" \"%s\" -o\"%s\" -MD -MF \"%s\" > \"%s\" 2>&1" % (executable, rspPath, srcPath, objPath, depPath, logPath) exitcode = os.system(cmd) with open(logPath, "rt") as logFile: logContents = logFile.read() if re.search("(warning)|(error)", logContents, re.MULTILINE): print("%s" % logContents) if exitcode: sys.exit(exitcode) os.chdir(workingDir) gcc_common.set_gcc_environment(installDir) cpp_compile() sys.exit(0)