1 import os 2 import sys 3 import subprocess 4 5 TCL_MAJOR = 8 6 TCL_MINOR = 5 7 TCL_PATCH = 2 8 9 TIX_MAJOR = 8 10 TIX_MINOR = 4 11 TIX_PATCH = 3 12 13 def abspath(name): 14 par = os.path.pardir 15 return os.path.abspath(os.path.join(__file__, par, par, par, par, name)) 16 17 TCL_DIR = abspath("tcl%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) 18 TK_DIR = abspath("tk%d.%d.%d" % (TCL_MAJOR, TCL_MINOR, TCL_PATCH)) 19 TIX_DIR = abspath("tix%d.%d.%d" % (TIX_MAJOR, TIX_MINOR, TIX_PATCH)) 20 OUT_DIR = abspath("tcltk") 21 22 def have_args(*a): 23 return any(s in sys.argv[1:] for s in a) 24 25 def enter(dir): 26 os.chdir(os.path.join(dir, "win")) 27 28 def main(): 29 debug = have_args("-d", "--debug") 30 clean = have_args("clean") 31 install = have_args("install") 32 tcl = have_args("tcl") 33 tk = have_args("tk") 34 tix = have_args("tix") 35 if not(tcl) and not(tk) and not(tix): 36 tcl = tk = tix = True 37 38 def nmake(makefile, *a): 39 args = ["nmake", "/nologo", "/f", makefile, "DEBUG=%d" % debug] 40 args.extend(a) 41 subprocess.check_call(args) 42 43 if tcl: 44 enter(TCL_DIR) 45 def nmake_tcl(*a): 46 nmake("makefile.vc", *a) 47 if clean: 48 nmake_tcl("clean") 49 elif install: 50 nmake_tcl("install", "INSTALLDIR=" + OUT_DIR) 51 else: 52 nmake_tcl() 53 54 if tk: 55 enter(TK_DIR) 56 def nmake_tk(*a): 57 nmake("makefile.vc", "TCLDIR=" + TCL_DIR, *a) 58 if clean: 59 nmake_tk("clean") 60 elif install: 61 nmake_tk("install", "INSTALLDIR=" + OUT_DIR) 62 else: 63 nmake_tk() 64 65 if tix: 66 enter(TIX_DIR) 67 def nmake_tix(*a): 68 nmake("python.mak", 69 "TCL_MAJOR=%d" % TCL_MAJOR, 70 "TCL_MINOR=%d" % TCL_MINOR, 71 "TCL_PATCH=%d" % TCL_PATCH, 72 "MACHINE=IX86", *a) 73 if clean: 74 nmake_tix("clean") 75 elif install: 76 nmake_tix("install", "INSTALL_DIR=" + OUT_DIR) 77 else: 78 nmake_tix() 79 80 if __name__ == '__main__': 81 main() 82