source: branches/testScripts/nightlyBuild.py @ 787

Last change on this file since 787 was 787, checked in by kmartin, 12 years ago

icorporate a mingw build

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.8 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
11from sets import Set
12import NBprojectConfig
13import NBlogMessages
14import NBemail
15import NBosCommand
16import NBsvnCommand
17import NBcheckResult
18import NBbuildConfig
19
20
21execfile('NBuserParametersDefault.py')
22execfile('NBuserParameters.py')
23
24
25
26
27
28# TODO:
29#   -Reduce size of email messages.
30#   -Get config style build 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#  If needed open the logfile
46#------------------------------------------------------------------------
47
48if len(LOGFILE) > 0 and not LOGFILE.isspace() :
49  NBlogMessages.openLogFile()
50
51#------------------------------------------------------------------------
52#  Get the data directories if they don't already exist
53#------------------------------------------------------------------------
54dataBaseDir=os.path.join(NIGHTLY_BUILD_ROOT_DIR,'Data')
55if not os.path.isdir(dataBaseDir) :
56  os.makedirs(dataBaseDir)
57dataDirs=['Netlib','miplib3','Sample']
58for d in dataDirs :
59  dataDir=os.path.join(dataBaseDir,d)
60  if not os.path.isdir(dataDir) :
61    svnCmd='svn checkout https://projects.coin-or.org/svn/Data/releases/1.0.4/'+d+' '+d
62    svnResult=NBsvnCommand.run(svnCmd,dataBaseDir,'Data')
63    if svnResult['returnCode'] != 0 :
64      sys.exit(1)
65    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
66netlibDir=os.path.join(dataBaseDir,'Netlib')
67miplib3Dir=os.path.join(dataBaseDir,'miplib3')
68sampleDir=os.path.join(dataBaseDir,'Sample')
69
70#------------------------------------------------------------------------
71# Define loop invariant configuration values
72#------------------------------------------------------------------------
73configuration={}
74configuration['rootDir']=NIGHTLY_BUILD_ROOT_DIR
75configurations = Set([""])
76
77#------------------------------------------------------------------------
78# Define how code is is to be built. Choices are:
79# msSoln: use microsoft compiler with a solution (sln) file.
80# unixConfig: use sequence "./configure", "make", "make test"
81#------------------------------------------------------------------------
82if sys.platform=='win32' :
83  # see if we are running Mingw
84  # assume Bourne shell in path
85  result=NBosCommand.run( "sh -c ls" )
86  if result['returnCode'] == 0 :
87    configuration['buildMethod']='mingw'
88  else:
89    configuration['buildMethod']='msSln'
90else :
91  configuration['buildMethod']='unixConfig'
92
93#------------------------------------------------------------------------
94# Loop once for each project (get code, compile & link, and test).
95#------------------------------------------------------------------------
96for p in PROJECTS :
97
98  configuration['project']=p
99  configuration['clear previous build']=CLEAR_PREVIOUS_BUILD
100
101  #------------------------------------------------------------------------
102  # Loop once for each build configuration of p
103  #------------------------------------------------------------------------
104  buildConfigs = BUILDS[p]
105  for bc in buildConfigs:
106
107    #--------------------------------------------------------------------
108    # Does build reference another project's build configuration.
109    # If yes, then build p as specified by the reference project.
110    #--------------------------------------------------------------------
111    if 'Reference' in bc :
112      referencedConfigs = BUILDS[ bc['Reference'] ]
113      for c in referencedConfigs :
114        buildConfigs.append(c)
115      continue
116
117    #--------------------------------------------------------------------
118    # Setup subversion verion
119    #--------------------------------------------------------------------
120    if 'SvnVersion' not in bc :
121      print 'Error. BUILDS does not contain SvnVersion'
122      print '       Project is '+p
123      print '       BuildConfig is '+str(bc)
124      sys.exit(1)
125    if bc['SvnVersion']=='latestStable' :
126      lsv=NBsvnCommand.latestStableVersion(p)
127      if not lsv :
128        print 'Error. BUILDS configured to use lastest stable svn version'
129        print '       Project does not have a stable version'
130        print '       Project is '+p
131        print '       BuildConfig is '+str(bc)
132        sys.exit(1)
133      configuration['svnVersion']='stable/'+lsv
134    elif bc['SvnVersion']=='latestRelease' :
135      lrv=NBsvnCommand.latestReleaseVersion(p)
136      if not lrv :
137        print 'Error. BUILDS configured to use lastest release svn version'
138        print '       Project does not have a release version'
139        print '       Project is '+p
140        print '       BuildConfig is '+str(bc)
141        sys.exit(1)
142      configuration['svnVersion']='releases/'+lrv
143    else:
144      configuration['svnVersion']=bc['SvnVersion']
145
146    #--------------------------------------------------------------------
147    # Make sure optlevel specified
148    #--------------------------------------------------------------------
149    if 'OptLevel' not in bc :
150      print 'Error. BUILDS does not contain OptLevel'
151      print '       Project is '+p
152      print '       BuildConfig is '+str(bc)
153      sys.exit(1)
154    elif bc['OptLevel']!="Debug" and bc['OptLevel']!="Default" :
155      print 'Error. BUILDS has unrecognized OptLevel'
156      print '       Project is '+p
157      print '       BuildConfig is '+str(bc)
158      print '       Expected OptLevel: Debug or Default'
159      sys.exit(1)
160
161    #--------------------------------------------------------------------
162    # Process Parameters that are used by unix configure style build
163    #--------------------------------------------------------------------
164    if configuration['buildMethod']=='unixConfig' or configuration['buildMethod']=='mingw':
165      #--------------------------------------------------------------------
166      # Doing a unix config type build.  Grab unix config parms
167      #--------------------------------------------------------------------
168
169      #--------------------------------------------------------------------
170      # Setup usage of 3rd Party code
171      #--------------------------------------------------------------------
172      if 'noThirdParty' in configuration: configuration.pop('noThirdParty')
173      if 'ThirdParty' in bc:
174        if bc['ThirdParty'].lower()=='yes' :
175          configuration['noThirdParty']=False
176        else:
177          configuration['noThirdParty']=True
178
179      #--------------------------------------------------------------------
180      # Set config options
181      #--------------------------------------------------------------------
182      configuration['configOptions']={}
183      configuration['configOptions']['unique']=""
184      configuration['configOptions']['invariant']=""
185
186      if bc['OptLevel']=='Debug' :
187        configuration['configOptions']['unique']+=" --enable-debug"
188      if 'AdditionalConfigOptions' in bc :
189        configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions']
190
191      configuration['configOptions']['invariant']+=" "+ CONFIGURE_FLAGS
192
193      #--------------------------------------------------------------------
194      # Deal with coin projects to be skipped by ./config
195      #--------------------------------------------------------------------
196      if 'SkipProjects' in configuration: configuration.pop('SkipProjects')
197      if 'SkipProjects' in bc :
198        configuration['SkipProjects']=bc['SkipProjects']
199     
200      #---------------------------------------------------------------------
201      # Set up test commands
202      #---------------------------------------------------------------------
203      configuration['test']={}
204      if NBprojectConfig.CFG_BLD_TEST.has_key(p) :
205        configuration['test']=NBprojectConfig.CFG_BLD_TEST[p]
206      else :
207        # No test commands so remove from configuration
208        configuration.pop('test') 
209
210
211    if configuration['buildMethod']=='msSln' :
212      #--------------------------------------------------------------------
213      # Doing a microsoft solution  build.  Grap ms sln parms
214      #--------------------------------------------------------------------
215
216      #---------------------------------------------------------------------
217      # Set up test executables
218      #---------------------------------------------------------------------
219      configuration['test']={}
220      if NBprojectConfig.SLN_BLD_TEST.has_key(p) :
221        configuration['test']=NBprojectConfig.SLN_BLD_TEST[p]
222      else :
223        # No test executables so remove from configuration
224        configuration.pop('test')
225       
226      #---------------------------------------------------------------------
227      # If solution file is not in standard place then specify it's location
228      #---------------------------------------------------------------------
229      configuration['slnFile']=''
230      if NBprojectConfig.SLN_FILE.has_key(p) :
231        configuration['slnFile']=NBprojectConfig.SLN_FILE[p]         
232      else :
233        configuration.pop('slnFile')
234      configuration['slnDir']=''
235      if NBprojectConfig.SLN_DIR.has_key(p) :
236        configuration['slnDir']=NBprojectConfig.SLN_DIR[p]         
237      else :
238        configuration.pop('slnDir')
239       
240
241      #--------------------------------------------------------------------
242      # Set msbuild configuration parm (Release or Debug)
243      #--------------------------------------------------------------------
244      #if bc['OptLevel']=='Debug' :
245      #  configuration['msbuild']="Debug"
246      #else :
247      #  configuration['msbuild']="Release"
248
249    #---------------------------------------------------------------------
250    # Get Run parm and pass it along
251    #---------------------------------------------------------------------
252    configuration['Run']='noSuccessOrAfterChange'
253    if 'Run' in bc :
254      if bc['Run'].lower()=='afterchange' :
255        configuration['Run']='afterChange'
256      elif bc['Run'].lower()=='always' :
257        configuration['Run']='always'
258               
259    #---------------------------------------------------------------------
260    # Modify any executable commands to have location of data directories
261    #---------------------------------------------------------------------
262    if configuration.has_key('test') :
263      for t in range( len(configuration['test']) ) :
264        testCmd=configuration['test'][t]['cmd']
265        testCmd=testCmd.replace('_NETLIBDIR_',netlibDir)
266        testCmd=testCmd.replace('_MIPLIB3DIR_',miplib3Dir)
267        testCmd=testCmd.replace('_SAMPLEDIR_',sampleDir)
268        configuration['test'][t]['cmd']=testCmd
269
270    #--------------------------------------------------
271    # Build & Test the configuration, if not previously done
272    #--------------------------------------------------
273    if str(configuration) not in configurations :
274      NBbuildConfig.run(configuration)
275      configurations=configurations | Set([str(configuration)])
276   
277
278
279NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
280
281# Email log messages to person running script
282toAddrs = [NBemail.unscrambleAddress(MY_EMAIL_ADDR)]
283subject = "NightlyBuild Log on "+sys.platform+" from "+gethostname()
284NBemail.send(toAddrs,subject,NBlogMessages.getAllMessages())
285
286#------------------------------------------------------------------------
287#  If needed close the logfile
288#------------------------------------------------------------------------
289
290if len(LOGFILE) > 0 and not LOGFILE.isspace() :
291  NBlogMessages.closeLogFile()
292
293sys.exit(0)
294
Note: See TracBrowser for help on using the repository browser.