From b1e765fb98667807e375c27b0b2191df7f0da199 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 23 Aug 2016 15:12:40 +0200 Subject: [PATCH] refactoring --- scripts/BuildSalomeMini.py | 670 ++++++++------------------------ scripts/SalomeMiniConfig.cfg | 18 +- scripts/salome_check_version.py | 46 +++ scripts/salome_compile.py | 144 +++++++ scripts/salome_config.py | 59 +++ scripts/salome_download.py | 163 ++++++++ scripts/salome_environ.py | 163 ++++++++ scripts/salome_misc.py | 23 ++ 8 files changed, 762 insertions(+), 524 deletions(-) create mode 100644 scripts/salome_check_version.py create mode 100644 scripts/salome_compile.py create mode 100644 scripts/salome_config.py create mode 100644 scripts/salome_download.py create mode 100644 scripts/salome_environ.py create mode 100644 scripts/salome_misc.py diff --git a/scripts/BuildSalomeMini.py b/scripts/BuildSalomeMini.py index 41ae2de..aa2a3ef 100755 --- a/scripts/BuildSalomeMini.py +++ b/scripts/BuildSalomeMini.py @@ -1,506 +1,51 @@ #! /usr/bin/env python -import os,subprocess,sys,re,datetime,shutil,glob -import ConfigParser -import tarfile +import os,sys,shutil,glob current_directory=os.path.dirname(os.path.abspath(__file__)) -# Read configuration -config_filename="SalomeMiniConfig.cfg" -config = ConfigParser.SafeConfigParser() -config.optionxform = str # case sensitive -config.read(os.path.join(current_directory, config_filename)) -# third argument of get: interpolation(0) or raw mode(1) -cmake_archive=config.get('Prerequisites', 'cmake_archive', 0) -cmake_url=config.get('Prerequisites', 'cmake_url', 0) -hdf5_archive=config.get('Prerequisites', 'hdf5_archive', 0) -hdf5_url=config.get('Prerequisites', 'hdf5_url', 0) -swig_archive=config.get('Prerequisites', 'swig_archive', 0) -swig_url=config.get('Prerequisites', 'swig_url', 0) -qt_archive=config.get('Prerequisites', 'qt_archive', 0) -qt_url=config.get('Prerequisites', 'qt_url', 0) -med_archive=config.get('Prerequisites', 'med_archive', 0) -med_url=config.get('Prerequisites', 'med_url', 0) -python_archive=config.get('Prerequisites', 'python_archive', 0) -python_url=config.get('Prerequisites', 'python_url', 0) -python_version_short=config.get('Prerequisites', 'python_version_short', 0) -python_version_long=config.get('Prerequisites', 'python_version_long', 0) -swig_version=config.get('Prerequisites', 'swig_version', 0) -swig_url=config.get('Prerequisites', 'swig_url', 0) -paraview_git_repo=config.get('ParaView', 'paraview_git_repo', 0) -paraview_git_version=config.get('ParaView', 'paraview_git_version', 0) -paraview_version=config.get('ParaView', 'paraview_version', 0) -salome_git_repo=config.get('SALOME', 'salome_git_repo', 0) -medcoupling_version=config.get('SALOME', 'medcoupling_version', 0) -kernel_version=config.get('SALOME', 'kernel_version', 0) -gui_version=config.get('SALOME', 'gui_version', 0) -paravis_version=config.get('SALOME', 'paravis_version', 0) -make_nb_jobs=config.get('Build options', 'make_nb_jobs', 0) -do_archive_download=config.getboolean('Build options', 'do_archive_download') - -# Download archives -local_archives_path=os.path.join(current_directory,"archives") -if not os.path.exists(local_archives_path): - os.makedirs(local_archives_path) - do_archive_download=True - pass - -import urllib2 -def download(url, outfile): - print "Downloading",outfile,"..." - if os.path.exists(outfile): - print "Already downloaded" # :TODO: should include MD5 check - return - try: - remotefile=urllib2.urlopen(url) - except urllib2.HTTPError: - print "Unable to fetch url:", url - sys.exit(1) - pass - with open(outfile,'w') as localfile: - buf = remotefile.read(65536) - while buf != "": - localfile.write(buf) - buf = remotefile.read(65536) - pass - pass - remotefile.close() - pass +from salome_environ import * -cmakeLoc=os.path.join(local_archives_path,cmake_archive) -pythonLoc=os.path.join(local_archives_path,python_archive) -hdf5Loc=os.path.join(local_archives_path,hdf5_archive) -swigLoc=os.path.join(local_archives_path,swig_archive) -qtLoc=os.path.join(local_archives_path,qt_archive) -medLoc=os.path.join(local_archives_path,med_archive) +envAcc={} -if not os.path.exists(cmakeLoc) \ - or not os.path.exists(pythonLoc) \ - or not os.path.exists(hdf5Loc) \ - or not os.path.exists(swigLoc) \ - or not os.path.exists(qtLoc) \ - or not os.path.exists(medLoc): - do_archive_download=True - pass +# Read configuration +from salome_config import read_config_file +read_config_file(os.path.join(current_directory, "SalomeMiniConfig.cfg")) +from salome_config import config -if do_archive_download: - download(cmake_url, cmakeLoc) - download(med_url, medLoc) - download(hdf5_url, hdf5Loc) - download(swig_url, swigLoc) - download(qt_url, qtLoc) - download(python_url, pythonLoc) - pass +# Check system prerequisites +from salome_check_version import * +check_gcc_version(config["gcc_version_min"], envAcc) +# Download archives +from salome_download import download_archives +download_archives(current_directory) # Prepare build -paraviewLoc=(paraview_git_repo,paraview_git_version) - -medcouplingLoc=(os.path.join(salome_git_repo,"tools","medcoupling.git"),medcoupling_version) -kernelLoc=(os.path.join(salome_git_repo,"modules","kernel.git"),kernel_version) -guiLoc=(os.path.join(salome_git_repo,"modules","gui.git"),gui_version) -paravisLoc=(os.path.join(salome_git_repo,"modules","paravis.git"),paravis_version) - rootDir="SalomeMini" -paraCompFlag="-j%s"%make_nb_jobs -cfgOut="config_out.log" -cfgErr="config_err.log" -compOut="compile_out.log" -compErr="compile_err.log" -okFlag=".install_ok" - # Manage dependencies -__softwares = ["cmake","python","hdf5","swig","qt","med","medcoupling","paraview","gui","paravis"] -__softwareChanged = {} -for s in __softwares: - __softwareChanged[s] = False +__softwares = ["cmake","python","hdf5","swig","qt","med","medcoupling","paraview","paravis"] __dependencies={ "cmake": [], - "python": [], + "python": ["cmake"], "hdf5": ["cmake"], "swig": ["python"], - "qt": [], + "qt": ["cmake"], "med": ["hdf5","python"], - "medcoupling": ["python","med"], + "medcoupling": ["python","med","swig"], "paraview": ["hdf5","python","qt","cmake"], - "gui": [""], # not built, only used to get cmake files from sources - "paravis": ["cmake","paraview","medcoupling","gui"], + "paravis": ["paraview","medcoupling"], } -def some_dependency_has_changed(software): - for x in __dependencies[software]: - if __softwareChanged[x]: - return True - return False - -# Manage environment - -def cmake_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - addEnv(envAcc,"PATH",pathAdd) - pass - -def python_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - ldPathAdd=[os.path.join(installDir,"lib")] - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - envAcc["PYTHONHOME"]=installDir - envAcc["PYTHONSTARTUP"]=os.path.join(installDir,"pythonrc.py") - envAcc["PYTHON_VERSION"]=python_version_short - envAcc["PYTHON_INCLUDE"]=os.path.join(installDir,"include","python%s"%envAcc["PYTHON_VERSION"]) - pass - -def hdf5_Environ(installDir,envAcc): - envAcc["HDF5HOME"]=installDir - envAcc["HDF5_DISABLE_VERSION_CHECK"]="1" - pathAdd=[os.path.join(installDir,"bin")] - ldPathAdd=[os.path.join(installDir,"lib")] - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - pass - -def swig_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - addEnv(envAcc,"PATH",pathAdd) - envAcc["SWIG_ROOT_DIR"]=installDir - envAcc["SWIG_LIB"]=os.path.join(installDir,"share","swig",swig_version) - pass - -def qt_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - ldPathAdd=[os.path.join(installDir,"lib")] - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - envAcc["QTDIR"]=installDir - envAcc["QT_PLUGIN_PATH"]=os.path.join(installDir,"plugins") - pass - -def med_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - ldPathAdd=[os.path.join(installDir,"lib")] - pyPathAdd=[os.path.join(installDir,"lib","python%s"%python_version_short,"site-packages")] - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - addEnv(envAcc,"PYTHONPATH",pyPathAdd) - envAcc["MED3HOME"]=installDir - pass - -def medcoupling_Environ(installDir,envAcc): - pathAdd=[os.path.join(installDir,"bin")] - ldPathAdd=[os.path.join(installDir,"lib")] - pyPathAdd=[os.path.join(installDir,"lib","python%s"%python_version_short,"site-packages")] - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - addEnv(envAcc,"PYTHONPATH",pyPathAdd) - addEnv(envAcc,"PATH",pathAdd) - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - addEnv(envAcc,"PYTHONPATH",pyPathAdd) - envAcc["MEDCOUPLINGHOME"]=installDir - pass - -def paraview_Environ(installDir,envAcc): - envAcc["PVHOME"]=installDir - envAcc["PVVERSION"]=paraview_version - pathAdd=[os.path.join(installDir,"bin")] - addEnv(envAcc,"PATH",pathAdd) - ldPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - pyPathAdd =[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages")] - pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","vtk")] - pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","paraview","vtk")] - addEnv(envAcc,"PYTHONPATH",pyPathAdd) - pvPlgPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] - addEnv(envAcc,"PV_PLUGIN_PATH",pvPlgPathAdd) - pass - -def paravis_Environ(installDir,envAcc): - ldPathAdd=[os.path.join(installDir,"lib","salome")] - pvPlgPathAdd=[os.path.join(installDir,"lib","paraview")] - addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - addEnv(envAcc,"PV_PLUGIN_PATH",pvPlgPathAdd) - pass +from salome_config import initialize +initialize(__softwares, __dependencies) #################### -def addEnv(dico,key,val): - if key not in dico.keys(): - dico[key]=val - else: - dico[key]+=val - -class AutoChdir: - def __init__(self,dn): - os.chdir(dn) - def __del__(self): - os.chdir("..") - -def extractSrcFromArchive(srcLoc,srcDir,pattern): - print "Extracting archive: ", srcLoc - tmpDir="tmp" - zz=AutoChdir(srcDir) - if os.path.exists(tmpDir): - assert(False) - srcDN=None - ret=None - myExt=os.path.splitext(srcLoc)[1] - - try: - tar_file = tarfile.open(name=srcLoc, mode='r|*') - name0 = tar_file.getnames()[0] # raise IndexError if tar_file is empty - base0 = name0.split('/')[0] - ret = os.path.realpath(os.path.join(os.getcwd(), base0)) - if os.path.exists(ret): - print("\"%s\" already exists : keep it as this !"%ret) - tar_file.close() - return ret - os.mkdir(tmpDir) - tar_file.extractall(tmpDir) - tar_file.close() - except: - shutil.rmtree(tmpDir) - assert(False) - pass - unzipDir = os.path.join(tmpDir, base0) - shutil.move(unzipDir, os.getcwd()) - os.rmdir(tmpDir) - return ret - -def extractSrcFromGit(gitLoc,srcDir,pattern): - print "Connecting to git repository: ", gitLoc[0] - zz=AutoChdir(srcDir) - assert(isinstance(gitLoc,tuple)) - assert(len(gitLoc)==2) - dirGitLoc=os.path.splitext(os.path.basename(gitLoc[0]))[0] - ret=os.path.realpath(os.path.join(os.getcwd(),dirGitLoc)) - if not os.path.exists(dirGitLoc): - print("Cloning %s..."%dirGitLoc) - def __connect(): - p=subprocess.Popen("GIT_SSL_NO_VERIFY=true git clone %s"%(gitLoc[0]), shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) - p_out,p_err=p.communicate() - return p.returncode, p_out, p_err - tries=0 - while True: - _status,_out,_err = __connect() - if _status == 0 or tries > 1: - break - print _out - print _err - print "Try again" - tries = tries+1 - pass - assert(_status==0) - else: - assert(os.path.exists(os.path.join(dirGitLoc,".git"))) - p=subprocess.Popen(["git","fetch"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) - p.communicate() - pass - p=subprocess.Popen(["git","checkout",gitLoc[1]],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) - p_out,p_err=p.communicate() - if p.returncode != 0: - msg = "Error in checkout\n" + p_err - raise Exception(msg) - if dirGitLoc=="ParaView": - p=subprocess.Popen(["git","submodule","update","--init"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) - p_out,p_err=p.communicate() - if p.returncode != 0: - msg = "Error in submodule update\n" + p_err - raise Exception(msg) - return ret - - -def extractSrc(srcDir,pattern): - srcLoc=eval("%sLoc"%pattern) - if isinstance(srcLoc,str): - return extractSrcFromArchive(srcLoc,srcDir,pattern) - elif isinstance(srcLoc,tuple): - return extractSrcFromGit(srcLoc,srcDir,pattern) - else: - raise Exception("Unrecognized localization of source : %s"%srcLoc) - -def computeEnv(envAcc,withDft=True): - import os,copy - if withDft: - d=copy.deepcopy(os.environ) - for k in os.environ.keys(): - if k not in envAcc.keys(): - del d[k] - else: - d={} - for k in envAcc.keys(): - l=[] - if k in d.keys(): - l=d[k].split(os.pathsep) - tmp=envAcc[k] - if not isinstance(tmp,list): - tmp=[tmp] - l=tmp+l - if k!="PYTHONSTARTUP": - d[k]=os.pathsep.join(l) - else: - d[k]=l[-1] - # - if "PATH" not in d.keys(): - d["PATH"]=os.environ["PATH"] - return d - -def getCurrentVersion(srcDir,pattern): - zz=AutoChdir(srcDir) - srcLoc=eval("%sLoc"%pattern) - if isinstance(srcLoc,str): - s = os.path.splitext(os.path.basename(srcLoc))[0] - if s.endswith(".tar"): - s = s[:-4] - return s - elif isinstance(srcLoc,tuple): - dirGitLoc=os.path.splitext(os.path.basename(srcLoc[0]))[0] - p=subprocess.Popen(["git","rev-parse","--verify","HEAD"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) - p_out,p_err=p.communicate() - if p.returncode != 0: - msg = "Error in getCurrentVersion\n" + p_err - raise Exception(msg) - return p_out.strip() - -def compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): - assert(os.path.isdir(srcDir)) - baseName=os.path.basename(srcDir) - myBuildDir=os.path.realpath(os.path.join(topBuildDir,baseName)) - myInstallDir=os.path.realpath(os.path.join(topInstallDir,baseName)) - if os.path.exists(myBuildDir): - if forceRebuild: - shutil.rmtree(myBuildDir) - os.mkdir(myBuildDir) - else: - if not os.path.exists(os.path.join(myBuildDir,okFlag)): - shutil.rmtree(myBuildDir) - os.mkdir(myBuildDir) - else: - with open(os.path.join(myBuildDir,okFlag)) as f: - built_version = f.readline() - built_version = built_version.strip() - current_version = getCurrentVersion(topSrcDir,pattern) - if current_version != built_version: - print("For \"%s\" : Version has changed !"%srcDir) - print(" Built version: %s"%built_version) - print(" Needed version: %s"%current_version) - shutil.rmtree(myBuildDir) - os.mkdir(myBuildDir) - else: - if some_dependency_has_changed(pattern): - print("For \"%s\" : Some dependencies have changed !"%srcDir) - shutil.rmtree(myBuildDir) - os.mkdir(myBuildDir) - else: - print("For \"%s\" : Do nothing !"%srcDir) - return myBuildDir,myInstallDir,False - else: - os.mkdir(myBuildDir) - pass - __softwareChanged[pattern] = True - return myBuildDir,myInstallDir,True - -def compilePart1(p,buildDir): - a,b=p.communicate() - f=file(os.path.join(buildDir,cfgOut),"w") ; f.write(a) ; f.flush() - f=file(os.path.join(buildDir,cfgErr),"w") ; f.write(b) ; f.flush() - if p.returncode != 0: - msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,cfgOut), os.path.join(buildDir,cfgErr)) - raise Exception(msg) - -def compilePart2(topSrcDir,pattern,envAcc,buildDir,splitInstall): - print("make in %s"%(buildDir)) - if not splitInstall: - p=subprocess.Popen(["make",paraCompFlag,"install"],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) - a,b=p.communicate() - f=file(os.path.join(buildDir,compOut),"w") ; f.write(a) ; f.flush() - f=file(os.path.join(buildDir,compErr),"w") ; f.write(b) ; f.flush() - if p.returncode != 0: - msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) - raise Exception(msg) - else: - p=subprocess.Popen(["make",paraCompFlag],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) - a0,b0=p.communicate() - f=file(os.path.join(buildDir,compOut),"w") ; f.write(a0) ; f.flush() - f=file(os.path.join(buildDir,compErr),"w") ; f.write(b0) ; f.flush() - if p.returncode != 0: - msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) - raise Exception(msg) - p=subprocess.Popen(["make",paraCompFlag,"install"],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) - a1,b1=p.communicate() - f=file(os.path.join(buildDir,compOut),"w") ; f.write(a0+a1) ; f.flush() - f=file(os.path.join(buildDir,compErr),"w") ; f.write(b0+b1) ; f.flush() - if p.returncode != 0: - msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) - raise Exception(msg) - pass - current_version = getCurrentVersion(topSrcDir,pattern) - with open(os.path.join(buildDir,okFlag),"w") as f: - f.write(current_version + "\n") - f.write(str(datetime.datetime.now())) - f.flush() - pass - -def compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,splitInstall): - myBuildDir,myInstallDir,shouldContinue=compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) - if not shouldContinue: - return myInstallDir - myCmd=[os.path.join(srcDir,"configure"),"--prefix=%s"%(myInstallDir)]+addCfgParam - print "Command: ", " ".join(myCmd) - p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) - compilePart1(p,myBuildDir) - compilePart2(topSrcDir,pattern,envAcc,myBuildDir,splitInstall) - return myInstallDir - -def compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): - return compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,False) - -def compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): - return compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,True) - -def compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): - myBuildDir,myInstallDir,shouldContinue=compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) - if not shouldContinue: - return myInstallDir - myCmd=["cmake","-DCMAKE_INSTALL_PREFIX=%s"%(myInstallDir)]+addCfgParam+[srcDir] - print(" ".join(myCmd)) - p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) - compilePart1(p,myBuildDir) - compilePart2(topSrcDir,pattern,envAcc,myBuildDir,False) - return myInstallDir - -def accumulateEnv(installDir,pattern,envAcc): - """ envAcc out parameter""" - zeAccumulator=eval("%s_Environ"%pattern) - zeAccumulator(installDir,envAcc) - pass - -def generateInlineEnv(envAcc): - d=computeEnv(envAcc) - return "env "+" ".join(["%s=%s"%(k,d[k]) for k in d.keys()]) - -def generateFileEnv(envAcc): - d=computeEnv(envAcc) - return "\n".join(["export %s=\"%s\""%(k,d[k]) for k in d.keys()]) - -def bidouilleForCMake(topSrcDir,guiSrcDir): - kernelFake="DUMMY_KERNEL" - zeKernelFake=os.path.join(topSrcDir,kernelFake) - if os.path.exists(zeKernelFake): - shutil.rmtree(zeKernelFake) - os.mkdir(zeKernelFake) - distDir=os.path.join(zeKernelFake,"salome_adm") - os.mkdir(distDir) - shutil.copytree(os.path.join(guiSrcDir,"adm_local","cmake_files"),os.path.join(distDir,"cmake_files")) - return os.path.abspath(zeKernelFake) - -def copyCMakeFromSrcToInstall(srcDir,installDir): - zeSrcDir=os.path.join(srcDir,"cmake_files") - zeInstDir=os.path.join(installDir,"cmake_files") - for fi in glob.glob(os.path.join(zeSrcDir,"*.cmake")): - shutil.copy(fi,zeInstDir) +from salome_download import * +from salome_compile import * def patchCMakeLists(topSrcDir,srcDir): realSrcDirSrc=os.path.join(srcDir,'src','Plugins','MEDReader') @@ -508,9 +53,11 @@ def patchCMakeLists(topSrcDir,srcDir): if os.path.exists(destReal): shutil.rmtree(destReal) shutil.copytree(realSrcDirSrc,destReal) - linesToAdd0="""INCLUDE(UseQtExt) + linesToAdd0="""LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") +""" + linesToAdd1="""INCLUDE(UseQtExt) """ - linesToAdd1="""IF (NOT SALOME_GUI_BUILD_WITH_QT5) + linesToAdd2="""IF (NOT SALOME_GUI_BUILD_WITH_QT5) FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp) ELSE() FIND_PACKAGE(SalomeQt5 REQUIRED) @@ -520,12 +67,20 @@ ENDIF() cmakeToPatch=os.path.join(destReal,"CMakeLists.txt") assert(os.path.exists(cmakeToPatch)) f=file(cmakeToPatch) ; lines=f.readlines() - pos0=filter(lambda (x,y): "INCLUDE(SalomeSetupPlatform)" in y,enumerate(lines)) + + pos0=filter(lambda (x,y): "INCLUDE(SalomeMacros)" in y,enumerate(lines)) assert(len(pos0)==1) ; pos0=pos0[0] - lines=lines[0:pos0[0]+1]+[linesToAdd0]+lines[pos0[0]+1:] - pos1=filter(lambda (x,y): "FIND_PACKAGE(SalomeMEDFile REQUIRED)" in y,enumerate(lines)) + print pos0 + lines=lines[0:pos0[0]]+[linesToAdd0]+lines[pos0[0]:] + + pos1=filter(lambda (x,y): "INCLUDE(SalomeSetupPlatform)" in y,enumerate(lines)) assert(len(pos1)==1) ; pos1=pos1[0] lines=lines[0:pos1[0]+1]+[linesToAdd1]+lines[pos1[0]+1:] + + pos2=filter(lambda (x,y): "FIND_PACKAGE(SalomeMEDFile REQUIRED)" in y,enumerate(lines)) + assert(len(pos2)==1) ; pos2=pos2[0] + lines=lines[0:pos2[0]+1]+[linesToAdd2]+lines[pos2[0]+1:] + f=file(cmakeToPatch,"w") ; f.writelines(lines) return os.path.abspath(destReal) @@ -536,7 +91,7 @@ if not os.path.exists(rootDir): os.mkdir(rootDir) zz=AutoChdir(rootDir) -envAcc={} + topSrcDir="src" topBuildDir="build" @@ -554,78 +109,159 @@ accumulateEnv(installDir,pattern,envAcc) # pattern="python" srcDir=extractSrc(topSrcDir,pattern) -installDir=compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,["--enable-shared","--enable-unicode=ucs4","-without-pymalloc"],False) +installDir=compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, + ["--enable-shared", + "--enable-unicode=ucs4", + "-without-pymalloc" + ],False) accumulateEnv(installDir,pattern,envAcc) # pattern="hdf5" srcDir=extractSrc(topSrcDir,pattern) installDir=compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, - ['-DHDF5_BUILD_HL_LIB=ON','-DHDF5_BUILD_TOOLS=ON','-DBUILD_SHARED_LIBS=ON','-DHDF5_ENABLE_Z_LIB_SUPPORT=ON','-DCMAKE_BUILD_TYPE=Release'],False) + ['-DHDF5_BUILD_HL_LIB=ON', + '-DHDF5_BUILD_TOOLS=ON', + '-DBUILD_SHARED_LIBS=ON', + '-DHDF5_ENABLE_Z_LIB_SUPPORT=ON', + '-DCMAKE_BUILD_TYPE=Release' + ],False) accumulateEnv(installDir,pattern,envAcc) # pattern="swig" srcDir=extractSrc(topSrcDir,pattern) -installDir=compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,["--without-pcre","--without-octave"],False) +installDir=compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, + ["--without-pcre", + "--without-octave" + ],False) accumulateEnv(installDir,pattern,envAcc) # pattern="qt" srcDir=extractSrc(topSrcDir,pattern) -installDir=compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,["-opensource","-confirm-license","-no-rpath","-qt-xcb"],False) +installDir=compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, + ["-opensource", + "-confirm-license", + "-no-rpath", + "-qt-xcb" + ],False) accumulateEnv(installDir,pattern,envAcc) # pattern="med" srcDir=extractSrc(topSrcDir,pattern) -installDir=compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,["--with-hdf5=%s"%(envAcc["HDF5HOME"]),"--enable-production"],False) +installDir=compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, + ["--with-hdf5=%s"%(envAcc["HDF5HOME"]), + "--enable-production" + ],False) accumulateEnv(installDir,pattern,envAcc) # +pattern="repoConfig" +srcDir=extractSrc(topSrcDir,pattern) +accumulateEnv(srcDir,pattern,envAcc) +# pattern="medcoupling" srcDir=extractSrc(topSrcDir,pattern) installDir=compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, - ["-DMEDFILE_ROOT_DIR=%s"%(envAcc["MED3HOME"]),"-DCMAKE_BUILD_TYPE=Debug","-DMEDCOUPLING_BUILD_DOC=OFF","-DMEDCOUPLING_BUILD_TESTS=OFF", - "-DMEDCOUPLING_PARTITIONER_METIS=OFF","-DMEDCOUPLING_ENABLE_RENUMBER=OFF","-DMEDCOUPLING_PARTITIONER_SCOTCH=OFF", + ["-DCMAKE_BUILD_TYPE=Debug", + "-DMEDCOUPLING_BUILD_DOC=OFF", + "-DMEDCOUPLING_BUILD_TESTS=OFF", + "-DMEDCOUPLING_PARTITIONER_METIS=OFF", + "-DMEDCOUPLING_ENABLE_RENUMBER=OFF", + "-DMEDCOUPLING_PARTITIONER_SCOTCH=OFF", + "-DCONFIGURATION_ROOT_DIR=%s"%(envAcc["CONFIGURATION_ROOT_DIR"]), + "-DCONFIGURATION_CMAKE_DIR=%s/cmake"%(envAcc["CONFIGURATION_ROOT_DIR"]), + "-DPYTHONROOT_DIR=%s"%envAcc["PYTHONHOME"], "-DPYTHONINTERP_ROOT_DIR=%s"%envAcc["PYTHONHOME"], "-DPYTHONLIBS_ROOT_DIR=%s"%envAcc["PYTHONHOME"], -],False) + "-DHDF5_ROOT_DIR=%s"%(envAcc["HDF5HOME"]), + "-DMEDFICHIER_ROOT_DIR=%s"%(envAcc["MED3HOME"]), + "-DMEDFILE_ROOT_DIR=%s"%(envAcc["MED3HOME"]), + "-DSWIG_EXECUTABLE=%s"%(envAcc["SWIG_EXECUTABLE"]), + "-DSWIG_VERSION=%s"%(envAcc["SWIG_VERSION"]), + ],False) accumulateEnv(installDir,pattern,envAcc) -#copyCMakeFromSrcToInstall(srcDir,installDir)#patch # pattern="paraview" srcDir=extractSrc(topSrcDir,pattern) installDir=compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, - ['-DPYTHON_ROOT_DIR=%s'%(envAcc["PYTHONHOME"]),'-DHDF5_ROOT_DIR=%s'%(envAcc["HDF5HOME"]),'-DPYTHON_EXECUTABLE=%s/bin/python%s'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), - '-DPYTHON_INCLUDE_DIR=%s'%(envAcc["PYTHON_INCLUDE"]),'-DPYTHON_LIBRARY=%s/lib/libpython%s.so'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), + ['-DPYTHON_ROOT_DIR=%s'%(envAcc["PYTHONHOME"]), + '-DHDF5_ROOT_DIR=%s'%(envAcc["HDF5HOME"]), + '-DPYTHON_EXECUTABLE=%s/bin/python%s'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), + '-DPYTHON_INCLUDE_DIR=%s'%(envAcc["PYTHON_INCLUDE"]), + '-DPYTHON_LIBRARY=%s/lib/libpython%s.so'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), '-DHDF5_LIBRARIES=%s/lib'%(envAcc["HDF5HOME"]), - '-DHDF5_INCLUDE_DIRS=%s/include'%(envAcc["HDF5HOME"]),'-DHDF5_CXX_COMPILER_EXECUTABLE=%s/bin/h5pcc'%(envAcc["HDF5HOME"]), - '-DHDF5_HL_INCLUDE_DIR=%s/include'%(envAcc["HDF5HOME"]),'-DHDF5_hdf5_hl_LIBRARY=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), - '-DHDF5_hdf5_hl_LIBRARY_RELEASE=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]),'-DHDF5_hdf5_hl_LIBRARY_DEBUG=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), - '-DHDF5_HL_LIBRARY=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]),'-DBUILD_SHARED_LIBS:BOOL=ON','-DCMAKE_BUILD_TYPE:STRING=Debug', - '-DPARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON','-DPARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON','-DVTK_USE_64BIT_IDS:BOOL=OFF','-DPARAVIEW_BUILD_QT_GUI:BOOL=ON', - '-DVTK_QT_USE_WEBKIT:BOOL=ON','-DQT_TESTING_INSTALL_DEVELOPMENT:BOOL=ON','-DPARAVIEW_ENABLE_PYTHON:BOOL=ON','-DVTK_USE_SYSTEM_HDF5:BOOL=ON','-DVTK_USE_GL2PS:BOOL=ON', - '-DPARAVIEW_BUILD_PLUGIN_Moments:BOOL=OFF', '-DPARAVIEW_BUILD_PLUGIN_SierraPlotTools:BOOL=OFF', '-DPARAVIEW_BUILD_PLUGIN_SLACTools:BOOL=OFF', + '-DHDF5_INCLUDE_DIRS=%s/include'%(envAcc["HDF5HOME"]), + '-DHDF5_CXX_COMPILER_EXECUTABLE=%s/bin/h5pcc'%(envAcc["HDF5HOME"]), + '-DHDF5_HL_INCLUDE_DIR=%s/include'%(envAcc["HDF5HOME"]), + '-DHDF5_hdf5_hl_LIBRARY=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), + '-DHDF5_hdf5_hl_LIBRARY_RELEASE=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), + '-DHDF5_hdf5_hl_LIBRARY_DEBUG=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), + '-DHDF5_HL_LIBRARY=%s/lib/libhdf5_hl.so'%(envAcc["HDF5HOME"]), + '-DBUILD_SHARED_LIBS:BOOL=ON', + '-DCMAKE_BUILD_TYPE:STRING=Debug', + '-DPARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON', + '-DPARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON', + '-DVTK_USE_64BIT_IDS:BOOL=OFF', + '-DPARAVIEW_BUILD_QT_GUI:BOOL=ON', + '-DVTK_QT_USE_WEBKIT:BOOL=ON', + '-DQT_TESTING_INSTALL_DEVELOPMENT:BOOL=ON', + '-DPARAVIEW_ENABLE_PYTHON:BOOL=ON', + '-DVTK_USE_SYSTEM_HDF5:BOOL=ON', + '-DVTK_USE_GL2PS:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_Moments:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_SierraPlotTools:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_SLACTools:BOOL=OFF', '-DPARAVIEW_INSTALL_DEVELOPMENT_FILES=ON', - '-DVTK_NO_PYTHON_THREADS=OFF','-DPARAVIEW_ENABLE_CATALYST:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_AnalyzeNIfTIIO:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_ArrowGlyph:BOOL=OFF', - '-DPARAVIEW_BUILD_PLUGIN_CatalystScriptGeneratorPlugin:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_GMVReader:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_MobileRemoteControl:BOOL=OFF', - '-DPARAVIEW_BUILD_PLUGIN_NonOrthogonalSource:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_QuadView:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_PacMan:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_PrismPlugin:BOOL=OFF', - '-DPARAVIEW_BUILD_PLUGIN_RGBZView:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_SciberQuestToolKit:BOOL=OFF','-DPARAVIEW_BUILD_PLUGIN_StreamingParticles:BOOL=ON', - '-DPARAVIEW_BUILD_PLUGIN_UncertaintyRendering:BOOL=ON','-DPARAVIEW_ENABLE_MATPLOTLIB:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_EyeDomeLighting:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_ForceTime:BOOL=ON', - '-DPARAVIEW_BUILD_PLUGIN_H5PartReader:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_PointSprite:BOOL=ON','-DPARAVIEW_BUILD_PLUGIN_SurfaceLIC:BOOL=ON', - '-DCMAKE_BUILD_QT_GUI:BOOL=ON','-DVTK_USE_SYSTEM_LIBXML2:BOOL=ON','-DVTK_USE_OGGTHEORA_ENCODER:BOOL=ON','-DPARAVIEW_INSTALL_THIRD_PARTY_LIBRARIES:BOOL=OFF', - '-DBUILD_DOCUMENTATION:BOOL=ON','-DBUILD_EXAMPLES:BOOL=OFF','-DBUILD_TESTING:BOOL=OFF', '-DPARAVIEW_GENERATE_PROXY_DOCUMENTATION:BOOL=ON','-DVTK_NO_PYTHON_THREADS=OFF', - '-DVTK_PYTHON_FULL_THREADSAFE=ON','-DPARAVIEW_QT_VERSION=5','-DQT_HELP_GENERATOR=%s/bin/qhelpgenerator'%(envAcc["QTDIR"]),'-DVTK_BUILD_QT_DESIGNER_PLUGIN:BOOL=OFF','-DBUILD_DOCUMENTATION=OFF'],False) + '-DVTK_NO_PYTHON_THREADS=OFF', + '-DPARAVIEW_ENABLE_CATALYST:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_AnalyzeNIfTIIO:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_ArrowGlyph:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_CatalystScriptGeneratorPlugin:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_GMVReader:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_MobileRemoteControl:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_NonOrthogonalSource:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_QuadView:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_PacMan:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_PrismPlugin:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_RGBZView:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_SciberQuestToolKit:BOOL=OFF', + '-DPARAVIEW_BUILD_PLUGIN_StreamingParticles:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_UncertaintyRendering:BOOL=ON', + '-DPARAVIEW_ENABLE_MATPLOTLIB:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_EyeDomeLighting:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_ForceTime:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_H5PartReader:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_PointSprite:BOOL=ON', + '-DPARAVIEW_BUILD_PLUGIN_SurfaceLIC:BOOL=ON', + '-DCMAKE_BUILD_QT_GUI:BOOL=ON', + '-DVTK_USE_SYSTEM_LIBXML2:BOOL=ON', + '-DVTK_USE_OGGTHEORA_ENCODER:BOOL=ON', + '-DPARAVIEW_INSTALL_THIRD_PARTY_LIBRARIES:BOOL=OFF', + '-DBUILD_DOCUMENTATION:BOOL=ON', + '-DBUILD_EXAMPLES:BOOL=OFF', + '-DBUILD_TESTING:BOOL=OFF', + '-DPARAVIEW_GENERATE_PROXY_DOCUMENTATION:BOOL=ON', + '-DVTK_NO_PYTHON_THREADS=OFF', + '-DVTK_PYTHON_FULL_THREADSAFE=ON', + '-DPARAVIEW_QT_VERSION=%s'%(envAcc["QTVERSION"]), + '-DQT_HELP_GENERATOR=%s/bin/qhelpgenerator'%(envAcc["QTDIR"]), + '-DVTK_BUILD_QT_DESIGNER_PLUGIN:BOOL=OFF', + '-DBUILD_DOCUMENTATION=OFF' + ],False) accumulateEnv(installDir,pattern,envAcc) # -pattern="gui" -srcDir=extractSrc(topSrcDir,pattern) -fakeKernelDir=bidouilleForCMake(topSrcDir,srcDir) -# pattern="paravis"# for MEDReader srcDir=extractSrc(topSrcDir,pattern) srcDir=patchCMakeLists(topSrcDir,srcDir)# change Reference for source installDir=compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir, - ["-DMEDCOUPLING_ROOT_DIR=%s"%(envAcc["MEDCOUPLINGHOME"]),"-DKERNEL_ROOT_DIR=%s"%fakeKernelDir, - '-DPYTHON_ROOT_DIR=%s'%(envAcc["PYTHONHOME"]),'-DHDF5_ROOT_DIR=%s'%(envAcc["HDF5HOME"]), + ["-DMEDCOUPLING_ROOT_DIR=%s"%(envAcc["MEDCOUPLINGHOME"]), + "-DCONFIGURATION_ROOT_DIR=%s"%(envAcc["CONFIGURATION_ROOT_DIR"]), + '-DPYTHON_ROOT_DIR=%s'%(envAcc["PYTHONHOME"]), + '-DHDF5_ROOT_DIR=%s'%(envAcc["HDF5HOME"]), '-DPYTHON_EXECUTABLE=%s/bin/python%s'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), - '-DPYTHON_INCLUDE_DIR=%s'%(envAcc["PYTHON_INCLUDE"]),'-DPARAVIEW_QT_VERSION=5','-DQT_VERSION=5','-DSALOME_GUI_BUILD_WITH_QT5=ON','-DSALOME_INSTALL_SCRIPT_SCRIPTS=%s'%topInstallDir, + '-DPYTHON_INCLUDE_DIR=%s'%(envAcc["PYTHON_INCLUDE"]), + '-DPARAVIEW_QT_VERSION=5', + '-DQT_VERSION=5', + '-DSALOME_GUI_BUILD_WITH_QT5=ON', + '-DSALOME_INSTALL_SCRIPT_SCRIPTS=%s'%topInstallDir, '-DPYTHON_LIBRARY=%s/lib/libpython%s.so'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"])],False) accumulateEnv(installDir,pattern,envAcc) # END diff --git a/scripts/SalomeMiniConfig.cfg b/scripts/SalomeMiniConfig.cfg index 832a9e9..b987a03 100644 --- a/scripts/SalomeMiniConfig.cfg +++ b/scripts/SalomeMiniConfig.cfg @@ -9,24 +9,28 @@ python_version_short=2.7 python_version_long=2.7.10 python_archive=Python-2.7.10.tgz python_url=https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz -qt_archive=qt-everywhere-opensource-src-5.5.1.tar.gz -qt_url=http://download.qt.io/archive/qt/5.5/5.5.1/single/qt-everywhere-opensource-src-5.5.1.tar.gz +qt_archive=qt-everywhere-opensource-src-5.6.1-1.tar.gz +qt_url=http://download.qt.io/archive/qt/5.6/5.6.1-1/single/qt-everywhere-opensource-src-5.6.1-1.tar.gz +qt_version_major=5 swig_version=2.0.8 swig_archive=swig-2.0.8.tar.gz swig_url=http://downloads.sourceforge.net/project/swig/swig/swig-2.0.8/swig-2.0.8.tar.gz [ParaView] paraview_git_repo=https://github.com/Kitware/ParaView.git -paraview_git_version=ef3ccd0e9a48396acd5fd61f364f81e24d202294 +paraview_git_version=909f984978afd2cd719d59b9cef4c0788ed151f0 paraview_version=5.1 [SALOME] +# Last Update: 17/08/2016 salome_git_repo=https://git.salome-platform.org/gitpub -medcoupling_version=d985c98a -kernel_version=8ede54c6 -gui_version=c3dc40d6 -paravis_version=467172fc +medcoupling_version=e3f57e412fe3ca55fdb26275d2f6d8967f83e86c +repo_config_version=bfbaf981033eba4be59b44c1ea53b63586d849ff +paravis_version=957677f54b03a149d8f154638a97a2c7b294c8d3 [Build options] make_nb_jobs=6 do_archive_download=yes + +[System] +gcc_version_min=4.9.2 diff --git a/scripts/salome_check_version.py b/scripts/salome_check_version.py new file mode 100644 index 0000000..8781ec8 --- /dev/null +++ b/scripts/salome_check_version.py @@ -0,0 +1,46 @@ +#! /usr/bin/env python + +import subprocess +import sys +import re + +from salome_misc import compare_num +from salome_environ import computeEnv + +def compare_versions(a, b): + a1,a2,a3 = a.split('.') + b1,b2,b3 = b.split('.') + c = compare_num(a1, b1) + if c != 0: + return c + c = compare_num(a2, b2) + if c != 0: + return c + return compare_num(a3, b3) + +def check_gcc_version(gcc_version_ref, envAcc): + p = subprocess.Popen("gcc --version",env=computeEnv(envAcc),stdout=subprocess.PIPE, shell=True) + (out, err) = p.communicate() + if err: + print "Error when determining gcc version:" + print err + sys.exit(1) + pass + xyz = re.findall(r'(\d+\.\d+\.\d+)',out) + if not xyz: + print "Unable to determine gcc version" + sys.exit(1) + pass + xyz = list(set(xyz)) + if len(xyz) > 1: + print "Ambiguous gcc version in 'gcc --version' output:" + print out + sys.exit(1) + pass + c = compare_versions(xyz[0], gcc_version_ref) + if c == -1: + print "Error: too old gcc version: %s"%xyz[0] + print "gcc version must be >= %s"%gcc_version_ref + sys.exit(1) + pass + pass diff --git a/scripts/salome_compile.py b/scripts/salome_compile.py new file mode 100644 index 0000000..67afea1 --- /dev/null +++ b/scripts/salome_compile.py @@ -0,0 +1,144 @@ +#! /usr/bin/env python + +import os +import shutil +import subprocess +import datetime + +from salome_environ import computeEnv +from salome_misc import * + +def getCurrentVersion(srcDir,pattern): + zz=AutoChdir(srcDir) + from salome_config import config + srcLoc=eval("config['%sLoc']"%pattern) + if isinstance(srcLoc,str): + s = os.path.splitext(os.path.basename(srcLoc))[0] + if s.endswith(".tar"): + s = s[:-4] + return s + elif isinstance(srcLoc,tuple): + dirGitLoc=os.path.splitext(os.path.basename(srcLoc[0]))[0] + p=subprocess.Popen(["git","rev-parse","--verify","HEAD"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + p_out,p_err=p.communicate() + if p.returncode != 0: + msg = "Error in getCurrentVersion\n" + p_err + raise Exception(msg) + return p_out.strip() + +def some_dependency_has_changed(software): + from salome_config import config + for x in config["dependencies"][software]: + if config["softwareChanged"][x]: + return True + return False + +def compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): + assert(os.path.isdir(srcDir)) + baseName=os.path.basename(srcDir) + myBuildDir=os.path.realpath(os.path.join(topBuildDir,baseName)) + myInstallDir=os.path.realpath(os.path.join(topInstallDir,baseName)) + if os.path.exists(myBuildDir): + if forceRebuild: + shutil.rmtree(myBuildDir) + os.mkdir(myBuildDir) + else: + if not os.path.exists(os.path.join(myBuildDir,okFlag)): + shutil.rmtree(myBuildDir) + os.mkdir(myBuildDir) + else: + with open(os.path.join(myBuildDir,okFlag)) as f: + built_version = f.readline() + built_version = built_version.strip() + current_version = getCurrentVersion(topSrcDir,pattern) + if current_version != built_version: + print("For \"%s\" : Version has changed !"%srcDir) + print(" Built version: %s"%built_version) + print(" Needed version: %s"%current_version) + shutil.rmtree(myBuildDir) + os.mkdir(myBuildDir) + else: + if some_dependency_has_changed(pattern): + print("For \"%s\" : Some dependencies have changed !"%srcDir) + shutil.rmtree(myBuildDir) + os.mkdir(myBuildDir) + else: + print("For \"%s\" : Do nothing !"%srcDir) + return myBuildDir,myInstallDir,False + else: + os.mkdir(myBuildDir) + pass + from salome_config import config + config["softwareChanged"][pattern] = True + return myBuildDir,myInstallDir,True + +def compilePart1(p,buildDir): + a,b=p.communicate() + f=file(os.path.join(buildDir,cfgOut),"w") ; f.write(a) ; f.flush() + f=file(os.path.join(buildDir,cfgErr),"w") ; f.write(b) ; f.flush() + if p.returncode != 0: + msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,cfgOut), os.path.join(buildDir,cfgErr)) + raise Exception(msg) + +def compilePart2(topSrcDir,pattern,envAcc,buildDir,splitInstall): + print("make in %s"%(buildDir)) + from salome_config import config + paraCompFlag = config["paraCompFlag"] + if not splitInstall: + p=subprocess.Popen(["make",paraCompFlag,"install"],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) + a,b=p.communicate() + f=file(os.path.join(buildDir,compOut),"w") ; f.write(a) ; f.flush() + f=file(os.path.join(buildDir,compErr),"w") ; f.write(b) ; f.flush() + if p.returncode != 0: + msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) + raise Exception(msg) + else: + p=subprocess.Popen(["make",paraCompFlag],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) + a0,b0=p.communicate() + f=file(os.path.join(buildDir,compOut),"w") ; f.write(a0) ; f.flush() + f=file(os.path.join(buildDir,compErr),"w") ; f.write(b0) ; f.flush() + if p.returncode != 0: + msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) + raise Exception(msg) + p=subprocess.Popen(["make",paraCompFlag,"install"],cwd=buildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) + a1,b1=p.communicate() + f=file(os.path.join(buildDir,compOut),"w") ; f.write(a0+a1) ; f.flush() + f=file(os.path.join(buildDir,compErr),"w") ; f.write(b0+b1) ; f.flush() + if p.returncode != 0: + msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr)) + raise Exception(msg) + pass + current_version = getCurrentVersion(topSrcDir,pattern) + with open(os.path.join(buildDir,okFlag),"w") as f: + f.write(current_version + "\n") + f.write(str(datetime.datetime.now())) + f.flush() + pass + +def compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,splitInstall): + myBuildDir,myInstallDir,shouldContinue=compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) + if not shouldContinue: + return myInstallDir + myCmd=[os.path.join(srcDir,"configure"),"--prefix=%s"%(myInstallDir)]+addCfgParam + print "Command: ", " ".join(myCmd) + p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) + compilePart1(p,myBuildDir) + compilePart2(topSrcDir,pattern,envAcc,myBuildDir,splitInstall) + return myInstallDir + +def compileOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): + return compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,False) + +def compileVeryOld(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): + return compileOldCommon(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,True) + +def compileNew(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): + myBuildDir,myInstallDir,shouldContinue=compilePart0(topSrcDir,pattern,envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) + if not shouldContinue: + return myInstallDir + myCmd=["cmake","-DCMAKE_INSTALL_PREFIX=%s"%(myInstallDir)]+addCfgParam+[srcDir] + print(" ".join(myCmd)) + p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) + compilePart1(p,myBuildDir) + compilePart2(topSrcDir,pattern,envAcc,myBuildDir,False) + return myInstallDir diff --git a/scripts/salome_config.py b/scripts/salome_config.py new file mode 100644 index 0000000..0bdbac2 --- /dev/null +++ b/scripts/salome_config.py @@ -0,0 +1,59 @@ +#! /usr/bin/env python + +import os +import ConfigParser + +config={} + +def read_config_file(config_filename): + global config + c = ConfigParser.SafeConfigParser() + c.optionxform = str # case sensitive + c.read(config_filename) + # third argument of get: interpolation(0) or raw mode(1) + config["cmake_archive"] = c.get('Prerequisites', 'cmake_archive', 0) + config["cmake_url"] = c.get('Prerequisites', 'cmake_url', 0) + config["hdf5_archive"] = c.get('Prerequisites', 'hdf5_archive', 0) + config["hdf5_url"] = c.get('Prerequisites', 'hdf5_url', 0) + config["swig_archive"] = c.get('Prerequisites', 'swig_archive', 0) + config["swig_url"] = c.get('Prerequisites', 'swig_url', 0) + config["qt_archive"] = c.get('Prerequisites', 'qt_archive', 0) + config["qt_url"] = c.get('Prerequisites', 'qt_url', 0) + config["qt_version_major"] = c.get('Prerequisites', 'qt_version_major', 0) + config["med_archive"] = c.get('Prerequisites', 'med_archive', 0) + config["med_url"] = c.get('Prerequisites', 'med_url', 0) + config["python_archive"] = c.get('Prerequisites', 'python_archive', 0) + config["python_url"] = c.get('Prerequisites', 'python_url', 0) + config["python_version_short"] = c.get('Prerequisites', 'python_version_short', 0) + config["python_version_long"] = c.get('Prerequisites', 'python_version_long', 0) + config["swig_version"] = c.get('Prerequisites', 'swig_version', 0) + config["swig_url"] = c.get('Prerequisites', 'swig_url', 0) + config["paraview_git_repo"] = c.get('ParaView', 'paraview_git_repo', 0) + config["paraview_git_version"] = c.get('ParaView', 'paraview_git_version', 0) + config["paraview_version"] = c.get('ParaView', 'paraview_version', 0) + config["salome_git_repo"] = c.get('SALOME', 'salome_git_repo', 0) + config["medcoupling_version"] = c.get('SALOME', 'medcoupling_version', 0) + config["repo_config_version"] = c.get('SALOME', 'repo_config_version', 0) + config["paravis_version"] = c.get('SALOME', 'paravis_version', 0) + config["make_nb_jobs"] = c.get('Build options', 'make_nb_jobs', 0) + config["do_archive_download"] = c.getboolean('Build options', 'do_archive_download') + config["gcc_version_min"] = c.get('System', 'gcc_version_min') + pass + +def initialize(softwares, dependencies): + global config + softwareChanged = {} + for s in softwares: + softwareChanged[s] = False + pass + config["softwareChanged"] = softwareChanged + config["dependencies"] = dependencies + + config["paraCompFlag"] = "-j%s"%config["make_nb_jobs"] + + config["paraviewLoc"] = (config["paraview_git_repo"],config["paraview_git_version"]) + salome_git_repo = config["salome_git_repo"] + config["medcouplingLoc"] = (os.path.join(salome_git_repo,"tools","medcoupling.git"),config["medcoupling_version"]) + config["repoConfigLoc"] = (os.path.join(salome_git_repo,"tools","configuration.git"),config["repo_config_version"]) + config["paravisLoc"] = (os.path.join(salome_git_repo,"modules","paravis.git"),config["paravis_version"]) + pass diff --git a/scripts/salome_download.py b/scripts/salome_download.py new file mode 100644 index 0000000..c06fb7b --- /dev/null +++ b/scripts/salome_download.py @@ -0,0 +1,163 @@ +#! /usr/bin/env python + +import os +import tarfile +import shutil +import subprocess + +from salome_misc import AutoChdir + +def extractSrcFromArchive(srcLoc,srcDir,pattern): + print "Extracting archive: ", srcLoc + tmpDir="tmp" + zz=AutoChdir(srcDir) + if os.path.exists(tmpDir): + assert(False) + srcDN=None + ret=None + myExt=os.path.splitext(srcLoc)[1] + + try: + tar_file = tarfile.open(name=srcLoc, mode='r|*') + name0 = tar_file.getnames()[0] # raise IndexError if tar_file is empty + base0 = name0.split('/')[0] + ret = os.path.realpath(os.path.join(os.getcwd(), base0)) + if os.path.exists(ret): + print("\"%s\" already exists : keep it as this !"%ret) + tar_file.close() + return ret + os.mkdir(tmpDir) + # close then reopen: http://stackoverflow.com/questions/18623842/read-contents-tarfile-into-python-seeking-backwards-is-not-allowed + tar_file.close() + tar_file = tarfile.open(name=srcLoc, mode='r|*') + tar_file.extractall(tmpDir) + tar_file.close() + except: + import traceback + traceback.print_exc() + shutil.rmtree(tmpDir) + assert(False) + pass + unzipDir = os.path.join(tmpDir, base0) + shutil.move(unzipDir, os.getcwd()) + os.rmdir(tmpDir) + return ret + +def extractSrcFromGit(gitLoc,srcDir,pattern): + print "Connecting to git repository: ", gitLoc[0] + zz=AutoChdir(srcDir) + assert(isinstance(gitLoc,tuple)) + assert(len(gitLoc)==2) + dirGitLoc=os.path.splitext(os.path.basename(gitLoc[0]))[0] + ret=os.path.realpath(os.path.join(os.getcwd(),dirGitLoc)) + if not os.path.exists(dirGitLoc): + print("Cloning %s..."%dirGitLoc) + def __connect(): + p=subprocess.Popen("GIT_SSL_NO_VERIFY=true git clone %s"%(gitLoc[0]), shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + p_out,p_err=p.communicate() + return p.returncode, p_out, p_err + tries=0 + while True: + _status,_out,_err = __connect() + if _status == 0 or tries > 1: + break + print _out + print _err + print "Try again" + tries = tries+1 + pass + assert(_status==0) + else: + print("Fetching %s..."%dirGitLoc) + assert(os.path.exists(os.path.join(dirGitLoc,".git"))) + p=subprocess.Popen(["git","fetch"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + p.communicate() + pass + p=subprocess.Popen(["git","checkout",gitLoc[1]],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + p_out,p_err=p.communicate() + if p.returncode != 0: + msg = "Error in checkout\n" + p_err + raise Exception(msg) + if dirGitLoc=="ParaView": + p=subprocess.Popen(["git","submodule","update","--init"],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + p_out,p_err=p.communicate() + if p.returncode != 0: + msg = "Error in submodule update\n" + p_err + raise Exception(msg) + return ret + +def extractSrc(srcDir,pattern): + from salome_config import config + srcLoc=eval("config['%sLoc']"%pattern) + if isinstance(srcLoc,str): + return extractSrcFromArchive(srcLoc,srcDir,pattern) + elif isinstance(srcLoc,tuple): + return extractSrcFromGit(srcLoc,srcDir,pattern) + else: + raise Exception("Unrecognized localization of source : %s"%srcLoc) + +import urllib2 +def download(url, outfile): + print "Downloading",outfile,"..." + if os.path.exists(outfile): + print "Already downloaded" # :TODO: should include MD5 check + return + try: + remotefile=urllib2.urlopen(url) + except urllib2.HTTPError: + print "Unable to fetch url:", url + sys.exit(1) + pass + with open(outfile,'w') as localfile: + buf = remotefile.read(65536) + while buf != "": + localfile.write(buf) + buf = remotefile.read(65536) + pass + pass + remotefile.close() + pass + +def download_archives(current_directory): + from salome_config import config + do_archive_download = config["do_archive_download"] + + local_archives_path = os.path.join(current_directory,"archives") + if not os.path.exists(local_archives_path): + os.makedirs(local_archives_path) + do_archive_download = True + pass + + cmakeLoc = os.path.join(local_archives_path,config["cmake_archive"]) + pythonLoc = os.path.join(local_archives_path,config["python_archive"]) + hdf5Loc = os.path.join(local_archives_path,config["hdf5_archive"]) + swigLoc = os.path.join(local_archives_path,config["swig_archive"]) + qtLoc = os.path.join(local_archives_path,config["qt_archive"]) + medLoc = os.path.join(local_archives_path,config["med_archive"]) + + if not os.path.exists(cmakeLoc) \ + or not os.path.exists(pythonLoc) \ + or not os.path.exists(hdf5Loc) \ + or not os.path.exists(swigLoc) \ + or not os.path.exists(qtLoc) \ + or not os.path.exists(medLoc): + do_archive_download = True + pass + + if do_archive_download: + download(config["cmake_url"], cmakeLoc) + download(config["med_url"], medLoc) + download(config["hdf5_url"], hdf5Loc) + download(config["swig_url"], swigLoc) + download(config["qt_url"], qtLoc) + download(config["python_url"], pythonLoc) + pass + + config["cmakeLoc"] = cmakeLoc + config["pythonLoc"] = pythonLoc + config["hdf5Loc"] = hdf5Loc + config["swigLoc"] = swigLoc + config["qtLoc"] = qtLoc + config["medLoc"] = medLoc + config["do_archive_download"] = do_archive_download + pass diff --git a/scripts/salome_environ.py b/scripts/salome_environ.py new file mode 100644 index 0000000..e9b15b1 --- /dev/null +++ b/scripts/salome_environ.py @@ -0,0 +1,163 @@ +#! /usr/bin/env python + +import os + +def cmake_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + addEnv(envAcc,"PATH",pathAdd) + pass + +def python_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + ldPathAdd=[os.path.join(installDir,"lib")] + addEnv(envAcc,"PATH",pathAdd) + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + envAcc["PYTHONHOME"]=installDir + envAcc["PYTHONSTARTUP"]=os.path.join(installDir,"pythonrc.py") + from salome_config import config + envAcc["PYTHON_VERSION"]=config["python_version_short"] + envAcc["PYTHON_INCLUDE"]=os.path.join(installDir,"include","python%s"%envAcc["PYTHON_VERSION"]) + pass + +def hdf5_Environ(installDir,envAcc): + envAcc["HDF5HOME"]=installDir + envAcc["HDF5_DISABLE_VERSION_CHECK"]="1" + pathAdd=[os.path.join(installDir,"bin")] + ldPathAdd=[os.path.join(installDir,"lib")] + addEnv(envAcc,"PATH",pathAdd) + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + pass + +def swig_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + addEnv(envAcc,"PATH",pathAdd) + envAcc["SWIG_ROOT_DIR"]=installDir + from salome_config import config + envAcc["SWIG_LIB"]=os.path.join(installDir,"share","swig",config["swig_version"]) + envAcc["SWIG_EXECUTABLE"]=os.path.join(installDir,"bin","swig") + envAcc["SWIG_VERSION"]=config["swig_version"] + pass + +def qt_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + ldPathAdd=[os.path.join(installDir,"lib")] + addEnv(envAcc,"PATH",pathAdd) + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + envAcc["QTDIR"]=installDir + envAcc["QT_PLUGIN_PATH"]=os.path.join(installDir,"plugins") + from salome_config import config + envAcc["QTVERSION"]=config["qt_version_major"] + pass + +def med_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + ldPathAdd=[os.path.join(installDir,"lib")] + from salome_config import config + pyPathAdd=[os.path.join(installDir,"lib","python%s"%config["python_version_short"],"site-packages")] + addEnv(envAcc,"PATH",pathAdd) + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + addEnv(envAcc,"PYTHONPATH",pyPathAdd) + envAcc["MED3HOME"]=installDir + pass + +def repoConfig_Environ(installDir,envAcc): + envAcc["CONFIGURATION_ROOT_DIR"]=installDir + envAcc["CONFIGURATION_CMAKE_DIR"]=os.path.join(installDir,"cmake") + pass + +def medcoupling_Environ(installDir,envAcc): + pathAdd=[os.path.join(installDir,"bin")] + ldPathAdd=[os.path.join(installDir,"lib")] + from salome_config import config + pyPathAdd=[os.path.join(installDir,"lib","python%s"%config["python_version_short"],"site-packages")] + addEnv(envAcc,"PATH",pathAdd) + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + addEnv(envAcc,"PYTHONPATH",pyPathAdd) + envAcc["MEDCOUPLINGHOME"]=installDir + pass + +def paraview_Environ(installDir,envAcc): + envAcc["PVHOME"]=installDir + from salome_config import config + paraview_version = config["paraview_version"] + envAcc["PVVERSION"]=paraview_version + pathAdd=[os.path.join(installDir,"bin")] + addEnv(envAcc,"PATH",pathAdd) + ldPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + pyPathAdd =[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages")] + pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","vtk")] + pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","paraview","vtk")] + addEnv(envAcc,"PYTHONPATH",pyPathAdd) + pvPlgPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] + addEnv(envAcc,"PV_PLUGIN_PATH",pvPlgPathAdd) + pass + +def paravis_Environ(installDir,envAcc): + ldPathAdd=[os.path.join(installDir,"lib","salome")] + pvPlgPathAdd=[os.path.join(installDir,"lib","paraview")] + addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) + addEnv(envAcc,"PV_PLUGIN_PATH",pvPlgPathAdd) + pass + +def addEnv(dico,key,val): + if key not in dico.keys(): + dico[key]=val + else: + dico[key]=val+dico[key] + +def computeEnv_1(envAcc,withDft=True): + import os,copy + if withDft: + d=copy.deepcopy(os.environ) + for k in os.environ.keys(): + if k not in envAcc.keys(): + del d[k] + else: + d={} + for k in envAcc.keys(): + l=[] + if k in d.keys(): + l=d[k].split(os.pathsep) + tmp=envAcc[k] + if not isinstance(tmp,list): + tmp=[tmp] + l=tmp+l + if k!="PYTHONSTARTUP": + d[k]=os.pathsep.join(l) + else: + d[k]=l[-1] + # + return d + +def computeEnv(envAcc): + import os, copy + d = copy.deepcopy(os.environ) + for k in envAcc.keys(): + l = [] + if k in d.keys(): + l = d[k].split(os.pathsep) + tmp = envAcc[k] + if not isinstance(tmp,list): + tmp = [tmp] + l = tmp+l + if k != "PYTHONSTARTUP": + d[k] = os.pathsep.join(l) + else: + d[k] = l[-1] + return d + pass + +def accumulateEnv(installDir,pattern,envAcc): + """ envAcc out parameter""" + zeAccumulator=eval("%s_Environ"%pattern) + zeAccumulator(installDir,envAcc) + pass + +def generateInlineEnv(envAcc): + d=computeEnv(envAcc) + return "env "+" ".join(["%s=%s"%(k,d[k]) for k in d.keys()]) + +def generateFileEnv(envAcc): + d=computeEnv(envAcc) + return "\n".join(["export %s=\"%s\""%(k,d[k]) for k in d.keys()]) diff --git a/scripts/salome_misc.py b/scripts/salome_misc.py new file mode 100644 index 0000000..f33f1d7 --- /dev/null +++ b/scripts/salome_misc.py @@ -0,0 +1,23 @@ +#! /usr/bin/env python + +import os + +cfgOut="config_out.log" +cfgErr="config_err.log" +compOut="compile_out.log" +compErr="compile_err.log" +okFlag=".install_ok" + +def compare_num(x, y): + if x > y: + return 1 + if x == y: + return 0 + if x < y: + return -1 + +class AutoChdir: + def __init__(self,dn): + os.chdir(dn) + def __del__(self): + os.chdir("..") -- 2.39.2