diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 48fd5210d3..d7ec85c213 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -34,7 +34,6 @@ THIRDPARTYLIBS=0 VC90CRTVERSION="" INSTALLER=0 GENMAN=0 -VERBOSE=1 COMPRESSOR="zlib" THREADCOUNT=0 CFLAGS="" @@ -97,9 +96,9 @@ def usage(problem): def parseopts(args): global INSTALLER,RUNTIME,GENMAN,RUNTIME_DISTRIBUTOR - global VERSION,COMPRESSOR,VERBOSE,THREADCOUNT + global VERSION,COMPRESSOR,VERBOSE,THREADCOUNT,VERBOSE longopts = [ - "help","distributor=", + "help","distributor=","verbose", "optimize=","everything","nothing","installer","runtime", "version=","lzma","no-python","threads=","outputdir="] anything = 0 @@ -112,6 +111,7 @@ def parseopts(args): if (option=="--help"): raise "usage" elif (option=="--optimize"): optimize=value elif (option=="--installer"): INSTALLER=1 + elif (option=="--verbose"): SetVerbose(True) elif (option=="--distributor"): RUNTIME_DISTRIBUTOR=value elif (option=="--runtime"): RUNTIME=1 elif (option=="--genman"): GENMAN=1 @@ -525,7 +525,7 @@ IncDirectory("ALWAYS", GetOutputDir()+"/include") def printStatus(header,warnings): global VERBOSE - if VERBOSE >= -2: + if VERBOSE: print "" print "-------------------------------------------------------------------" print header @@ -538,7 +538,6 @@ def printStatus(header,warnings): print "Makepanda: Optimize:",GetOptimize() print "Makepanda: Keep Pkg:",tkeep print "Makepanda: Omit Pkg:",tomit - print "Makepanda: Verbose vs. Quiet Level:",VERBOSE if (GENMAN): print "Makepanda: Generate API reference manual" else : print "Makepanda: Don't generate API reference manual" if (sys.platform == "win32"): @@ -978,7 +977,7 @@ def CompileBundle(target, inputs, opts): # ########################################################################################## -def CompileAnything(target, inputs, opts): +def CompileAnything(target, inputs, opts, progress = None): if (opts.count("DEPENDENCYONLY")): return if (len(inputs)==0): @@ -986,31 +985,56 @@ def CompileAnything(target, inputs, opts): infile = inputs[0] origsuffix = GetOrigExt(target) if (target == "pandac/PandaModules.py"): + ProgressOutput(progress, "Generating 'pandac' tree") return RunGenPyCode(target, inputs, opts) elif (infile.endswith(".py")): + if (origsuffix==".exe"): + ProgressOutput(progress, "Building frozen executable", target) + else: + ProgressOutput(progress, "Building frozen library", target) return FreezePy(target, inputs, opts) elif SUFFIX_LIB.count(origsuffix): + ProgressOutput(progress, "Linking static library", target) return CompileLib(target, inputs, opts) elif SUFFIX_DLL.count(origsuffix): + if (origsuffix==".exe"): + ProgressOutput(progress, "Linking executable", target) + else: + ProgressOutput(progress, "Linking dynamic library", target) return CompileLink(target, inputs, opts) elif (origsuffix==".in"): + ProgressOutput(progress, "Building Interrogate database", target) return CompileIgate(target, inputs, opts) elif (origsuffix==".plugin"): + ProgressOutput(progress, "Building plugin bundle", target) return CompileBundle(target, inputs, opts) elif (origsuffix==".pz"): + ProgressOutput(progress, "Compressing", target) return CompileEggPZ(target, infile, opts) elif (origsuffix in [".res", ".rsrc"]): + ProgressOutput(progress, "Building resource object", target) return CompileResource(target, infile, opts) elif (origsuffix==".obj"): - if (infile.endswith(".cxx") or infile.endswith(".c") or infile.endswith(".mm")): + if (infile.endswith(".cxx")): + ProgressOutput(progress, "Building C++ object", target) + return CompileCxx(target, infile, opts) + elif (infile.endswith(".c")): + ProgressOutput(progress, "Building C object", target) + return CompileCxx(target, infile, opts) + elif (infile.endswith(".mm")): + ProgressOutput(progress, "Building Objective-C++ object", target) return CompileCxx(target, infile, opts) elif (infile.endswith(".yxx")): + ProgressOutput(progress, "Building Bison object", target) return CompileBison(target, infile, opts) elif (infile.endswith(".lxx")): + ProgressOutput(progress, "Building Flex object", target) return CompileFlex(target, infile, opts) elif (infile.endswith(".in")): + ProgressOutput(progress, "Building Interrogate object", target) return CompileImod(target, inputs, opts) elif (infile.endswith(".rc") or infile.endswith(".r")): + ProgressOutput(progress, "Building resource object", target) return CompileResource(target, infile, opts) exit("Don't know how to compile: "+target) @@ -4100,10 +4124,12 @@ def ParallelMake(tasklist): def SequentialMake(tasklist): + i = 0 for task in tasklist: if (NeedsBuild(task[2], task[3])): - apply(task[0], task[1]) + apply(task[0], task[1] + [(i * 100.0) / len(tasklist)]) JustBuilt(task[2], task[3]) + i += 1 def RunDependencyQueue(tasklist): if (THREADCOUNT!=0): @@ -4187,7 +4213,7 @@ Priority: optional Architecture: ARCH Essential: no Depends: PYTHONV -Recommends: python-profiler (>= PV) +Recommends: panda3d-runtime, python-profiler (>= PV) Provides: panda3d Maintainer: etc-panda3d@lists.andrew.cmu.edu Description: The Panda3D free 3D engine @@ -4366,6 +4392,7 @@ def MakeInstallerOSX(): oscmd("rm -rf Panda3D-tpl-rw") if (INSTALLER != 0): + ProgressOutput(100.0, "Building installer") if (sys.platform.startswith("win")): dbg = "" if (GetOptimize() <= 2): dbg = "-dbg" diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 02c7d4720c..2cab134d95 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -20,6 +20,7 @@ MAINTHREAD=threading.currentThread() OUTPUTDIR="built" CUSTOM_OUTPUTDIR=False OPTIMIZE="3" +VERBOSE=False ######################################################################## ## @@ -73,6 +74,31 @@ for (ver,key1,key2,subdir) in MAXVERSIONINFO: ######################################################################## WARNINGS=[] +THREADS={} +HAVE_COLORS=False +try: + import curses + curses.setupterm() + HAVE_COLORS=sys.stdout.isatty() +except: pass + +def GetColor(color = None): + if not HAVE_COLORS: return "" + if color != None: color = color.lower() + if (color == "blue"): + return curses.tparm(curses.tigetstr("setf"), 1) + elif (color == "green"): + return curses.tparm(curses.tigetstr("setf"), 2) + elif (color == "cyan"): + return curses.tparm(curses.tigetstr("setf"), 3) + elif (color == "red"): + return curses.tparm(curses.tigetstr("setf"), 4) + elif (color == "magenta"): + return curses.tparm(curses.tigetstr("setf"), 5) + elif (color == "yellow"): + return curses.tparm(curses.tigetstr("setf"), 6) + else: + return curses.tparm(curses.tigetstr("sgr0")) def PrettyTime(t): t = int(t) @@ -85,6 +111,25 @@ def PrettyTime(t): if (minutes): return str(minutes)+" min "+str(seconds)+" sec" return str(seconds)+" sec" +def ProgressOutput(progress, msg, target = None): + if (threading.currentThread() == MAINTHREAD): + if (progress == None): + print msg + elif (progress >= 100.0): + print "%s[%s%d%%%s] %s" % (GetColor("yellow"), GetColor("cyan"), progress, GetColor("yellow"), msg), + else: + print "%s[%s %d%%%s] %s" % (GetColor("yellow"), GetColor("cyan"), progress, GetColor("yellow"), msg), + else: + global THREADS + ident = threading.currentThread().ident + if (ident not in THREADS): + THREADS[ident] = len(THREADS) + 1 + print "%s[%sT%d%s] %s" % (GetColor("yellow"), GetColor("cyan"), THREADS[ident], GetColor("yellow"), msg), + if (target == None): + print GetColor() + else: + print "%s%s%s" % (GetColor("green"), target, GetColor()) + def exit(msg = ""): if (threading.currentThread() == MAINTHREAD): SaveDependencyCache() @@ -115,7 +160,8 @@ def exit(msg = ""): ######################################################################## def oscmd(cmd, ignoreError = False): - print cmd + if VERBOSE: + print GetColor("blue") + cmd.split(" ", 1)[0] + " " + GetColor("magenta") + cmd.split(" ", 1)[1] + GetColor() sys.stdout.flush() if sys.platform == "win32": exe = cmd.split()[0] @@ -174,13 +220,13 @@ def GetDirectoryContents(dir, filters="*", skip=[]): if (skip.count(file)==0): cvs[file] = 1 for file in actual.keys(): - if (file not in cvs): - msg = "WARNING: %s is in %s, but not in CVS"%(file, dir) + if (file not in cvs and VERBOSE): + msg = "%sWARNING: %s is in %s, but not in CVS%s" % (GetColor("red"), GetColor("green") + file + GetColor(), GetColor("green") + dir + GetColor(), GetColor()) print msg WARNINGS.append(msg) for file in cvs.keys(): - if (file not in actual): - msg = "WARNING: %s is not in %s, but is in CVS"%(file, dir) + if (file not in actual and VERBOSE): + msg = "%sWARNING: %s is not in %s, but is in CVS%s" % (GetColor("red"), GetColor("green") + file + GetColor(), GetColor("green") + dir + GetColor(), GetColor()) print msg WARNINGS.append(msg) results = actual.keys() @@ -269,8 +315,8 @@ def NeedsBuild(files,others): return 0 else: oldothers = BUILTFROMCACHE[key][0] - if (oldothers != others): - print "CAUTION: file dependencies changed: "+str(files) + if (oldothers != others and VERBOSE): + print "%sCAUTION:%s file dependencies changed: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), str(files), GetColor()) return 1 ######################################################################## @@ -639,6 +685,7 @@ def SetVC90CRTVersion(fn, ver): ## ## Gets or sets the output directory, by default "built". ## Gets or sets the optimize level. +## Gets or sets the verbose flag. ## ######################################################################## @@ -657,6 +704,10 @@ def SetOptimize(optimize): global OPTIMIZE OPTIMIZE=optimize +def SetVerbose(verbose): + global VERBOSE + VERBOSE=verbose + ######################################################################## ## ## Package Selection