blob: d76ea264b118adf250e89854899bd71862137ea3 [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 Heimesb9eccbf2007-12-05 20:18:38 +000015TCL = "tcl8.4.16"
16TK = "tk8.4.16"
Christian Heimes60d388d2007-12-05 09:36:42 +000017TIX = "Tix8.4.0"
Christian Heimesb9eccbf2007-12-05 20:18:38 +000018#TIX = "Tix8.4.2"
Christian Heimesb0789252007-11-24 12:40:29 +000019ROOT = os.path.abspath(os.path.join(here, par, par))
20NMAKE = "nmake /nologo "
21
22def system(cmd):
23 if os.system(cmd) != 0:
24 raise RuntimeError(cmd)
25
26def build(platform, clean):
27 if platform == "Win32":
28 dest = os.path.join(ROOT, "tcltk")
29 machine = "X86"
30 elif platform == "x64":
31 dest = os.path.join(ROOT, "tcltk64")
32 machine = "X64"
33 else:
34 raise ValueError(platform)
35
36 # TCL
37 tcldir = os.path.join(ROOT, TCL)
38 if True:
39 os.chdir(os.path.join(tcldir, "win"))
40 if clean:
41 system(NMAKE + "/f makefile.vc clean")
42 system(NMAKE + "/f makefile.vc")
43 system(NMAKE + "/f makefile.vc INSTALLDIR=%s install" % dest)
44
45 # TK
46 if True:
47 os.chdir(os.path.join(ROOT, TK, "win"))
48 if clean:
49 system(NMAKE + "/f makefile.vc clean")
50 system(NMAKE + "/f makefile.vc TCLDIR=%s" % tcldir)
51 system(NMAKE + "/f makefile.vc TCLDIR=%s INSTALLDIR=%s install" %
52 (tcldir, dest))
53
54 # TIX
55 if True:
56 os.chdir(os.path.join(ROOT, TIX, "win"))
57 if clean:
Christian Heimesb9eccbf2007-12-05 20:18:38 +000058 system(NMAKE + "/f python9.mak clean")
59 system(NMAKE + "/f python9.mak MACHINE=%s" % machine)
60 system(NMAKE + "/f python9.mak install")
Christian Heimesb0789252007-11-24 12:40:29 +000061
62
63def main():
64 if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"):
65 print("%s Win32|x64" % sys.argv[0])
66 sys.exit(1)
67
68 if "-c" in sys.argv:
69 clean = True
70 else:
71 clean = False
72
73 build(sys.argv[1], clean)
74
75
76if __name__ == '__main__':
77 main()