| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 1 | """Script to compile the dependencies of _tkinter | 
 | 2 |  | 
 | 3 | Copyright (c) 2007 by Christian Heimes <christian@cheimes.de> | 
 | 4 |  | 
 | 5 | Licensed to PSF under a Contributor Agreement. | 
 | 6 | """ | 
 | 7 |  | 
 | 8 | import os | 
 | 9 | import sys | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 10 |  | 
 | 11 | here = os.path.abspath(os.path.dirname(__file__)) | 
 | 12 | par = os.path.pardir | 
 | 13 |  | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 14 | if 1: | 
 | 15 |     TCL = "tcl8.4.16" | 
 | 16 |     TK = "tk8.4.16" | 
 | 17 |     TIX = "tix-8.4.0" | 
 | 18 | else: | 
 | 19 |     TCL = "tcl8.5b3" | 
 | 20 |     TK = "tcl8.5b3" | 
 | 21 |     TIX = "Tix8.4.2" | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 22 |  | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 23 | ROOT = os.path.abspath(os.path.join(here, par, par)) | 
 | 24 | # Windows 2000 compatibility: WINVER 0x0500 | 
 | 25 | # http://msdn2.microsoft.com/en-us/library/aa383745.aspx | 
| Christian Heimes | faf2f63 | 2008-01-06 16:59:19 +0000 | [diff] [blame] | 26 | NMAKE = ('nmake /nologo /f %s ' | 
| Christian Heimes | 25bb783 | 2008-01-11 16:17:00 +0000 | [diff] [blame] | 27 |     'COMPILERFLAGS=\"-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=NTDDI_WIN2KSP4\" ' | 
| Christian Heimes | faf2f63 | 2008-01-06 16:59:19 +0000 | [diff] [blame] | 28 |     '%s %s') | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 29 |  | 
 | 30 | def nmake(makefile, command="", **kw): | 
 | 31 |     defines = ' '.join(k+'='+v for k, v in kw.items()) | 
 | 32 |     cmd = NMAKE % (makefile, defines, command) | 
 | 33 |     print("\n\n"+cmd+"\n") | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 34 |     if os.system(cmd) != 0: | 
 | 35 |         raise RuntimeError(cmd) | 
 | 36 |  | 
 | 37 | def build(platform, clean): | 
 | 38 |     if platform == "Win32": | 
 | 39 |         dest = os.path.join(ROOT, "tcltk") | 
 | 40 |         machine = "X86" | 
 | 41 |     elif platform == "x64": | 
 | 42 |         dest = os.path.join(ROOT, "tcltk64") | 
 | 43 |         machine = "X64" | 
 | 44 |     else: | 
 | 45 |         raise ValueError(platform) | 
 | 46 |  | 
 | 47 |     # TCL | 
 | 48 |     tcldir = os.path.join(ROOT, TCL) | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 49 |     if 1: | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 50 |         os.chdir(os.path.join(tcldir, "win")) | 
 | 51 |         if clean: | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 52 |             nmake("makefile.vc", "clean") | 
 | 53 |         nmake("makefile.vc") | 
 | 54 |         nmake("makefile.vc", "install", INSTALLDIR=dest) | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 55 |  | 
 | 56 |     # TK | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 57 |     if 1: | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 58 |         os.chdir(os.path.join(ROOT, TK, "win")) | 
 | 59 |         if clean: | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 60 |             nmake("makefile.vc", "clean", TCLDIR=tcldir) | 
 | 61 |         nmake("makefile.vc", TCLDIR=tcldir) | 
 | 62 |         nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest) | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 63 |  | 
 | 64 |     # TIX | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 65 |     if 1: | 
| Christian Heimes | 255f53b | 2007-12-08 15:33:56 +0000 | [diff] [blame] | 66 |         # python9.mak is available at http://svn.python.org | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 67 |         os.chdir(os.path.join(ROOT, TIX, "win")) | 
 | 68 |         if clean: | 
| Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 69 |             nmake("python9.mak", "clean") | 
 | 70 |         nmake("python9.mak", MACHINE=machine) | 
 | 71 |         nmake("python9.mak", "install") | 
| Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 72 |  | 
 | 73 | def main(): | 
 | 74 |     if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"): | 
 | 75 |         print("%s Win32|x64" % sys.argv[0]) | 
 | 76 |         sys.exit(1) | 
 | 77 |  | 
 | 78 |     if "-c" in sys.argv: | 
 | 79 |         clean = True | 
 | 80 |     else: | 
 | 81 |         clean = False | 
 | 82 |  | 
 | 83 |     build(sys.argv[1], clean) | 
 | 84 |  | 
 | 85 |  | 
 | 86 | if __name__ == '__main__': | 
 | 87 |     main() |