From: Cédric Aguerre Date: Wed, 31 Aug 2016 08:52:13 +0000 (+0200) Subject: add --with-paraview-version option X-Git-Tag: kw11013~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0290bcc608fee8d4c7b891a17453c55cfec11f6;p=tools%2Fpvdeliv.git add --with-paraview-version option --- diff --git a/scripts/BuildSalomeMini.py b/scripts/BuildSalomeMini.py index 0ebfdac..c8f4e4a 100755 --- a/scripts/BuildSalomeMini.py +++ b/scripts/BuildSalomeMini.py @@ -3,7 +3,7 @@ import os,sys,shutil,glob from salome_misc import AutoChdir -from salome_config import read_config_file, initialize +from salome_config import read_config_file, initialize, update_config_file from salome_check_version import check_gcc_version from salome_download import extractSrc, download_archives from salome_build_options import * @@ -12,9 +12,14 @@ from salome_environ import accumulateEnv, generateFileEnv current_directory=os.path.dirname(os.path.abspath(__file__)) -def __init(envAcc={}): +def __init(envAcc={}, paraview_version=None): # Read configuration - config=read_config_file(os.path.join(current_directory, "SalomeMiniConfig.cfg")) + filename=os.path.join(current_directory, "SalomeMiniConfig.cfg") + config=read_config_file(filename) + if paraview_version: + config["paraview_version"] = paraview_version[0] + config["paraview_git_version"] = paraview_version[1] + update_config_file(filename, {"paraview_version": paraview_version[0], "paraview_git_version":paraview_version[1]}) # Check system prerequisites check_gcc_version(config["gcc_version_min"], envAcc) # Download archives @@ -61,9 +66,9 @@ ENDIF() return os.path.abspath(destReal) #################### -def __let_us_go(): +def __let_us_go(paraview_version=None): envAcc={} - config=__init() + config=__init(paraview_version=paraview_version) # Prepare build rootDir="SalomeMini" @@ -136,7 +141,7 @@ def __let_us_go(): srcDir=extractSrc(topSrcDir,pattern,config) srcDir=__patchCMakeLists(topSrcDir,srcDir)# change Reference for source installDir=compileNew(topSrcDir,pattern,config,envAcc,srcDir,topBuildDir,topInstallDir, - get_paravis_build_options(envAcc),False) + get_paravis_build_options(envAcc,topInstallDir),False) accumulateEnv(installDir,pattern,config,envAcc) # @@ -147,5 +152,31 @@ def __let_us_go(): print("Env file generated : %s"%envFile) pass +def __usage(exe): + return """ +Usage: %s [--with-paraview-version=number,sha1]\n +Use option --with-paraview-version to build a specific paraview version. Give the +version number (e.g. 5.1) and a git sha1. +"""%(exe) + +### if __name__ == "__main__": - __let_us_go() + if len(sys.argv) not in [1,2]: + print __usage(sys.argv[0]) + sys.exit(1) + + paraview_version = None + if len(sys.argv) == 2: + if sys.argv[1].startswith("--with-paraview-version="): + try: + number,sha1 = sys.argv[1].split("=")[1].split(",") + paraview_version = (number.strip(),sha1.strip()) + except: + print "Syntax error in paraview version" + print __usage(sys.argv[0]) + sys.exit(1) + else: + print __usage(sys.argv[0]) + sys.exit(1) + + __let_us_go(paraview_version) diff --git a/scripts/SalomeMiniConfig.cfg b/scripts/SalomeMiniConfig.cfg index 5f39ede..1ba374c 100644 --- a/scripts/SalomeMiniConfig.cfg +++ b/scripts/SalomeMiniConfig.cfg @@ -18,7 +18,7 @@ swig_url=http://downloads.sourceforge.net/project/swig/swig/swig-2.0.8/swig-2.0. [ParaView] paraview_git_repo=https://github.com/Kitware/ParaView.git -paraview_git_version=909f984978afd2cd719d59b9cef4c0788ed151f0 +paraview_git_version=97cdb51f paraview_version=5.1 [SALOME] diff --git a/scripts/salome_build_options.py b/scripts/salome_build_options.py index 5a55170..3d39361 100644 --- a/scripts/salome_build_options.py +++ b/scripts/salome_build_options.py @@ -123,7 +123,7 @@ def get_paraview_build_options(envAcc): '-DQT_HELP_GENERATOR=%s/bin/qhelpgenerator'%(envAcc["QTDIR"]) ] -def get_paravis_build_options(envAcc): +def get_paravis_build_options(envAcc,topInstallDir): return [ '-DPARAVIEW_QT_VERSION=5', '-DQT_VERSION=5', @@ -134,6 +134,6 @@ def get_paravis_build_options(envAcc): '-DHDF5_ROOT_DIR=%s'%(envAcc["HDF5HOME"]), '-DPYTHON_EXECUTABLE=%s/bin/python%s'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]), '-DPYTHON_INCLUDE_DIR=%s'%(envAcc["PYTHON_INCLUDE"]), -# '-DSALOME_INSTALL_SCRIPT_SCRIPTS=%s'%topInstallDir, + '-DSALOME_INSTALL_SCRIPT_SCRIPTS=%s'%topInstallDir, '-DPYTHON_LIBRARY=%s/lib/libpython%s.so'%(envAcc["PYTHONHOME"],envAcc["PYTHON_VERSION"]) ] diff --git a/scripts/salome_config.py b/scripts/salome_config.py index 8326f60..8f156b1 100644 --- a/scripts/salome_config.py +++ b/scripts/salome_config.py @@ -2,6 +2,7 @@ import os import ConfigParser +import re def read_config_file(config_filename): config={} @@ -68,3 +69,17 @@ def initialize(config): 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 + +def update_config_file(filename, dico): + regex = '(('+'|'.join(dico.keys())+')\s*=)[^\r\n]*?(\r?\n|\r)' + pat = re.compile(regex) + + # replace a=b with a=c + def repl_func(mat,dic = dico): + return dic[mat.group(2)].join(mat.group(1,3)) + + with open(filename,'rb') as f: + content = f.read() + + with open(filename,'wb') as f: + f.write(pat.sub(repl_func,content))