source: branches/testScripts/newNightlyBuild.py @ 674

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

Tried to create a nicer vpath directory name.
Added log message to indicate current directory.

  • Property svn:executable set to *
File size: 6.8 KB
Line 
1#!/usr/bin/env python
2
3import os
4import sys
5
6import NBuserConfig
7import NBprojectConfig
8import NBlogMessages
9import NBemail
10import NBosCommand
11import NBsvnCommand
12import NBcheckResult
13import NBbuildConfig
14
15# TODO:
16#   -Get some information about the platform and put this in email failure message.
17#   -In userConfig allow one to optionally do a clean checkout and/or config
18#   -Don't do build if 'svn update' doesn't change anything and prior test was OK.
19#     (no need to re-run if nothing has changed since prior run)
20#   -Skip make of project that depend on a project which make had been failing. (Similar for configure.)
21#    But also tell project managers of skiped project that their project was skipped.
22#   -Store output of get.XXX calls, make, make test, configures... in some files.
23#   -Allow a fine configuration of which build tests to run per project.
24#   -Move actual [get project, configure, make, tests] part into an extra file.
25
26
27#------------------------------------------------------------------------
28#  Main Program Starts Here 
29#------------------------------------------------------------------------
30
31#------------------------------------------------------------------------
32#  If needed create the top level directory
33#------------------------------------------------------------------------
34if not os.path.isdir(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR) :
35  os.makedirs(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
36os.chdir(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
37
38#------------------------------------------------------------------------
39#  Get the data directories if they don't already exist
40#------------------------------------------------------------------------
41dataBaseDir=os.path.join(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR,'Data')
42if not os.path.isdir(dataBaseDir) :
43  os.makedirs(dataBaseDir)
44dataDirs=['Netlib','miplib3']
45for d in dataDirs :
46  dataDir=os.path.join(dataBaseDir,d)
47  if not os.path.isdir(dataDir) :
48    svnCmd=os.path.join(NBuserConfig.SVNPATH_PREFIX,'svn') + ' checkout https://projects.coin-or.org/svn/Data/releases/1.0.0/'+d+' '+d
49    if NBsvnCommand.run(svnCmd,dataBaseDir,'Data')!='OK' :
50      sys.exit(1)
51    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
52netlibDir=os.path.join(dataBaseDir,'Netlib')
53miplib3Dir=os.path.join(dataBaseDir,'miplib3')
54
55#------------------------------------------------------------------------
56# Loop once for each project (get code, compile & link, and test).
57#------------------------------------------------------------------------
58configuration={}
59configuration['rootDir']=NBuserConfig.NIGHTLY_BUILD_ROOT_DIR
60#for p,buildConfigs in NBprojectConfig.BUILDS.iteritems():
61for p in NBuserConfig.PROJECTS :
62
63  configuration['project']=p
64
65  #------------------------------------------------------------------------
66  # Loop once for each build configuration of p
67  #------------------------------------------------------------------------
68  buildConfigs = NBprojectConfig.BUILDS[p]
69  for bc in buildConfigs:
70
71    #--------------------------------------------------------------------
72    # Does build reference another project's build configuration.
73    # If yes, then build p as specified by the reference project.
74    #--------------------------------------------------------------------
75    if 'Reference' in bc :
76      referencedConfigs = NBprojectConfig.BUILDS[ bc['Reference'] ]
77      for c in referencedConfigs :
78        buildConfigs.append(c)
79      continue
80
81    #--------------------------------------------------------------------
82    # Setup subversion verion
83    #--------------------------------------------------------------------
84    if 'SvnVersion' not in bc :
85      print 'Error. BUILDS does not contain SvnVersion'
86      print '       Project is '+p
87      print '       BuildConfig is '+str(bc)
88      sys.exit(1)
89    if bc['SvnVersion']=='latestStable' :
90      configuration['svnVersion']='stable/'+NBsvnCommand.latestStableVersion(p)
91    else:
92      configuration['svnVersion']=bc['SvnVersion']
93
94    #--------------------------------------------------------------------
95    # Setup usage of 3rd Party code
96    #--------------------------------------------------------------------
97    if 'noThirdParty' in configuration: configuration.pop('noThirdParty')
98    if 'ThirdParty' in bc:
99      if bc['ThirdParty'].lower()=='yes' :
100        configuration['noThirdParty']=False
101      else:
102        configuration['noThirdParty']=True
103
104    #--------------------------------------------------------------------
105    # Set config options
106    #--------------------------------------------------------------------
107    configuration['configOptions']={}
108    configuration['configOptions']['unique']=""
109    configuration['configOptions']['invariant']=""
110    if 'OptLevel' not in bc :
111      print 'Error. BUILDS does not contain OptLevel'
112      print '       Project is '+p
113      print '       BuildConfig is '+str(bc)
114      sys.exit(1)
115    if bc['OptLevel']=='Debug' :
116      configuration['configOptions']['unique']+=" --enable-debug"
117    if 'AdditionalConfigOptions' in bc :
118      configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions']
119
120    configuration['configOptions']['invariant']+=" "+NBuserConfig.CONFIGURE_FLAGS
121
122    #--------------------------------------------------------------------
123    # Deal with coin projects to be skipped by ./config
124    #--------------------------------------------------------------------
125    if 'SkipProjects' in configuration: configuration.pop('SkipProjects')
126    if 'SkipProjects' in bc :
127      configuration['SkipProjects']=bc['SkipProjects']
128
129    #---------------------------------------------------------------------
130    # Setup checkMakeTest
131    #---------------------------------------------------------------------
132    configuration['checkMakeTest']=NBcheckResult.didTestFail
133
134
135    #---------------------------------------------------------------------
136    # Set up unitTest
137    #---------------------------------------------------------------------
138    configuration['unitTest']={}
139    if NBprojectConfig.UNITTEST_CMD.has_key(p) :
140
141      unitTestCmdTemplate=NBprojectConfig.UNITTEST_CMD[p]
142      unitTestCmd=unitTestCmdTemplate.replace('_NETLIBDIR_',netlibDir)
143      unitTestCmd=unitTestCmd.replace('_MIPLIB3DIR_',miplib3Dir)
144
145      configuration['unitTest']['command']=unitTestCmd
146      configuration['unitTest']['checkUnitTest']=NBcheckResult.didTestFail
147      configuration['unitTest']['path']=NBprojectConfig.UNITTEST_DIR[p]
148
149    else :
150      # No unitTest so remove from configuration
151      configuration.pop('unitTest')
152
153    #--------------------------------------------------
154    # Build & Test the configuration
155    #--------------------------------------------------
156    NBbuildConfig.run(configuration)
157
158
159NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
160
161sys.exit(0)
162
Note: See TracBrowser for help on using the repository browser.