]> SALOME platform Git repositories - tools/pvdeliv.git/commitdiff
Salome HOME
add --with-paraview-version option
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 31 Aug 2016 08:52:13 +0000 (10:52 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 31 Aug 2016 08:52:13 +0000 (10:52 +0200)
scripts/BuildSalomeMini.py
scripts/SalomeMiniConfig.cfg
scripts/salome_build_options.py
scripts/salome_config.py

index 0ebfdacccbd6cbcd03e8c809b95e45d818f66120..c8f4e4ab97760418ae5f7f755bf8810741846892 100755 (executable)
@@ -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)
index 5f39ede7d30557f42f88e87bf32a1fac7162b388..1ba374c2765673c8128105249664aa9b04351ab2 100644 (file)
@@ -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]
index 5a55170adeff9294ad17e549ad97c1e8c9b4cd90..3d39361c12d58c68ba4284d6482464ce39735dd6 100644 (file)
@@ -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"])
     ]
index 8326f601174954e03c65e7fb8cc59b9a41f6da36..8f156b1f703ee2916b5a407a9da22efab99835b3 100644 (file)
@@ -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))