source: branches/testScripts/nightlyBuild.py @ 769

Last change on this file since 769 was 769, checked in by stefan, 13 years ago

make the logfile object a global variable

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