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 | |
---|
8 | import os |
---|
9 | import sys |
---|
10 | import NBprojectConfig |
---|
11 | import NBlogMessages |
---|
12 | import NBemail |
---|
13 | import NBosCommand |
---|
14 | import NBsvnCommand |
---|
15 | import NBcheckResult |
---|
16 | import NBbuildConfig |
---|
17 | |
---|
18 | |
---|
19 | execfile('NBuserParametersDefault.py') |
---|
20 | execfile('NBuserParameters.py') |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | |
---|
26 | # TODO: |
---|
27 | # -In userConfig allow one to optionally do a clean checkout and/or config |
---|
28 | # -Clean up the kludge that tests if "make test" and 'unitTest' were |
---|
29 | # successfull |
---|
30 | # -Reduce size of email messages. |
---|
31 | # -Get working on windows |
---|
32 | |
---|
33 | |
---|
34 | #------------------------------------------------------------------------ |
---|
35 | # Main Program Starts Here |
---|
36 | #------------------------------------------------------------------------ |
---|
37 | |
---|
38 | #------------------------------------------------------------------------ |
---|
39 | # If needed create the top level directory |
---|
40 | #------------------------------------------------------------------------ |
---|
41 | if not os.path.isdir( NIGHTLY_BUILD_ROOT_DIR) : |
---|
42 | os.makedirs(NIGHTLY_BUILD_ROOT_DIR) |
---|
43 | os.chdir( NIGHTLY_BUILD_ROOT_DIR) |
---|
44 | |
---|
45 | #------------------------------------------------------------------------ |
---|
46 | # Get the data directories if they don't already exist |
---|
47 | #------------------------------------------------------------------------ |
---|
48 | dataBaseDir=os.path.join(NIGHTLY_BUILD_ROOT_DIR,'Data') |
---|
49 | if not os.path.isdir(dataBaseDir) : |
---|
50 | os.makedirs(dataBaseDir) |
---|
51 | dataDirs=['Netlib','miplib3'] |
---|
52 | for d in dataDirs : |
---|
53 | dataDir=os.path.join(dataBaseDir,d) |
---|
54 | if not os.path.isdir(dataDir) : |
---|
55 | svnCmd=os.path.join( SVNPATH_PREFIX,'svn') + ' checkout https://projects.coin-or.org/svn/Data/releases/1.0.0/'+d+' '+d |
---|
56 | if NBsvnCommand.run(svnCmd,dataBaseDir,'Data')!='OK' : |
---|
57 | sys.exit(1) |
---|
58 | result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d') |
---|
59 | netlibDir=os.path.join(dataBaseDir,'Netlib') |
---|
60 | miplib3Dir=os.path.join(dataBaseDir,'miplib3') |
---|
61 | |
---|
62 | #------------------------------------------------------------------------ |
---|
63 | # Loop once for each project (get code, compile & link, and test). |
---|
64 | #------------------------------------------------------------------------ |
---|
65 | configuration={} |
---|
66 | configuration['rootDir']=NIGHTLY_BUILD_ROOT_DIR |
---|
67 | #for p,buildConfigs in NBprojectConfig.BUILDS.iteritems(): |
---|
68 | for p in PROJECTS : |
---|
69 | |
---|
70 | configuration['project']=p |
---|
71 | |
---|
72 | #------------------------------------------------------------------------ |
---|
73 | # Loop once for each build configuration of p |
---|
74 | #------------------------------------------------------------------------ |
---|
75 | buildConfigs = BUILDS[p] |
---|
76 | for bc in buildConfigs: |
---|
77 | |
---|
78 | #-------------------------------------------------------------------- |
---|
79 | # Does build reference another project's build configuration. |
---|
80 | # If yes, then build p as specified by the reference project. |
---|
81 | #-------------------------------------------------------------------- |
---|
82 | if 'Reference' in bc : |
---|
83 | referencedConfigs = BUILDS[ bc['Reference'] ] |
---|
84 | for c in referencedConfigs : |
---|
85 | buildConfigs.append(c) |
---|
86 | continue |
---|
87 | |
---|
88 | #-------------------------------------------------------------------- |
---|
89 | # Setup subversion verion |
---|
90 | #-------------------------------------------------------------------- |
---|
91 | if 'SvnVersion' not in bc : |
---|
92 | print 'Error. BUILDS does not contain SvnVersion' |
---|
93 | print ' Project is '+p |
---|
94 | print ' BuildConfig is '+str(bc) |
---|
95 | sys.exit(1) |
---|
96 | if bc['SvnVersion']=='latestStable' : |
---|
97 | lsv=NBsvnCommand.latestStableVersion(p) |
---|
98 | if not lsv : |
---|
99 | print 'Error. BUILDS configured to use lastest stable svn version' |
---|
100 | print ' Project does not have a stable version' |
---|
101 | print ' Project is '+p |
---|
102 | print ' BuildConfig is '+str(bc) |
---|
103 | sys.exit(1) |
---|
104 | configuration['svnVersion']='stable/'+lsv |
---|
105 | elif bc['SvnVersion']=='latestRelease' : |
---|
106 | lrv=NBsvnCommand.latestReleaseVersion(p) |
---|
107 | if not lrv : |
---|
108 | print 'Error. BUILDS configured to use lastest release svn version' |
---|
109 | print ' Project does not have a release version' |
---|
110 | print ' Project is '+p |
---|
111 | print ' BuildConfig is '+str(bc) |
---|
112 | sys.exit(1) |
---|
113 | configuration['svnVersion']='releases/'+lrv |
---|
114 | else: |
---|
115 | configuration['svnVersion']=bc['SvnVersion'] |
---|
116 | |
---|
117 | #-------------------------------------------------------------------- |
---|
118 | # Setup usage of 3rd Party code |
---|
119 | #-------------------------------------------------------------------- |
---|
120 | if 'noThirdParty' in configuration: configuration.pop('noThirdParty') |
---|
121 | if 'ThirdParty' in bc: |
---|
122 | if bc['ThirdParty'].lower()=='yes' : |
---|
123 | configuration['noThirdParty']=False |
---|
124 | else: |
---|
125 | configuration['noThirdParty']=True |
---|
126 | |
---|
127 | #-------------------------------------------------------------------- |
---|
128 | # Set config options |
---|
129 | #-------------------------------------------------------------------- |
---|
130 | configuration['configOptions']={} |
---|
131 | configuration['configOptions']['unique']="" |
---|
132 | configuration['configOptions']['invariant']="" |
---|
133 | if 'OptLevel' not in bc : |
---|
134 | print 'Error. BUILDS does not contain OptLevel' |
---|
135 | print ' Project is '+p |
---|
136 | print ' BuildConfig is '+str(bc) |
---|
137 | sys.exit(1) |
---|
138 | if bc['OptLevel']=='Debug' : |
---|
139 | configuration['configOptions']['unique']+=" --enable-debug" |
---|
140 | if 'AdditionalConfigOptions' in bc : |
---|
141 | configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions'] |
---|
142 | |
---|
143 | configuration['configOptions']['invariant']+=" "+ CONFIGURE_FLAGS |
---|
144 | |
---|
145 | #-------------------------------------------------------------------- |
---|
146 | # Deal with coin projects to be skipped by ./config |
---|
147 | #-------------------------------------------------------------------- |
---|
148 | if 'SkipProjects' in configuration: configuration.pop('SkipProjects') |
---|
149 | if 'SkipProjects' in bc : |
---|
150 | configuration['SkipProjects']=bc['SkipProjects'] |
---|
151 | |
---|
152 | #--------------------------------------------------------------------- |
---|
153 | # Setup checkMakeTest |
---|
154 | #--------------------------------------------------------------------- |
---|
155 | configuration['checkMakeTest']=NBcheckResult.didTestFail |
---|
156 | |
---|
157 | |
---|
158 | #--------------------------------------------------------------------- |
---|
159 | # Set up unitTest |
---|
160 | #--------------------------------------------------------------------- |
---|
161 | configuration['unitTest']={} |
---|
162 | if NBprojectConfig.UNITTEST_CMD.has_key(p) : |
---|
163 | |
---|
164 | unitTestCmdTemplate=NBprojectConfig.UNITTEST_CMD[p] |
---|
165 | unitTestCmd=unitTestCmdTemplate.replace('_NETLIBDIR_',netlibDir) |
---|
166 | unitTestCmd=unitTestCmd.replace('_MIPLIB3DIR_',miplib3Dir) |
---|
167 | |
---|
168 | configuration['unitTest']['command']=unitTestCmd |
---|
169 | configuration['unitTest']['checkUnitTest']=NBcheckResult.didTestFail |
---|
170 | configuration['unitTest']['path']=NBprojectConfig.UNITTEST_DIR[p] |
---|
171 | |
---|
172 | else : |
---|
173 | # No unitTest so remove from configuration |
---|
174 | configuration.pop('unitTest') |
---|
175 | |
---|
176 | #-------------------------------------------------- |
---|
177 | # Build & Test the configuration |
---|
178 | #-------------------------------------------------- |
---|
179 | NBbuildConfig.run(configuration) |
---|
180 | |
---|
181 | |
---|
182 | NBlogMessages.writeMessage( "nightlyBuild.py Finished" ) |
---|
183 | |
---|
184 | sys.exit(0) |
---|
185 | |
---|