source: branches/testScripts/nightlyBuild.py @ 744

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

more clean up. email should now include nightlyBuild log messages

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