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 | |
Martin v. Löwis | 8d0d369 | 2013-11-23 23:05:27 +0100 | [diff] [blame] | 14 | TCL = "tcl8.6.1" |
| 15 | TK = "tk8.6.1" |
| 16 | TIX = "tix-8.4.3.3" |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 17 | |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 18 | ROOT = os.path.abspath(os.path.join(here, par, par)) |
Martin v. Löwis | 3f50bf6 | 2013-01-25 14:06:18 +0100 | [diff] [blame] | 19 | NMAKE = ('nmake /nologo /f %s %s %s') |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 20 | |
| 21 | def nmake(makefile, command="", **kw): |
Martin v. Löwis | 9f59fa5 | 2010-08-28 13:06:43 +0000 | [diff] [blame] | 22 | defines = ' '.join(k+'='+str(v) for k, v in kw.items()) |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 23 | cmd = NMAKE % (makefile, defines, command) |
| 24 | print("\n\n"+cmd+"\n") |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 25 | if os.system(cmd) != 0: |
| 26 | raise RuntimeError(cmd) |
| 27 | |
| 28 | def build(platform, clean): |
| 29 | if platform == "Win32": |
| 30 | dest = os.path.join(ROOT, "tcltk") |
Martin v. Löwis | c11eba8 | 2012-05-31 21:53:36 +0200 | [diff] [blame] | 31 | machine = "IX86" |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 32 | elif platform == "AMD64": |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 33 | dest = os.path.join(ROOT, "tcltk64") |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 34 | machine = "AMD64" |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 35 | else: |
| 36 | raise ValueError(platform) |
| 37 | |
| 38 | # TCL |
| 39 | tcldir = os.path.join(ROOT, TCL) |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 40 | if 1: |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 41 | os.chdir(os.path.join(tcldir, "win")) |
| 42 | if clean: |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 43 | nmake("makefile.vc", "clean") |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 44 | nmake("makefile.vc", MACHINE=machine) |
| 45 | nmake("makefile.vc", "install", INSTALLDIR=dest, MACHINE=machine) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 46 | |
| 47 | # TK |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 48 | if 1: |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 49 | os.chdir(os.path.join(ROOT, TK, "win")) |
| 50 | if clean: |
Benjamin Peterson | 247a9b8 | 2009-02-20 04:09:19 +0000 | [diff] [blame] | 51 | nmake("makefile.vc", "clean", DEBUG=0, TCLDIR=tcldir) |
Martin v. Löwis | 9f59fa5 | 2010-08-28 13:06:43 +0000 | [diff] [blame] | 52 | nmake("makefile.vc", DEBUG=0, MACHINE=machine, TCLDIR=tcldir) |
| 53 | nmake("makefile.vc", "install", DEBUG=0, INSTALLDIR=dest, MACHINE=machine, TCLDIR=tcldir) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 54 | |
| 55 | # TIX |
Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 56 | if 1: |
Christian Heimes | 255f53b | 2007-12-08 15:33:56 +0000 | [diff] [blame] | 57 | # python9.mak is available at http://svn.python.org |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 58 | os.chdir(os.path.join(ROOT, TIX, "win")) |
| 59 | if clean: |
Benjamin Peterson | 247a9b8 | 2009-02-20 04:09:19 +0000 | [diff] [blame] | 60 | nmake("python.mak", "clean") |
| 61 | nmake("python.mak", MACHINE=machine, INSTALL_DIR=dest) |
Martin v. Löwis | 9f59fa5 | 2010-08-28 13:06:43 +0000 | [diff] [blame] | 62 | nmake("python.mak", "install", MACHINE=machine, INSTALL_DIR=dest) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 63 | |
| 64 | def main(): |
Martin v. Löwis | f38e0d0 | 2008-06-13 14:11:59 +0000 | [diff] [blame] | 65 | if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "AMD64"): |
| 66 | print("%s Win32|AMD64" % sys.argv[0]) |
Christian Heimes | b078925 | 2007-11-24 12:40:29 +0000 | [diff] [blame] | 67 | 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 | |
| 77 | if __name__ == '__main__': |
| 78 | main() |