current_directory=os.path.dirname(os.path.abspath(__file__))
-def __init(envAcc={}, paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None):
+def __init(envAcc={}, paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None, verbose_mode=False):
# Read configuration
filename=os.path.join(current_directory, "SalomeMiniConfig.cfg")
config=read_config_file(filename)
if nb_jobs:
config["make_nb_jobs"] = nb_jobs
pass
+ config["verbose_mode"] = verbose_mode
# Check system prerequisites
check_gcc_version(config["gcc_version_min"], envAcc)
# Download archives
return os.path.abspath(destReal)
####################
-def __let_us_go(paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None):
+def __let_us_go(paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None, verbose_mode=False):
envAcc={}
- config=__init(paraview_version=paraview_version, use_pleiade_mirrors=use_pleiade_mirrors, nb_jobs=nb_jobs)
+ config=__init(paraview_version=paraview_version, use_pleiade_mirrors=use_pleiade_mirrors, nb_jobs=nb_jobs,verbose_mode=verbose_mode)
# Prepare build
rootDir="SalomeMini"
parser.add_option("--pleiade",
action="store_true", dest="pleiade", default=False,
help="Use PLEIADE mirrors (for EDF).")
+ parser.add_option("--verbose",
+ action="store_true", dest="verbose_mode", default=False,
+ help="Log to stdout/stderr and files. If false only log to files.")
(options, args) = parser.parse_args()
return options, args
print "Syntax error in paraview version"
sys.exit(1)
- __let_us_go(paraview_version=paraview_version, use_pleiade_mirrors=options.pleiade, nb_jobs=nb_jobs)
+ __let_us_go(paraview_version=paraview_version, use_pleiade_mirrors=options.pleiade, nb_jobs=nb_jobs, verbose_mode=options.verbose_mode)
config["softwareChanged"][pattern] = True
return myBuildDir,myInstallDir,True
-def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filename_err):
+def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filename_err,verbose_mode):
file_out=file(os.path.join(myBuildDir,filename_out),"w")
file_err=file(os.path.join(myBuildDir,filename_err),"w")
p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
f2.write(line)
pass
pass
- t1 = threading.Thread(target=tee_pipe, args=(p.stdout, file_out, sys.stdout))
- t2 = threading.Thread(target=tee_pipe, args=(p.stderr, file_err, sys.stderr))
+ if verbose_mode:
+ stdout=sys.stdout
+ stderr=sys.stderr
+ else:
+ stdout=open(os.devnull, 'w')
+ stderr=open(os.devnull, 'w')
+ t1 = threading.Thread(target=tee_pipe, args=(p.stdout, file_out, stdout))
+ t2 = threading.Thread(target=tee_pipe, args=(p.stderr, file_err, stderr))
t3 = threading.Thread(target=p.wait)
t1.start(); t2.start(); t3.start()
t1.join(); t2.join(); t3.join()
file_err.flush()
return p.returncode
-def __compilePart1(myCmd,envAcc,buildDir):
- returncode = __runCommandAndLogToFileAndStdOut(myCmd,buildDir,envAcc,cfgOut,cfgErr)
+def __compilePart1(myCmd,envAcc,buildDir,verbose_mode):
+ returncode = __runCommandAndLogToFileAndStdOut(myCmd,buildDir,envAcc,cfgOut,cfgErr,verbose_mode)
if 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,config,envAcc,buildDir,splitInstall):
print("make in %s"%(buildDir))
paraCompFlag = config["paraCompFlag"]
+ verbose_mode = config["verbose_mode"]
if not splitInstall:
- returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr)
+ returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr,verbose_mode)
if 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:
- returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag],buildDir,envAcc,compOut,compErr)
+ returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag],buildDir,envAcc,compOut,compErr,verbose_mode)
if 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)
- returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr)
+ returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr,verbose_mode)
if 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)
return myInstallDir
myCmd=[os.path.join(srcDir,"configure"),"--prefix=%s"%(myInstallDir)]+addCfgParam
print "Command: ", " ".join(myCmd)
- __compilePart1(myCmd,envAcc,myBuildDir)
+ __compilePart1(myCmd,envAcc,myBuildDir,config["verbose_mode"])
__compilePart2(topSrcDir,pattern,config,envAcc,myBuildDir,splitInstall)
return myInstallDir
return myInstallDir
myCmd=["cmake","-DCMAKE_INSTALL_PREFIX=%s"%(myInstallDir)]+addCfgParam+[srcDir]
print(" ".join(myCmd))
- __compilePart1(myCmd,envAcc,myBuildDir)
+ __compilePart1(myCmd,envAcc,myBuildDir,config["verbose_mode"])
__compilePart2(topSrcDir,pattern,config,envAcc,myBuildDir,False)
return myInstallDir