blob: dada3865f9e5088c6c7d44fa7a4b10812ba39ab6 [file] [log] [blame]
Christian Heimesb0789252007-11-24 12:40:29 +00001"""Script to compile the dependencies of _tkinter
2
3Copyright (c) 2007 by Christian Heimes <christian@cheimes.de>
4
5Licensed to PSF under a Contributor Agreement.
6"""
7
8import os
9import sys
10import shutil
11
12here = os.path.abspath(os.path.dirname(__file__))
13par = os.path.pardir
14
Christian Heimes99170a52007-12-19 02:07:34 +000015if 1:
16 TCL = "tcl8.4.16"
17 TK = "tk8.4.16"
18 TIX = "tix-8.4.0"
19else:
20 TCL = "tcl8.5b3"
21 TK = "tcl8.5b3"
22 TIX = "Tix8.4.2"
Christian Heimesb0789252007-11-24 12:40:29 +000023
Christian Heimes99170a52007-12-19 02:07:34 +000024ROOT = os.path.abspath(os.path.join(here, par, par))
25# Windows 2000 compatibility: WINVER 0x0500
26# http://msdn2.microsoft.com/en-us/library/aa383745.aspx
27NMAKE = "nmake /nologo /f %s COMPILERFLAGS=-DWINVER=0x0500 %s %s"
28
29def nmake(makefile, command="", **kw):
30 defines = ' '.join(k+'='+v for k, v in kw.items())
31 cmd = NMAKE % (makefile, defines, command)
32 print("\n\n"+cmd+"\n")
Christian Heimesb0789252007-11-24 12:40:29 +000033 if os.system(cmd) != 0:
34 raise RuntimeError(cmd)
35
36def build(platform, clean):
37 if platform == "Win32":
38 dest = os.path.join(ROOT, "tcltk")
39 machine = "X86"
40 elif platform == "x64":
41 dest = os.path.join(ROOT, "tcltk64")
42 machine = "X64"
43 else:
44 raise ValueError(platform)
45
46 # TCL
47 tcldir = os.path.join(ROOT, TCL)
Christian Heimes99170a52007-12-19 02:07:34 +000048 if 1:
Christian Heimesb0789252007-11-24 12:40:29 +000049 os.chdir(os.path.join(tcldir, "win"))
50 if clean:
Christian Heimes99170a52007-12-19 02:07:34 +000051 nmake("makefile.vc", "clean")
52 nmake("makefile.vc")
53 nmake("makefile.vc", "install", INSTALLDIR=dest)
Christian Heimesb0789252007-11-24 12:40:29 +000054
55 # TK
Christian Heimes99170a52007-12-19 02:07:34 +000056 if 1:
Christian Heimesb0789252007-11-24 12:40:29 +000057 os.chdir(os.path.join(ROOT, TK, "win"))
58 if clean:
Christian Heimes99170a52007-12-19 02:07:34 +000059 nmake("makefile.vc", "clean", TCLDIR=tcldir)
60 nmake("makefile.vc", TCLDIR=tcldir)
61 nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest)
Christian Heimesb0789252007-11-24 12:40:29 +000062
63 # TIX
Christian Heimes99170a52007-12-19 02:07:34 +000064 if 1:
Christian Heimes255f53b2007-12-08 15:33:56 +000065 # python9.mak is available at http://svn.python.org
Christian Heimesb0789252007-11-24 12:40:29 +000066 os.chdir(os.path.join(ROOT, TIX, "win"))
67 if clean:
Christian Heimes99170a52007-12-19 02:07:34 +000068 nmake("python9.mak", "clean")
69 nmake("python9.mak", MACHINE=machine)
70 nmake("python9.mak", "install")
Christian Heimesb0789252007-11-24 12:40:29 +000071
72def main():
73 if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"):
74 print("%s Win32|x64" % sys.argv[0])
75 sys.exit(1)
76
77 if "-c" in sys.argv:
78 clean = True
79 else:
80 clean = False
81
82 build(sys.argv[1], clean)
83
84
85if __name__ == '__main__':
86 main()