| 1 | |
| 2 | |
| 3 | import sys, os, string, time |
| 4 | from ftplib import FTP |
| 5 | |
| 6 | cwd = os.getcwd() |
| 7 | |
| 8 | logfile = 'c:\\temp\\autobuild.log' |
| 9 | WXDIR = os.environ['WXWIN'] |
| 10 | dllVer = '23_0' |
| 11 | wxpVer = '2.3b1' |
| 12 | dateSt = time.strftime("%Y%m%d", time.localtime(time.time())) |
| 13 | |
| 14 | base = os.path.split(sys.argv[0])[0] |
| 15 | base = os.path.join(base, '..') |
| 16 | WXPYDIR = os.path.abspath(base) |
| 17 | |
| 18 | #---------------------------------------------------------------------- |
| 19 | |
| 20 | def do(cmd): |
| 21 | st = " " + cmd + " >> " + logfile |
| 22 | print st |
| 23 | f = open(logfile, "at") |
| 24 | f.write(st + '\n') |
| 25 | f.close() |
| 26 | os.system(cmd + " >>& " + logfile) |
| 27 | |
| 28 | #---------------------------------------------------------------------- |
| 29 | |
| 30 | def logTruncate(): |
| 31 | f = open(logfile, "wt") |
| 32 | f.close() |
| 33 | |
| 34 | |
| 35 | def logSeparator(msg=None, f=None, recurse=1): |
| 36 | if not f: |
| 37 | f = open(logfile, "at") |
| 38 | f.write('\n') |
| 39 | f.write('--' * 35) |
| 40 | f.write('\n') |
| 41 | if msg: |
| 42 | f.write(msg) |
| 43 | f.write('\n') |
| 44 | f.write('--' * 35) |
| 45 | f.write('\n') |
| 46 | if recurse: |
| 47 | logSeparator(msg, sys.stdout, 0) |
| 48 | |
| 49 | #---------------------------------------------------------------------- |
| 50 | |
| 51 | def validateFile(file): |
| 52 | if not os.path.exists(file): |
| 53 | logSeparator("***** %s does not exist, exiting! *****" % file) |
| 54 | raise SystemExit |
| 55 | else: |
| 56 | logSeparator("%s found, continuing..." % file, recurse=0) |
| 57 | |
| 58 | |
| 59 | #---------------------------------------------------------------------- |
| 60 | |
| 61 | def main(): |
| 62 | logTruncate() |
| 63 | |
| 64 | try: |
| 65 | logSeparator("Cleanup") |
| 66 | os.chdir(WXDIR + '/src/msw') |
| 67 | do('make cleandll FINAL=1') |
| 68 | |
| 69 | logSeparator("Building Documentation...") |
| 70 | os.chdir(WXDIR + '/src/msw') |
| 71 | do('make touchmanual htmlhelp') |
| 72 | validateFile(WXDIR + '/docs/htmlhelp/wx.chm') |
| 73 | |
| 74 | logSeparator("Building wxWindows...") |
| 75 | os.chdir(WXDIR + '/src/msw') |
| 76 | do('make dll pch FINAL=1') |
| 77 | validateFile(WXDIR + '/lib/wx'+dllVer+'.dll') |
| 78 | |
| 79 | |
| 80 | |
| 81 | logSeparator("Cleaning wxPython build directory...") |
| 82 | os.chdir(WXPYDIR) |
| 83 | do('b.bat c') |
| 84 | |
| 85 | logSeparator("Building wxPython...") |
| 86 | os.chdir(WXPYDIR + '\\src') |
| 87 | do("b.bat f") |
| 88 | validateFile(WXPYDIR+'\\wxPython\\wxc.pyd') |
| 89 | |
| 90 | |
| 91 | logSeparator("Building installer executable...") |
| 92 | os.chdir(WXPYDIR+'\\distrib') |
| 93 | do("autoit2 wise.aut") |
| 94 | srcName = WXPYDIR+'\\distrib\\wxPython-'+wxpVer+'.EXE' |
| 95 | destName = WXPYDIR+'\\distrib\\wxPython-'+wxpVer+'-'+dateSt+'.EXE' |
| 96 | validateFile(srcName) |
| 97 | try: |
| 98 | time.sleep(5) |
| 99 | os.rename(srcName, destName) |
| 100 | validateFile(destName) |
| 101 | except: |
| 102 | logSeparator("****** UNABLE TO RENAME FILE ******") |
| 103 | |
| 104 | |
| 105 | logSeparator("Building docs zip file...") |
| 106 | os.chdir(WXPYDIR) |
| 107 | do("distrib\\zipit.bat %s" % wxpVer) |
| 108 | |
| 109 | srcDName = WXPYDIR+'\\distrib\\wxPython-docs-'+wxpVer+'.tar.gz' |
| 110 | destDName = WXPYDIR+'\\distrib\\wxPython-docs-'+wxpVer+'-'+dateSt+'.tar.gz' |
| 111 | validateFile(srcDName) |
| 112 | try: |
| 113 | os.rename(srcDName, destDName) |
| 114 | except: |
| 115 | pass |
| 116 | |
| 117 | |
| 118 | |
| 119 | # #*#*#*#*#* Comment this out to allow upload... |
| 120 | #return |
| 121 | |
| 122 | logSeparator("Uploading to website...") |
| 123 | do('python c:\\utils\\sendwxp.py %s' % destName) |
| 124 | #do('python c:\\utils\\sendwxp.py %s' % destDName) |
| 125 | |
| 126 | |
| 127 | logSeparator("Finished!!!") |
| 128 | |
| 129 | finally: |
| 130 | os.system("list " + logfile) |
| 131 | pass |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | if __name__ == '__main__': |
| 139 | main() |