소스 검색

CMake-ish output coloring

rdb 16 년 전
부모
커밋
9542e67c7b
2개의 변경된 파일94개의 추가작업 그리고 16개의 파일을 삭제
  1. 36 9
      makepanda/makepanda.py
  2. 58 7
      makepanda/makepandacore.py

+ 36 - 9
makepanda/makepanda.py

@@ -34,7 +34,6 @@ THIRDPARTYLIBS=0
 VC90CRTVERSION=""
 VC90CRTVERSION=""
 INSTALLER=0
 INSTALLER=0
 GENMAN=0
 GENMAN=0
-VERBOSE=1
 COMPRESSOR="zlib"
 COMPRESSOR="zlib"
 THREADCOUNT=0
 THREADCOUNT=0
 CFLAGS=""
 CFLAGS=""
@@ -97,9 +96,9 @@ def usage(problem):
 
 
 def parseopts(args):
 def parseopts(args):
     global INSTALLER,RUNTIME,GENMAN,RUNTIME_DISTRIBUTOR
     global INSTALLER,RUNTIME,GENMAN,RUNTIME_DISTRIBUTOR
-    global VERSION,COMPRESSOR,VERBOSE,THREADCOUNT
+    global VERSION,COMPRESSOR,VERBOSE,THREADCOUNT,VERBOSE
     longopts = [
     longopts = [
-        "help","distributor=",
+        "help","distributor=","verbose",
         "optimize=","everything","nothing","installer","runtime",
         "optimize=","everything","nothing","installer","runtime",
         "version=","lzma","no-python","threads=","outputdir="]
         "version=","lzma","no-python","threads=","outputdir="]
     anything = 0
     anything = 0
@@ -112,6 +111,7 @@ def parseopts(args):
             if (option=="--help"): raise "usage"
             if (option=="--help"): raise "usage"
             elif (option=="--optimize"): optimize=value
             elif (option=="--optimize"): optimize=value
             elif (option=="--installer"): INSTALLER=1
             elif (option=="--installer"): INSTALLER=1
+            elif (option=="--verbose"): SetVerbose(True)
             elif (option=="--distributor"): RUNTIME_DISTRIBUTOR=value
             elif (option=="--distributor"): RUNTIME_DISTRIBUTOR=value
             elif (option=="--runtime"): RUNTIME=1
             elif (option=="--runtime"): RUNTIME=1
             elif (option=="--genman"): GENMAN=1
             elif (option=="--genman"): GENMAN=1
@@ -525,7 +525,7 @@ IncDirectory("ALWAYS", GetOutputDir()+"/include")
 
 
 def printStatus(header,warnings):
 def printStatus(header,warnings):
     global VERBOSE
     global VERBOSE
-    if VERBOSE >= -2:
+    if VERBOSE:
         print ""
         print ""
         print "-------------------------------------------------------------------"
         print "-------------------------------------------------------------------"
         print header
         print header
@@ -538,7 +538,6 @@ def printStatus(header,warnings):
         print "Makepanda: Optimize:",GetOptimize()
         print "Makepanda: Optimize:",GetOptimize()
         print "Makepanda: Keep Pkg:",tkeep
         print "Makepanda: Keep Pkg:",tkeep
         print "Makepanda: Omit Pkg:",tomit
         print "Makepanda: Omit Pkg:",tomit
-        print "Makepanda: Verbose vs. Quiet Level:",VERBOSE
         if (GENMAN): print "Makepanda: Generate API reference manual"
         if (GENMAN): print "Makepanda: Generate API reference manual"
         else       : print "Makepanda: Don't generate API reference manual"
         else       : print "Makepanda: Don't generate API reference manual"
         if (sys.platform == "win32"):
         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")):
     if (opts.count("DEPENDENCYONLY")):
         return
         return
     if (len(inputs)==0):
     if (len(inputs)==0):
