source: branches/testScripts/nightlyBuild.py @ 740

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

Merging code for windows and unix

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 10.5 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      # Setup checkMakeTest
185      #---------------------------------------------------------------------
186      #configuration['checkMakeTest']=NBprojectConfig.CHECK_MAKE_TEST[p]
187
188
189      #---------------------------------------------------------------------
190      # Set up unitTest
191      #---------------------------------------------------------------------
192      #configuration['unitTest']={}
193      #if NBprojectConfig.UNITTEST_CMD.has_key(p) :
194#
195      #  unitTestCmdTemplate=NBprojectConfig.UNITTEST_CMD[p]
196      #  unitTestCmd=unitTestCmdTemplate.replace('_NETLIBDIR_',netlibDir)
197      #  unitTestCmd=unitTestCmd.replace('_MIPLIB3DIR_',miplib3Dir)
198      #  unitTestCmd=unitTestCmd.replace('_SAMPLEDIR_',sampleDir)
199#
200      #  configuration['unitTest']['command']=unitTestCmd
201      #  configuration['unitTest']['checkUnitTest']=NBprojectConfig.CHECK_UNITTEST[p]
202      #  configuration['unitTest']['path']=NBprojectConfig.UNITTEST_DIR[p]
203#
204      #else :
205      #  # No unitTest so remove from configuration
206      #  configuration.pop('unitTest')
207
208    if configuration['buildMethod']=='msSln' :
209      #--------------------------------------------------------------------
210      # Doing a microsoft solution  build.  Grap ms sln parms
211      #--------------------------------------------------------------------
212
213      #---------------------------------------------------------------------
214      # Set up test executables
215      #---------------------------------------------------------------------
216      configuration['test']={}
217      if NBprojectConfig.SLN_BLD_TEST.has_key(p) :
218        configuration['test']=NBprojectConfig.SLN_BLD_TEST[p]
219      else :
220        # No test executables so remove from configuration
221        configuration.pop('test')
222       
223      #---------------------------------------------------------------------
224      # If solution file is not in standard place then specify it's location
225      #---------------------------------------------------------------------
226      configuration['slnFile']=''
227      if NBprojectConfig.SLN_FILE.has_key(p) :
228        configuration['slnFile']=NBprojectConfig.SLN_FILE[p]         
229      else :
230        configuration.pop('slnFile')
231               
232    #---------------------------------------------------------------------
233    # Modify any executable commands to have location of data directories
234    #---------------------------------------------------------------------
235    if configuration.has_key('test') :
236      for t in range( len(configuration['test']) ) :
237        testCmd=configuration['test'][t]['cmd']
238        testCmd=testCmd.replace('_NETLIBDIR_',netlibDir)
239        testCmd=testCmd.replace('_MIPLIB3DIR_',miplib3Dir)
240        testCmd=testCmd.replace('_SAMPLEDIR_',sampleDir)
241        configuration['test'][t]['cmd']=testCmd
242
243    #--------------------------------------------------
244    # Build & Test the configuration, if not previously done
245    #--------------------------------------------------
246    if str(configuration) not in configurations :
247      NBbuildConfig.run(configuration)
248      configurations=configurations | set([str(configuration)])
249   
250
251
252NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
253
254sys.exit(0)
255
Note: See TracBrowser for help on using the repository browser.