Browse Source

fix maya location on linux, fix dependency cache problems with Python 3 that forced a full rebuild every time

rdb 12 years ago
parent
commit
b686d371ca
2 changed files with 39 additions and 34 deletions
  1. 6 6
      makepanda/makepanda.py
  2. 33 28
      makepanda/makepandacore.py

+ 6 - 6
makepanda/makepanda.py

@@ -2149,7 +2149,7 @@ def WriteConfigSettings():
         speedtree_parameters["SPEEDTREE_BIN_DIR"] = (SDK["SPEEDTREE"] + "/Bin")
 
     conf = "/* prc_parameters.h.  Generated automatically by makepanda.py */\n"
-    for key in prc_parameters.keys():
+    for key in sorted(prc_parameters.keys()):
         if ((key == "DEFAULT_PRC_DIR") or (key[:4]=="PRC_")):
             val = OverrideValue(key, prc_parameters[key])
             if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
@@ -2157,7 +2157,7 @@ def WriteConfigSettings():
     ConditionalWriteFile(GetOutputDir() + '/include/prc_parameters.h', conf)
 
     conf = "/* dtool_config.h.  Generated automatically by makepanda.py */\n"
-    for key in dtool_config.keys():
+    for key in sorted(dtool_config.keys()):
         val = OverrideValue(key, dtool_config[key])
         if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
         else:                conf = conf + "#define " + key + " " + val + "\n"
@@ -2165,7 +2165,7 @@ def WriteConfigSettings():
 
     if (RTDIST or RUNTIME):
         conf = "/* p3d_plugin_config.h.  Generated automatically by makepanda.py */\n"
-        for key in plugin_config.keys():
+        for key in sorted(plugin_config.keys()):
             val = plugin_config[key]
             if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
             else:                conf = conf + "#define " + key + " \"" + val.replace("\\", "\\\\") + "\"\n"
@@ -2173,15 +2173,15 @@ def WriteConfigSettings():
 
     if (PkgSkip("SPEEDTREE")==0):
         conf = "/* speedtree_parameters.h.  Generated automatically by makepanda.py */\n"
-        for key in speedtree_parameters.keys():
+        for key in sorted(speedtree_parameters.keys()):
             val = OverrideValue(key, speedtree_parameters[key])
             if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n"
             else:                conf = conf + "#define " + key + " \"" + val.replace("\\", "\\\\") + "\"\n"
         ConditionalWriteFile(GetOutputDir() + '/include/speedtree_parameters.h', conf)
 
     for x in PkgListGet():
-        if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"0\n")
-        else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat',"1\n")
+        if (PkgSkip(x)): ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat', "0\n")
+        else:            ConditionalWriteFile(GetOutputDir() + '/tmp/dtool_have_'+x.lower()+'.dat', "1\n")
 
 WriteConfigSettings()
 

+ 33 - 28
makepanda/makepandacore.py

@@ -627,32 +627,34 @@ def ClearTimestamp(path):
 
 BUILTFROMCACHE = {}
 
-def JustBuilt(files,others):
-    dates = []
+def JustBuilt(files, others):
+    dates = {}
     for file in files:
         del TIMESTAMPCACHE[file]
-        dates.append(GetTimestamp(file))
+        dates[file] = GetTimestamp(file)
     for file in others:
-        dates.append(GetTimestamp(file))
+        dates[file] = GetTimestamp(file)
+
     key = tuple(files)
-    BUILTFROMCACHE[key] = [others,dates]
+    BUILTFROMCACHE[key] = dates
 
-def NeedsBuild(files,others):
-    dates = []
+def NeedsBuild(files, others):
+    dates = {}
     for file in files:
-        dates.append(GetTimestamp(file))
-        if (not os.path.exists(file)): return 1
+        dates[file] = GetTimestamp(file)
+        if not os.path.exists(file):
+            return True
     for file in others:
-        dates.append(GetTimestamp(file))
+        dates[file] = GetTimestamp(file)
+
     key = tuple(files)