@@ -986,31 +985,56 @@ def CompileAnything(target, inputs, opts):
     infile = inputs[0]
     infile = inputs[0]
     origsuffix = GetOrigExt(target)
     origsuffix = GetOrigExt(target)
     if (target == "pandac/PandaModules.py"):
     if (target == "pandac/PandaModules.py"):
+        ProgressOutput(progress, "Generating 'pandac' tree")
         return RunGenPyCode(target, inputs, opts)
         return RunGenPyCode(target, inputs, opts)
     elif (infile.endswith(".py")):
     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)
         return FreezePy(target, inputs, opts)
     elif SUFFIX_LIB.count(origsuffix):
     elif SUFFIX_LIB.count(origsuffix):
+        ProgressOutput(progress, "Linking static library", target)
         return CompileLib(target, inputs, opts)
         return CompileLib(target, inputs, opts)
     elif SUFFIX_DLL.count(origsuffix):
     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)
         return CompileLink(target, inputs, opts)
     elif (origsuffix==".in"):
     elif (origsuffix==".in"):
+        ProgressOutput(progress, "Building Interrogate database", target)
         return CompileIgate(target, inputs, opts)
         return CompileIgate(target, inputs, opts)
     elif (origsuffix==".plugin"):
     elif (origsuffix==".plugin"):
+        ProgressOutput(progress, "Building plugin bundle", target)
         return CompileBundle(target, inputs, opts)
         return CompileBundle(target, inputs, opts)
     elif (origsuffix==".pz"):
     elif (origsuffix==".pz"):
+        ProgressOutput(progress, "Compressing", target)
         return CompileEggPZ(target, infile, opts)
         return CompileEggPZ(target, infile, opts)
     elif (origsuffix in [".res", ".rsrc"]):
     elif (origsuffix in [".res", ".rsrc"]):
+        ProgressOutput(progress, "Building resource object", target)
         return CompileResource(target, infile, opts)
         return CompileResource(target, infile, opts)
     elif (origsuffix==".obj"):
     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)
             return CompileCxx(target, infile, opts)
         elif (infile.endswith(".yxx")):
         elif (infile.endswith(".yxx")):
+            ProgressOutput(progress, "Building Bison object", target)
             return CompileBison(target, infile, opts)
             return CompileBison(target, infile, opts)
         elif (infile.endswith(".lxx")):
         elif (infile.endswith(".lxx")):
+            ProgressOutput(progress, "Building Flex object", target)
             return CompileFlex(target, infile, opts)
             return CompileFlex(target, infile, opts)
         elif (infile.endswith(".in")):
         elif (infile.endswith(".in")):
+            ProgressOutput(progress, "Building Interrogate object", target)
             return CompileImod(target, inputs, opts)
             return CompileImod(target, inputs, opts)
         elif (infile.endswith(".rc") or infile.endswith(".r")):
         elif (infile.endswith(".rc") or infile.endswith(".r")):
+            ProgressOutput(progress, "Building resource object", target)
             return CompileResource(target, infile, opts)
             return CompileResource(target, infile, opts)
     exit("Don't know how to compile: "+target)
     exit("Don't know how to compile: "+target)
 
 
@@ -4100,10 +4124,12 @@ def ParallelMake(tasklist):
 
 
 
 
 def SequentialMake(tasklist):
 def SequentialMake(tasklist):
+    i = 0
     for task in tasklist:
     for task in tasklist:
         if (NeedsBuild(task[2], task[3])):
         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])
             JustBuilt(task[2], task[3])
+        i += 1
 
 
 def RunDependencyQueue(tasklist):
 def RunDependencyQueue(tasklist):
     if (THREADCOUNT!=0):
     if (THREADCOUNT!=0):
@@ -4187,7 +4213,7 @@ Priority: optional
 Architecture: ARCH
 Architecture: ARCH
 Essential: no
 Essential: no
 Depends: PYTHONV
 Depends: PYTHONV
