source: branches/testScripts/nightlyBuild.py @ 761

Last change on this file since 761 was 750, checked in by jpfasano, 12 years ago

Added some additional checks that configuration is specified correctly.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 10.4 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    # Make sure optlevel specified
133    #--------------------------------------------------------------------
134    if 'OptLevel' not in bc :
135      print 'Error. BUILDS does not contain OptLevel'
136      print '       Project is '+p
137      print '       BuildConfig is '+str(bc)
138      sys.exit(1)
139    elif bc['OptLevel']!="Debug" and bc['OptLevel']!="Default" :
140      print 'Error. BUILDS has unrecognized OptLevel'
141      print '       Project is '+p
142      print '       BuildConfig is '+str(bc)
143      print '       Expected OptLevel: Debug or Default'
144      sys.exit(1)
145
146    #--------------------------------------------------------------------
147    # Process Parameters that are used by unix configure style build
148    #--------------------------------------------------------------------
149    if configuration['buildMethod']=='unixConfig' :
150      #--------------------------------------------------------------------
151      # Doing a unix config type build.  Grab unix config parms
152      #--------------------------------------------------------------------
153
154      #--------------------------------------------------------------------
155      # Setup usage of 3rd Party code
156      #--------------------------------------------------------------------
157      if 'noThirdParty' in configuration: configuration.pop('noThirdParty')
158      if 'ThirdParty' in bc:
159        if bc['ThirdParty'].lower()=='yes' :
160          configuration['noThirdParty']=False
161        else:
162          configuration['noThirdParty']=True
163
164      #--------------------------------------------------------------------
165      # Set config options
166      #--------------------------------------------------------------------
167      configuration['configOptions']={}
168      configuration['configOptions']['unique']=""
169      configuration['configOptions']['invariant']=""
170
171      if bc['OptLevel']=='Debug' :
172        configuration['configOptions']['unique']+=" --enable-debug"
173      if 'AdditionalConfigOptions' in bc :
174        configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions']
175
176      configuration['configOptions']['invariant']+=" "+ CONFIGURE_FLAGS
177
178      #--------------------------------------------------------------------
179      # Deal with coin projects to be skipped by ./config
180      #--------------------------------------------------------------------
181      if 'SkipProjects' in configuration: configuration.pop('SkipProjects')
182      if 'SkipProjects' in bc :
183        configuration['SkipProjects']=bc['SkipProjects']
184     
185      #---------------------------------------------------------------------
186      # Set up test commands
187      #---------------------------------------------------------------------
188      configuration['test']={}
189      if NBprojectConfig.CFG_BLD_TEST.has_key(p) :
190        configuration['test']=NBprojectConfig.CFG_BLD_TEST[p]
191      else :
192        # No test commands so remove from configuration
193        configuration.pop('test') 
194
195
196    if configuration['buildMethod']=='msSln' :
197      #--------------------------------------------------------------------
198      # Doing a microsoft solution  build.  Grap ms sln parms
199      #--------------------------------------------------------------------
200
201      #---------------------------------------------------------------------
202      # Set up test executables
203      #---------------------------------------------------------------------
204      configuration['test']={}
205      if NBprojectConfig.SLN_BLD_TEST.has_key(p) :
206        configuration['test']=NBprojectConfig.SLN_BLD_TEST[p]
207      else :
208        # No test executables so remove from configuration
209        configuration.pop('test')
210       
211      #---------------------------------------------------------------------
212      # If solution file is not in standard place then specify it's location
213      #---------------------------------------------------------------------
214      configuration['slnFile']=''
215      if NBprojectConfig.SLN_FILE.has_key(p) :
216        configuration['slnFile']=NBprojectConfig.SLN_FILE[p]         
217      else :
218        configuration.pop('slnFile')
219
220      #--------------------------------------------------------------------
221      # Set msbuild configuration parm (Release or Debug)
222      #--------------------------------------------------------------------
223      #if bc['OptLevel']=='Debug' :
224      #  configuration['msbuild']="Debug"
225      #else :
226      #  configuration['msbuild']="Release"
227 
228               
229    #---------------------------------------------------------------------
230    # Modify any executable commands to have location of data directories
231    #---------------------------------------------------------------------
232    if configuration.has_key('test') :
233      for t in range( len(configuration['test']) ) :
234        testCmd=configuration['test'][t]['cmd']
235        testCmd=testCmd.replace('_NETLIBDIR_',netlibDir)
236        testCmd=testCmd.replace('_MIPLIB3DIR_',miplib3Dir)
237        testCmd=testCmd.replace('_SAMPLEDIR_',sampleDir)
238        configuration['test'][t]['cmd']=testCmd
239
240    #--------------------------------------------------
241    # Build & Test the configuration, if not previously done
242    #--------------------------------------------------
243    if str(configuration) not in configurations :
244      NBbuildConfig.run(configuration)
245      configurations=configurations | set([str(configuration)])
246   
247
248
249NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
250
251# Email log messages to person running script
252toAddrs = [NBemail.unscrambleAddress(MY_EMAIL_ADDR)]
253subject = "NightlyBuild Log from "+gethostname()+" on "+sys.platform
254NBemail.send(toAddrs,subject,NBlogMessages.getAllMessages())
255
256sys.exit(0)
257
Note: See TracBrowser for help on using the repository browser.