blob: 574d76808611f4a305c0a840848d25d32c682d88 [file] [log] [blame]
Christian Heimes8b011402007-11-27 21:28:40 +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 Heimes8affb5f2007-12-18 03:38:03 +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 Heimes8b011402007-11-27 21:28:40 +000023
Christian Heimes8affb5f2007-12-18 03:38:03 +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
Christian Heimes3001c542008-01-05 21:35:52 +000027NMAKE = ('nmake /nologo /f %s '
Thomas Hellerd17315f2008-01-11 08:04:03 +000028 'COMPILERFLAGS=\"-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=NTDDI_WIN2KSP4\" '
Christian Heimes3001c542008-01-05 21:35:52 +000029 '%s %s')
Christian Heimes8affb5f2007-12-18 03:38:03 +000030
31def nmake(makefile, command="", **kw):
32 defines = ' '.join(k+'='+v for k, v in kw.items())
33 cmd = NMAKE % (makefile, defines, command)
34 print("\n\n"+cmd+"\n")
Christian Heimes8b011402007-11-27 21:28:40 +000035 if os.system(cmd) != 0:
36 raise RuntimeError(cmd)
37
38def build(platform, clean):
39 if platform == "Win32":
40 dest = os.path.join(ROOT, "tcltk")
41 machine = "X86"
42 elif platform == "x64":
43 dest = os.path.join(ROOT, "tcltk64")
44 machine = "X64"
45 else:
46 raise ValueError(platform)
47
48 # TCL
49 tcldir = os.path.join(ROOT, TCL)
Christian Heimes8affb5f2007-12-18 03:38:03 +000050 if 1:
Christian Heimes8b011402007-11-27 21:28:40 +000051 os.chdir(os.path.join(tcldir, "win"))
52 if clean:
Christian Heimes8affb5f2007-12-18 03:38:03 +000053 nmake("makefile.vc", "clean")
54 nmake("makefile.vc")
55 nmake("makefile.vc", "install", INSTALLDIR=dest)
Christian Heimes8b011402007-11-27 21:28:40 +000056
57 # TK
Christian Heimes8affb5f2007-12-18 03:38:03 +000058 if 1:
Christian Heimes8b011402007-11-27 21:28:40 +000059 os.chdir(os.path.join(ROOT, TK, "win"))
60 if clean:
Christian Heimes8affb5f2007-12-18 03:38:03 +000061 nmake("makefile.vc", "clean", TCLDIR=tcldir)
62 nmake("makefile.vc", TCLDIR=tcldir)
63 nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest)
Christian Heimes8b011402007-11-27 21:28:40 +000064
65 # TIX
Christian Heimes8affb5f2007-12-18 03:38:03 +000066 if 1:
Christian Heimes3d2f5642007-12-06 21:13:06 +000067 # python9.mak is available at http://svn.python.org
Christian Heimes8b011402007-11-27 21:28:40 +000068 os.chdir(os.path.join(ROOT, TIX, "win"))
69 if clean:
Christian Heimes8affb5f2007-12-18 03:38:03 +000070 nmake("python9.mak", "clean")
71 nmake("python9.mak", MACHINE=machine)
72 nmake("python9.mak", "install")
Christian Heimes8b011402007-11-27 21:28:40 +000073
74def main():
75 if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"):
76 print("%s Win32|x64" % sys.argv[0])
77 sys.exit(1)
78
79 if "-c" in sys.argv:
80 clean = True
81 else:
82 clean = False
83
84 build(sys.argv[1], clean)
85
86
87if __name__ == '__main__':
88 main()