| 1 |
"""Script to compile the dependencies of _tkinter |
| 2 |
|
| 3 |
Copyright (c) 2007 by Christian Heimes <[email protected]> |
| 4 |
|
| 5 |
Licensed to PSF under a Contributor Agreement. |
| 6 |
""" |
| 7 |
|
| 8 |
import os |
| 9 |
import sys |
| 10 |
|
| 11 |
here = os.path.abspath(os.path.dirname(__file__)) |
| 12 |
par = os.path.pardir |
| 13 |
|
| 14 |
if 1: |
| 15 |
TCL = "tcl8.4.16" |
| 16 |
TK = "tk8.4.16" |
| 17 |
TIX = "tix-8.4.0" |
| 18 |
else: |
| 19 |
TCL = "tcl8.5b3" |
| 20 |
TK = "tcl8.5b3" |
| 21 |
TIX = "Tix8.4.2" |
| 22 |
|
| 23 |
ROOT = os.path.abspath(os.path.join(here, par, par, par)) |
| 24 |
|
| 25 |
|
| 26 |
NMAKE = "nmake /nologo /f %s COMPILERFLAGS=-DWINVER=0x0500 %s %s" |
| 27 |
|
| 28 |
def nmake(makefile, command="", **kw): |
| 29 |
defines = ' '.join(k+'='+v for k, v in kw.items()) |
| 30 |
cmd = NMAKE % (makefile, defines, command) |
| 31 |
print("\n\n"+cmd+"\n") |
| 32 |
if os.system(cmd) != 0: |
| 33 |
raise RuntimeError(cmd) |
| 34 |
|
| 35 |
def build(platform, clean): |
| 36 |
if platform == "Win32": |
| 37 |
dest = os.path.join(ROOT, "tcltk") |
| 38 |
machine = "X86" |
| 39 |
elif platform == "x64": |
| 40 |
dest = os.path.join(ROOT, "tcltk64") |
| 41 |
machine = "X64" |
| 42 |
else: |
| 43 |
raise ValueError(platform) |
| 44 |
|
| 45 |
|
| 46 |
tcldir = os.path.join(ROOT, TCL) |
| 47 |
if 1: |
| 48 |
os.chdir(os.path.join(tcldir, "win")) |
| 49 |
if clean: |
| 50 |
nmake("makefile.vc", "clean") |
| 51 |
nmake("makefile.vc") |
| 52 |
nmake("makefile.vc", "install", INSTALLDIR=dest) |
| 53 |
|
| 54 |
|
| 55 |
if 1: |
| 56 |
os.chdir(os.path.join(ROOT, TK, "win")) |
| 57 |
if clean: |
| 58 |
nmake("makefile.vc", "clean", TCLDIR=tcldir) |
| 59 |
nmake("makefile.vc", TCLDIR=tcldir) |
| 60 |
nmake("makefile.vc", "install", TCLDIR=tcldir, INSTALLDIR=dest) |
| 61 |
|
| 62 |
|
| 63 |
if 1: |
| 64 |
|
| 65 |
os.chdir(os.path.join(ROOT, TIX, "win")) |
| 66 |
if clean: |
| 67 |
nmake("python9.mak", "clean") |
| 68 |
nmake("python9.mak", MACHINE=machine) |
| 69 |
nmake("python9.mak", "install") |
| 70 |
|
| 71 |
def main(): |
| 72 |
if len(sys.argv) < 2 or sys.argv[1] not in ("Win32", "x64"): |
| 73 |
print("%s Win32|x64" % sys.argv[0]) |
| 74 |
sys.exit(1) |
| 75 |
|
| 76 |
if "-c" in sys.argv: |
| 77 |
clean = True |
| 78 |
else: |
| 79 |
clean = False |
| 80 |
|
| 81 |
build(sys.argv[1], clean) |
| 82 |
|
| 83 |
|
| 84 |
if __name__ == '__main__': |
| 85 |
main() |