From adf9b0538108a562f3a7179f52dd7114a0c30711 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 22 Dec 2013 10:12:19 +0000 Subject: [PATCH] include version number in dependency cache (sorry for forcing a full rebuild onto y'all) --- makepanda/makepandacore.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 911e3036d7..78d9b2250c 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -709,6 +709,7 @@ def CxxGetIncludes(path): ## ######################################################################## +DCACHE_VERSION = 2 DCACHE_BACKED_UP = False def SaveDependencyCache(): @@ -720,10 +721,15 @@ def SaveDependencyCache(): os.path.join(OUTPUTDIR, "tmp", "makepanda-dcache-backup")) except: pass DCACHE_BACKED_UP = True - try: icache = open(os.path.join(OUTPUTDIR, "tmp", "makepanda-dcache"),'wb') - except: icache = 0 - if (icache!=0): + + try: + icache = open(os.path.join(OUTPUTDIR, "tmp", "makepanda-dcache"),'wb') + except: + icache = None + + if icache is not None: print("Storing dependency cache.") + pickle.dump(DCACHE_VERSION, icache, 0) pickle.dump(CXXINCLUDECACHE, icache, 2) pickle.dump(BUILTFROMCACHE, icache, 2) icache.close() @@ -731,12 +737,20 @@ def SaveDependencyCache(): def LoadDependencyCache(): global CXXINCLUDECACHE global BUILTFROMCACHE - try: icache = open(os.path.join(OUTPUTDIR, "tmp", "makepanda-dcache"),'rb') - except: icache = 0 - if (icache!=0): - CXXINCLUDECACHE = pickle.load(icache) - BUILTFROMCACHE = pickle.load(icache) - icache.close() + + try: + icache = open(os.path.join(OUTPUTDIR, "tmp", "makepanda-dcache"), 'rb') + except: + icache = None + + if icache is not None: + ver = pickle.load(icache) + if ver == DCACHE_VERSION: + CXXINCLUDECACHE = pickle.load(icache) + BUILTFROMCACHE = pickle.load(icache) + icache.close() + else: + print("Cannot load dependency cache, version is too old!") ######################################################################## ##