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 *
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
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"
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)
#
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)
'-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',
'-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"])
]
import os
import ConfigParser
+import re
def read_config_file(config_filename):
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))