-    if (key in BUILTFROMCACHE):
-        if (BUILTFROMCACHE[key] == [others,dates]):
-            return 0
-        else:
-            oldothers = BUILTFROMCACHE[key][0]
-            if (oldothers != others and VERBOSE):
-                print("%sWARNING:%s file dependencies changed: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), files, GetColor()))
-    return 1
+    if key in BUILTFROMCACHE:
+        if BUILTFROMCACHE[key] == dates:
+            return False
+        if VERBOSE and frozenset(oldothers) != frozenset(others):
+            print("%sWARNING:%s file dependencies changed: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), files, GetColor()))
+
+    return True
 
 ########################################################################
 ##
@@ -721,8 +723,8 @@ def SaveDependencyCache():
     except: icache = 0
     if (icache!=0):
         print("Storing dependency cache.")
-        pickle.dump(CXXINCLUDECACHE, icache, 1)
-        pickle.dump(BUILTFROMCACHE, icache, 1)
+        pickle.dump(CXXINCLUDECACHE, icache, 2)
+        pickle.dump(BUILTFROMCACHE, icache, 2)
         icache.close()
 
 def LoadDependencyCache():
@@ -971,8 +973,10 @@ def ConditionalWriteFile(dest, desiredcontents):
         contents = rfile.read(-1)
         rfile.close()
     except:
-        contents=0
+        contents = 0
     if contents != desiredcontents:
+        if VERBOSE:
+            print("Writing %s" % (dest))
         sys.stdout.flush()
         WriteFile(dest, desiredcontents)
 
@@ -1744,7 +1748,7 @@ def SdkLocateDirectX( strMode = 'default' ):
         SDK["DIRECTCAM"] = SDK["DX9"]
 
 def SdkLocateMaya():
-    for (ver,key) in MAYAVERSIONINFO:
+    for (ver, key) in MAYAVERSIONINFO:
         if (PkgSkip(ver)==0 and ver not in SDK):
             GetSdkDir(ver.lower().replace("x",""), ver)
             if (not ver in SDK):
@@ -1759,7 +1763,7 @@ def SdkLocateMaya():
                     ddir = "/Applications/Autodesk/maya"+key
                     if (os.path.isdir(ddir)): SDK[ver] = ddir
                 else:
-                    if (GetTargetArch() == 'x64'):
+                    if (GetTargetArch() in ("x86_64", "amd64")):
                         ddir1 = "/usr/autodesk/maya"+key+"-x64"
                         ddir2 = "/usr/aw/maya"+key+"-x64"
                     else:
@@ -2544,9 +2548,9 @@ def CalcLocation(fn, ipath):
 
 def FindLocation(fn, ipath):
     if (GetLinkAllStatic() and fn.endswith(".dll")):
-        fn = fn[:-4]+".lib"
+        fn = fn[:-4] + ".lib"
     loc = CalcLocation(fn, ipath)
-    (base,ext) = os.path.splitext(fn)
+    base, ext = os.path.splitext(fn)
     ORIG_EXT[loc] = ext
     return loc
 
@@ -2597,8 +2601,8 @@ def FindLocation(fn, ipath):
 class Target:
     pass
 
-TARGET_LIST=[]
-TARGET_TABLE={}
+TARGET_LIST = []
+TARGET_TABLE = {}
 
 def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0):
     if (dummy != 0):
@@ -2607,7 +2611,7 @@ def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0):
     if (ipath == 0): ipath = []
     if (type(input) == str): input = [input]
     if (type(dep) == str): dep = [dep]
-    full = FindLocation(target,[OUTPUTDIR+"/include"])
+    full = FindLocation(target, [OUTPUTDIR + "/include"])
 
     if (full not in TARGET_TABLE):
         t = Target()
@@ -2642,6 +2646,7 @@ def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0):
         for x in dep:
             fulldep = FindLocation(x, ipath)
             t.deps[fulldep] = 1
+
     if winrc != 0 and GetTarget() == 'windows':
         TargetAdd(target, input=WriteResourceFile(target.split("/")[-1].split(".")[0], **winrc))