blob: c807e7b19cf6c0783786bbde1465cdab0e052f71 [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
Christian Heimesb0789252007-11-24 12:40:29 +000010
11here = os.path.abspath(os.path.dirname(__file__))
12par = os.path.pardir
13
Martin v. Löwis8d0d3692013-11-23 23:05:27 +010014TCL = "tcl8.6.1"
15TK = "tk8.6.1"
16TIX = "tix-8.4.3.3"
Christian Heimesb0789252007-11-24 12:40:29 +000017
Christian Heimes99170a52007-12-19 02:07:34 +000018ROOT = os.path.abspath(os.path.join(here, par, par))
Martin v. Löwis3f50bf62013-01-25 14:06:18 +010019NMAKE = ('nmake /nologo /f %s %s %s')
Christian Heimes99170a52007-12-19 02:07:34 +000020
21def nmake(makefile, command="", **kw):
Martin v. Löwis9f59fa52010-08-28 13:06:43 +000022 defines = ' '.join(k+'='+str(v) for k, v in kw.items())
Christian Heimes99170a52007-12-19 02:07:34 +000023 cmd = NMAKE % (makefile, defines, command)
24 print("\n\n"+cmd+"\n")
Christian Heimesb0789252007-11-24 12:40:29 +000025 if os.system(cmd) != 0:
26 raise RuntimeError(cmd)
27
28def build(platform, clean):
29 if platform == "Win32":
30 dest = os.path.join(ROOT, "tcltk")
Martin v. Löwisc11eba82012-05-31 21:53:36 +020031 machine = "IX86"
Martin v. Löwisf38e0d02008-06-13 14:11:59 +000032 elif platform == "AMD64":
Christian Heimesb0789252007-11-24 12:40:29 +000033 dest = os.path.join(ROOT, "tcltk64")
Martin v. Löwisf38e0d02008-06-13 14:11:59 +000034 machine = "AMD64"
Christian Heimesb0789252007-11-24 12:40:29 +000035 else:
36 raise ValueError(platform)
37
38 # TCL
39 tcldir = os.path.join(ROOT, TCL)
Christian Heimes99170a52007-12-19 02:07:34 +000040 if 1:
Christian Heimesb0789252007-11-24 12:40:29 +000041 os.chdir(os.path.join(tcldir, "win"))
42 if clean:
Christian Heimes99170a52007-12-19 02:07:34 +000043 nmake("makefile.vc", "clean")
Martin v. Löwisf38e0d02008-06-13 14:11:59 +000044 nmake("makefile.vc", MACHINE=machine)
45 nmake("makefile.vc", "install", INSTALLDIR=dest, MACHINE=machine)
Christian Heimesb0789252007-11-24 12:40:29 +000046
47 # TK
Christian Heimes99170a52007-12-19 02:07:34 +000048 if 1:
Christian Heimesb0789252007-11-24 12:40:29 +000049 os.chdir(os.path.join(ROOT, TK, "win"))
50 if clean:
Benjamin Peterson247a9b82009-02-20 04:09:19 +000051 nmake("makefile.vc", "clean", DEBUG=0, TCLDIR=tcldir)
Martin v. Löwis9f59fa52010-08-28 13:06:43 +000052 nmake("makefile.vc", DEBUG=0, MACHINE=machine, TCLDIR=tcldir)
53 nmake("makefile.vc", "install", DEBUG=0, INSTALLDIR=dest, MACHINE=machine, TCLDIR=tcldir)
Christian Heimesb0789252007-11-24 12:40:29 +000054
55 # TIX
Christian Heimes99170a52007-12-19 02:07:34 +000056 if 1:
Christian Heimes255f53b2007-12-08 15:33:56 +000057 # python9.mak is available at http://svn.python.org
Christian Heimesb0789252007-11-24 12:40:29 +000058 os.chdir(os.path.join(ROOT, TIX, "win"))
59 if clean:
Benjamin Peterson247a9b82009-02-20 04:09:19 +000060 nmake("python.mak", "clean")
61 nmake("python.mak", MACHINE=machine, INSTALL_DIR=dest)
Martin v. Löwis9f59fa52010-08-28 13:06:43 +000062 nmake("python.mak", "install", MACHINE=machine, INSTALL_DIR=dest)
Christian Heimesb0789252007-11-24 12:40:29 +000063
64def main():
Martin v. Löwisf38e0d02008-06-13 14:11:59 +000065 if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "AMD64"):
66 print("%s Win32|AMD64" % sys.argv[0])
Christian Heimesb0789252007-11-24 12:40:29 +000067 sys.exit(1)
68
69 if "-c" in sys.argv:
70 clean = True
71 else:
72 clean = False
73
74 build(sys.argv[1], clean)
75
76
77if __name__ == '__main__':
78 main()