-Recommends: python-profiler (>= PV)
+Recommends: panda3d-runtime, python-profiler (>= PV)
 Provides: panda3d
 Provides: panda3d
 Maintainer: [email protected]
 Maintainer: [email protected]
 Description: The Panda3D free 3D engine
 Description: The Panda3D free 3D engine
@@ -4366,6 +4392,7 @@ def MakeInstallerOSX():
     oscmd("rm -rf Panda3D-tpl-rw")
     oscmd("rm -rf Panda3D-tpl-rw")
 
 
 if (INSTALLER != 0):
 if (INSTALLER != 0):
+    ProgressOutput(100.0, "Building installer")
     if (sys.platform.startswith("win")):
     if (sys.platform.startswith("win")):
         dbg = ""
         dbg = ""
         if (GetOptimize() <= 2): dbg = "-dbg"
         if (GetOptimize() <= 2): dbg = "-dbg"

+ 58 - 7
makepanda/makepandacore.py

@@ -20,6 +20,7 @@ MAINTHREAD=threading.currentThread()
 OUTPUTDIR="built"
 OUTPUTDIR="built"
 CUSTOM_OUTPUTDIR=False
 CUSTOM_OUTPUTDIR=False
 OPTIMIZE="3"
 OPTIMIZE="3"
+VERBOSE=False
 
 
 ########################################################################
 ########################################################################
 ##
 ##
@@ -73,6 +74,31 @@ for (ver,key1,key2,subdir) in MAXVERSIONINFO:
 ########################################################################
 ########################################################################
 
 
 WARNINGS=[]
 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):
 def PrettyTime(t):
     t = int(t)
     t = int(t)
@@ -85,6 +111,25 @@ def PrettyTime(t):
     if (minutes): return str(minutes)+" min "+str(seconds)+" sec"
     if (minutes): return str(minutes)+" min "+str(seconds)+" sec"
     return 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 = ""):
 def exit(msg = ""):
     if (threading.currentThread() == MAINTHREAD):
     if (threading.currentThread() == MAINTHREAD):
         SaveDependencyCache()
         SaveDependencyCache()
@@ -115,7 +160,8 @@ def exit(msg = ""):
 ########################################################################
 ########################################################################
 
 
 def oscmd(cmd, ignoreError = False):
 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()
     sys.stdout.flush()
     if sys.platform == "win32":
     if sys.platform == "win32":
         exe = cmd.split()[0]
         exe = cmd.split()[0]
@@ -174,13 +220,13 @@ def GetDirectoryContents(dir, filters="*", skip=[]):
                 if (skip.count(file)==0):
                 if (skip.count(file)==0):
                     cvs[file] = 1
                     cvs[file] = 1
         for file in actual.keys():
         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
                 print msg
                 WARNINGS.append(msg)
                 WARNINGS.append(msg)
         for file in cvs.keys():
         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
                 print msg
                 WARNINGS.append(msg)
                 WARNINGS.append(msg)
     results = actual.keys()
     results = actual.keys()
@@ -269,8 +315,8 @@ def NeedsBuild(files,others):
             return 0
             return 0
         else:
         else:
             oldothers = BUILTFROMCACHE[key][0]
             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
     return 1
 
 
 ########################################################################
 ########################################################################
@@ -639,6 +685,7 @@ def SetVC90CRTVersion(fn, ver):
 ##
 ##
 ## Gets or sets the output directory, by default "built".
 ## Gets or sets the output directory, by default "built".
 ## Gets or sets the optimize level.
 ## Gets or sets the optimize level.
+## Gets or sets the verbose flag.
 ##
 ##
 ########################################################################
 ########################################################################
 
 
@@ -657,6 +704,10 @@ def SetOptimize(optimize):
   global OPTIMIZE
   global OPTIMIZE
   OPTIMIZE=optimize
   OPTIMIZE=optimize
 
 
+def SetVerbose(verbose):
+  global VERBOSE
+  VERBOSE=verbose
+
 ########################################################################
 ########################################################################
 ##
 ##
 ## Package Selection
 ## Package Selection