source: branches/testScripts/nightlyBuild.py @ 748

Last change on this file since 748 was 748, checked in by jpfasano, 13 years ago

Added sending an email msg to the person running the script containing log of what happened

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 9.7 KB
Line 
1#!/usr/bin/env python
2
3#------------------------------------------------------------------------
4# This file is distributed under the Common Public License.
5# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
6#------------------------------------------------------------------------
7
8import os
9import sys
10from socket import gethostname
11import NBprojectConfig
12import NBlogMessages
13import NBemail
14import NBosCommand
15import NBsvnCommand
16import NBcheckResult
17import NBbuildConfig
18
19
20execfile('NBuserParametersDefault.py')
21execfile('NBuserParameters.py')
22
23
24
25
26
27# TODO:
28#   -In userConfig allow one to optionally do a clean checkout and/or config
29#   -Reduce size of email messages.
30#   -Get working on windows
31
32
33#------------------------------------------------------------------------
34#  Main Program Starts Here
35#------------------------------------------------------------------------
36
37#------------------------------------------------------------------------
38#  If needed create the top level directory
39#------------------------------------------------------------------------
40if not os.path.isdir( NIGHTLY_BUILD_ROOT_DIR) :
41  os.makedirs(NIGHTLY_BUILD_ROOT_DIR)
42os.chdir( NIGHTLY_BUILD_ROOT_DIR)
43
44#------------------------------------------------------------------------
45#  Get the data directories if they don't already exist
46#------------------------------------------------------------------------
47dataBaseDir=os.path.join(NIGHTLY_BUILD_ROOT_DIR,'Data')
48if not os.path.isdir(dataBaseDir) :
49  os.makedirs(dataBaseDir)
50dataDirs=['Netlib','miplib3','Sample']
51for d in dataDirs :
52  dataDir=os.path.join(dataBaseDir,d)
53  if not os.path.isdir(dataDir) :
54    svnCmd='svn checkout https://projects.coin-or.org/svn/Data/releases/1.0.4/'+d+' '+d
55    if NBsvnCommand.run(svnCmd,dataBaseDir,'Data')!='OK' :
56      sys.exit(1)
57    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
58netlibDir=os.path.join(dataBaseDir,'Netlib')
59miplib3Dir=os.path.join(dataBaseDir,'miplib3')
60sampleDir=os.path.join(dataBaseDir,'Sample')
61
62#------------------------------------------------------------------------
63# Define loop invariant configuration values
64#------------------------------------------------------------------------
65configuration={}
66configuration['rootDir']=NIGHTLY_BUILD_ROOT_DIR
67configurations = set("")
68
69#------------------------------------------------------------------------
70# Define how code is is to be built. Choices are:
71# msSoln: use microsoft compiler with a solution (sln) file.
72# unixConfig: use sequence "./configure", "make", "make test"
73#------------------------------------------------------------------------
74if sys.platform=='win32' :
75  configuration['buildMethod']='msSln'
76else :
77  configuration['buildMethod']='unixConfig'
78
79#------------------------------------------------------------------------
80# Loop once for each project (get code, compile & link, and test).
81#------------------------------------------------------------------------
82for p in PROJECTS :
83
84  configuration['project']=p
85
86  #------------------------------------------------------------------------
87  # Loop once for each build configuration of p
88  #------------------------------------------------------------------------
89  buildConfigs = BUILDS[p]
90  for bc in buildConfigs:
91
92    #--------------------------------------------------------------------
93    # Does build reference another project's build configuration.
94    # If yes, then build p as specified by the reference project.
95    #--------------------------------------------------------------------
96    if 'Reference' in bc :
97      referencedConfigs = BUILDS[ bc['Reference'] ]
98      for c in referencedConfigs :
99        buildConfigs.append(c)
100      continue
101
102    #--------------------------------------------------------------------
103    # Setup subversion verion
104    #--------------------------------------------------------------------
105    if 'SvnVersion' not in bc :
106      print 'Error. BUILDS does not contain SvnVersion'
107      print '       Project is '+p
108      print '       BuildConfig is '+str(bc)
109      sys.exit(1)
110    if bc['SvnVersion']=='latestStable' :
111      lsv=NBsvnCommand.latestStableVersion(p)
112      if not lsv :
113        print 'Error. BUILDS configured to use lastest stable svn version'
114        print '       Project does not have a stable version'
115        print '       Project is '+p
116        print '       BuildConfig is '+str(bc)
117        sys.exit(1)
118      configuration['svnVersion']='stable/'+lsv
119    elif bc['SvnVersion']=='latestRelease' :
120      lrv=NBsvnCommand.latestReleaseVersion(p)
121      if not lrv :
122        print 'Error. BUILDS configured to use lastest release svn version'
123        print '       Project does not have a release version'
124        print '       Project is '+p
125        print '       BuildConfig is '+str(bc)
126        sys.exit(1)
127      configuration['svnVersion']='releases/'+lrv
128    else:
129      configuration['svnVersion']=bc['SvnVersion']
130
131    #--------------------------------------------------------------------
132    # Process Parameters that are used by unix configure style build
133    #--------------------------------------------------------------------
134    if configuration['buildMethod']=='unixConfig' :
135      #--------------------------------------------------------------------
136      # Doing a unix config type build.  Grab unix config parms
137      #--------------------------------------------------------------------
138
139      #--------------------------------------------------------------------
140      # Setup usage of 3rd Party code
141      #--------------------------------------------------------------------
142      if 'noThirdParty' in configuration: configuration.pop('noThirdParty')
143      if 'ThirdParty' in bc:
144        if bc['ThirdParty'].lower()=='yes' :
145          configuration['noThirdParty']=False
146        else:
147          configuration['noThirdParty']=True
148
149      #--------------------------------------------------------------------
150      # Set config options
151      #--------------------------------------------------------------------
152      configuration['configOptions']={}
153      configuration['configOptions']['unique']=""
154      configuration['configOptions']['invariant']=""
155      if 'OptLevel' not in bc :
156        print 'Error. BUILDS does not contain OptLevel'
157        print '       Project is '+p
158        print '       BuildConfig is '+str(bc)
159        sys.exit(1)
160      if bc['OptLevel']=='Debug' :
161        configuration['configOptions']['unique']+=" --enable-debug"
162      if 'AdditionalConfigOptions' in bc :
163        configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions']
164
165      configuration['configOptions']['invariant']+=" "+ CONFIGURE_FLAGS
166
167      #--------------------------------------------------------------------
168      # Deal with coin projects to be skipped by ./config
169      #--------------------------------------------------------------------
170      if 'SkipProjects' in configuration: configuration.pop('SkipProjects')
171      if 'SkipProjects' in bc :
172        configuration['SkipProjects']=bc['SkipProjects']
173     
174      #---------------------------------------------------------------------
175      # Set up test commands
176      #---------------------------------------------------------------------
177      configuration['test']={}
178      if NBprojectConfig.CFG_BLD_TEST.has_key(p) :
179        configuration['test']=NBprojectConfig.CFG_BLD_TEST[p]
180      else :
181        # No test commands so remove from configuration
182        configuration.pop('test') 
183
184
185    if configuration['buildMethod']=='msSln' :
186      #--------------------------------------------------------------------
187      # Doing a microsoft solution  build.  Grap ms sln parms
188      #--------------------------------------------------------------------
189
190      #---------------------------------------------------------------------
191      # Set up test executables
192      #---------------------------------------------------------------------
193      configuration['test']={}
194      if NBprojectConfig.SLN_BLD_TEST.has_key(p) :
195        configuration['test']=NBprojectConfig.SLN_BLD_TEST[p]
196      else :
197        # No test executables so remove from configuration
198        configuration.pop('test')
199       
200      #---------------------------------------------------------------------
201      # If solution file is not in standard place then specify it's location
202      #---------------------------------------------------------------------
203      configuration['slnFile']=''
204      if NBprojectConfig.SLN_FILE.has_key(p) :
205        configuration['slnFile']=NBprojectConfig.SLN_FILE[p]         
206      else :
207        configuration.pop('slnFile')
208               
209    #---------------------------------------------------------------------
210    # Modify any executable commands to have location of data directories
211    #---------------------------------------------------------------------
212    if configuration.has_key('test') :
213      for t in range( len(configuration['test']) ) :
214        testCmd=configuration['test'][t]['cmd']
215        testCmd=testCmd.replace('_NETLIBDIR_',netlibDir)
216        testCmd=testCmd.replace('_MIPLIB3DIR_',miplib3Dir)
217        testCmd=testCmd.replace('_SAMPLEDIR_',sampleDir)
218        configuration['test'][t]['cmd']=testCmd
219
220    #--------------------------------------------------
221    # Build & Test the configuration, if not previously done
222    #--------------------------------------------------
223    if str(configuration) not in configurations :
224      NBbuildConfig.run(configuration)
225      configurations=configurations | set([str(configuration)])
226   
227
228
229NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
230
231# Email log messages to person running script
232toAddrs = [NBemail.unscrambleAddress(MY_EMAIL_ADDR)]
233subject = "NightlyBuild Log from "+gethostname()+" on "+sys.platform
234NBemail.send(toAddrs,subject,NBlogMessages.getAllMessages())
235
236sys.exit(0)
237
Note: See TracBrowser for help on using the repository browser.