1import config.package 2import os 3 4class Configure(config.package.CMakePackage): 5 def __init__(self, framework): 6 config.package.CMakePackage.__init__(self, framework) 7 self.gitcommit = '0ddbf6e' # master 8 self.download = ['https://github.com/trilinos/xSDKTrilinos/archive/'+self.gitcommit+'.tar.gz','git://https://github.com/trilinos/xSDKTrilinos.git'] 9 self.downloaddirnames = ['xSDKTrilinos'] 10 self.includes = [] 11 self.functions = [] 12 self.cxx = 1 13 self.requirescxx11 = 1 14 self.downloadonWindows = 0 15 self.hastests = 1 16 self.linkedbypetsc = 0 17 self.useddirectly = 0 18 return 19 20 def setupDependencies(self, framework): 21 config.package.CMakePackage.setupDependencies(self, framework) 22 self.trilinos = framework.require('config.packages.Trilinos',self) 23 self.hypre = framework.require('config.packages.hypre',self) 24 self.x = framework.require('config.packages.X',self) 25 self.ssl = framework.require('config.packages.ssl',self) 26 self.triangle = framework.require('config.packages.Triangle',self) 27 self.exodusii = framework.require('config.packages.exodusii',self) 28 self.flibs = framework.require('config.packages.flibs',self) 29 self.cxxlibs = framework.require('config.packages.cxxlibs',self) 30 self.mathlib = framework.require('config.packages.mathlib',self) 31 # 32 # also requires the ./configure option --with-cxx-dialect=C++11 33 return 34 35 # the install is delayed until postProcess() since xSDKTrilinos install requires PETSc to be installed before xSDKTrilinos can be built 36 def Install(self): 37 return self.installDir 38 39 def configureLibrary(self): 40 ''' Since xSDKTrilinos cannot be built until after PETSc is compiled we need to just assume the downloaded library will work''' 41 if self.framework.clArgDB.has_key('with-xsdktrilinos'): 42 raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos; only --download-xsdktrilinos') 43 if self.framework.clArgDB.has_key('with-xsdktrilinos-dir'): 44 raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-dir; only --download-xsdktrilinos') 45 if self.framework.clArgDB.has_key('with-xsdktrilinos-include'): 46 raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-include; only --download-xsdktrilinos') 47 if self.framework.clArgDB.has_key('with-xsdktrilinos-lib'): 48 raise RuntimeError('Xsdktrilinos does not support --with-xsdktrilinos-lib; only --download-xsdktrilinos') 49 50 self.checkDownload() 51 self.include = [os.path.join(self.installDir,'include')] 52 self.lib = [os.path.join(self.installDir,'lib','libxsdktrilinos.a')] 53 self.found = 1 54 self.dlib = self.lib 55 if not hasattr(self.framework, 'packages'): 56 self.framework.packages = [] 57 self.framework.packages.append(self) 58 59 def formCMakeConfigureArgs(self): 60 args = config.package.CMakePackage.formCMakeConfigureArgs(self) 61 args.append('-DUSE_XSDK_DEFAULTS=YES') 62 args.append('-DTRILINOS_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0])) 63 args.append('-DTrilinos_INSTALL_DIR='+os.path.dirname(self.trilinos.include[0])) 64 if self.hypre.found: 65 args.append('-DTPL_ENABLE_HYPRE=ON') 66 args.append('-DTPL_HYPRE_LIBRARIES="'+self.libraries.toStringNoDupes(self.hypre.lib)+'"') 67 args.append('-DTPL_HYPRE_INCLUDE_DIRS='+self.headers.toStringNoDupes(self.hypre.include)[2:]) 68 69 args.append('-DTPL_ENABLE_PETSC=ON') 70 # These are packages that PETSc may be using that Trilinos is not be using 71 plibs = self.exodusii.dlib+self.triangle.lib+self.ssl.lib+self.x.lib 72 73 if not hasattr(self.compilers, 'FC'): 74 args.append('-DxSDKTrilinos_ENABLE_Fortran=OFF') 75 76 if self.framework.argDB['prefix']: 77 idir = os.path.join(self.getDefaultInstallDir(),'lib') 78 else: 79 idir = os.path.join(self.petscdir.dir,self.getArch(),'lib') 80 if self.framework.argDB['with-single-library']: 81 plibs = self.libraries.toStringNoDupes(['-L'+idir,' -lpetsc']+plibs) 82 else: 83 plibs = self.libraries.toStringNoDupes(['-L'+idir,'-lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys']+plibs) 84 85 args.append('-DTPL_PETSC_LIBRARIES="'+plibs+'"') 86 args.append('-DTPL_PETSC_INCLUDE_DIRS='+os.path.join(self.petscdir.dir,'include')) 87 88 if self.compilerFlags.debugging: 89 args.append('-DCMAKE_BUILD_TYPE=DEBUG') 90 args.append('-DxSDKTrilinos_ENABLE_DEBUG=YES') 91 else: 92 args.append('-DCMAKE_BUILD_TYPE=RELEASE') 93 args.append('-DxSDKTrilinos_ENABLE_DEBUG=NO') 94 95 args.append('-DxSDKTrilinos_EXTRA_LINK_FLAGS="'+self.libraries.toStringNoDupes(self.flibs.lib+self.cxxlibs.lib+self.mathlib.lib)+' '+self.compilers.LIBS+'"') 96 args.append('-DxSDKTrilinos_ENABLE_TESTS=ON') 97 return args 98 99 def postProcess(self): 100 self.compilePETSc() 101 config.package.CMakePackage.Install(self) 102 if not self.argDB['with-batch']: 103 try: 104 self.logPrintBox('Testing xSDKTrilinos; this may take several minutes') 105 output,err,ret = config.package.CMakePackage.executeShellCommand('cd '+os.path.join(self.packageDir,'build')+' && '+self.cmake.ctest,timeout=50, log = self.log) 106 output = output+err 107 self.log.write(output) 108 if output.find('Failure') > -1: 109 raise RuntimeError('Error running ctest on xSDKTrilinos: '+output) 110 except RuntimeError, e: 111 raise RuntimeError('Error running ctest on xSDKTrilinos: '+str(e)) 112 else: 113 self.logClear() 114 self.logPrintDivider( debugSection = 'screen') 115 self.logPrint('Since this is a batch system xSDKTrilinos cannot run tests directly. To run a short test suite.', debugSection = 'screen') 116 self.logPrint(' Obtain an interactive session with your batch system', debugSection = 'screen') 117 self.logPrint(' cd to installxSDK/xsdk/petsc/arch-linux2-c-debug/externalpackages/git.xsdktrilinos/build', debugSection = 'screen') 118 self.logPrint(' ctest', debugSection = 'screen') 119 linewidth = self.linewidth 120 self.linewidth = -1 121 if self.hypre.found: 122 self.logPrint(os.path.join(os.getcwd(),self.packageDir,'build','hypre','test','xSDKTrilinos_HypreTest.exe'), debugSection = 'screen') 123 self.logPrint(os.path.join(os.getcwd(),self.packageDir,'build','petsc','test','xSDKTrilinos_PETScAIJMatrix.exe'), debugSection = 'screen') 124 self.linewidth = linewidth 125 self.logPrintDivider( debugSection = 'screen') 126 self.logPrint('', debugSection = 'screen') 127 128 129 130 131 132 133