#!/usr/bin/env python import optparse import os import sys import subprocess import pdb TrueFalseStr=("False","True") TrueFalse={'no':False, 'yes':True} def GetCDMATHOptions(options): res=" -DCDMATH_DIR="+options.cdmath_dir return res def GetPETSC_DIROptions(options): res=' -DPETSC_DIR='+options.petsc_dir return res def GetDebugOptions(options): if options.debug == True: res=" -DCMAKE_BUILD_TYPE=Debug " else: res="" return res def GetPETSC_ARCHOptions(options): res=' -DPETSC_ARCH="'+options.petsc_arch+'"' return res def GetInstallPrefix(options): res=" -DCMAKE_INSTALL_PREFIX="+options.install_prefix return res def GetPythonOptions(options): res=" -DCOREFLOWS_WITH_PYTHON="+TrueFalseStr[options.python] return res def GetPackagesOptions(options): res=" -DCOREFLOWS_WITH_PACKAGE="+TrueFalseStr[options.packages] return res def GetDocOptions(options): res=" -DCOREFLOWS_WITH_DOCUMENTATION="+TrueFalseStr[options.doc] return res def GetGuiOptions(options): res=" -DCOREFLOWS_WITH_GUI="+TrueFalseStr[options.gui] return res def GetEclipseOptions(options): res=" -G\"Eclipse CDT4 - Unix Makefiles\""*(options.create_eclipse_project) return res def GetCmakeExecOption(options): cmakeExecutable=options.path_to_cmake_exec return cmakeExecutable def CheckOptions(parser): options, arguments = parser.parse_args() for stringToCheck in ['cdmath_dir', 'petsc_dir', 'petsc_arch']: if options.__dict__[stringToCheck] is None: parser.error("cannot determine "+stringToCheck) def printDocumentationInstructions(options): if options.doc: print "\n\t$ make doc\n\tto create the documentation." return def ForgeCMakeCommand(options): installPrefix=GetInstallPrefix(options) CDMATHOptions=GetCDMATHOptions(options) PETSC_DIROptions=GetPETSC_DIROptions(options) PETSC_ARCHOptions=GetPETSC_ARCHOptions(options) guiOptions=GetGuiOptions(options) docOptions=GetDocOptions(options) packagesOptions=GetPackagesOptions(options) debugOptions=GetDebugOptions(options) pythonOptions=GetPythonOptions(options) absolutePathToConfigure = os.path.abspath(sys.argv[0]) absolutePathToProjectDir = os.path.dirname(absolutePathToConfigure) eclipseProjectoptions=GetEclipseOptions(options) cmake_options=( installPrefix+" " +debugOptions +guiOptions+" " +pythonOptions+" " +CDMATHOptions+" " +PETSC_DIROptions+" " +PETSC_ARCHOptions+" " +docOptions+" " +packagesOptions+" " +eclipseProjectoptions ) cmake_executable=GetCmakeExecOption(options) cmake_cmd=cmake_executable+" "+cmake_options+" "+absolutePathToProjectDir return cmake_cmd def main(): usage = "usage: %prog [options]" p = optparse.OptionParser(usage=usage,conflict_handler="error") p.add_option('--prefix', default=".", metavar="