source: branches/testScripts/nightlyBuild.py @ 771

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

run configure only if last configure run was not ok OR svn update updated a configure or a *.in file

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