mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Improved the egg-cacher
This commit is contained in:
parent
e20cf31373
commit
ccef375974
@ -24,7 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BUILDING_EGGCACHER
|
#ifdef BUILDING_EGGCACHER
|
||||||
#define LINK_SOURCE "\\bin\\loadalleggs.exe"
|
#define LINK_SOURCE "\\bin\\eggcacher.exe"
|
||||||
#define LINK_TARGET "\\python\\python.exe"
|
#define LINK_TARGET "\\python\\python.exe"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,18 +2,51 @@
|
|||||||
#
|
#
|
||||||
# eggcacher
|
# eggcacher
|
||||||
#
|
#
|
||||||
# this tool searches a directory for egg files, and loads
|
# EggCacher searches a directory for egg files, and loads
|
||||||
# them all into the model-cache.
|
# them all into the model-cache. This is used as part of the
|
||||||
|
# panda installation process.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os,sys
|
import os,sys
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
|
|
||||||
MODELCACHE = ConfigVariableFilename("model-cache-dir", Filename()).getValue()
|
class EggCacher:
|
||||||
|
def __init__(self):
|
||||||
|
if (len(sys.argv) != 2):
|
||||||
|
print "Usage: eggcacher <file-or-directory>"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
self.bamcache = BamCache.getGlobalPtr()
|
||||||
|
self.pandaloader = PandaLoader()
|
||||||
|
self.loaderopts = LoaderOptions()
|
||||||
|
if (self.bamcache.getActive() == 0):
|
||||||
|
print "The model cache is not currently active."
|
||||||
|
print "You must set a model-cache-dir in your config file."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def traversePath(self, path):
|
||||||
|
if (os.path.exists(path)==0):
|
||||||
|
print "No such file or directory: "+path
|
||||||
|
return
|
||||||
|
if (os.path.isdir(path)):
|
||||||
|
for f in os.listdir(path):
|
||||||
|
self.traversePath(os.path.join(path,f))
|
||||||
|
return
|
||||||
|
if (path.endswith(".egg")) or (path.endswith(".egg.pz")):
|
||||||
|
fn = Filename.fromOsSpecific(path)
|
||||||
|
cached = self.bamcache.lookup(fn,"bam")
|
||||||
|
if (cached == None):
|
||||||
|
print "Not cacheable: "+path
|
||||||
|
elif (cached.hasData()):
|
||||||
|
print "Already Cached: "+path
|
||||||
|
else:
|
||||||
|
print "Caching "+path
|
||||||
|
self.pandaloader.loadSync(fn, self.loaderopts)
|
||||||
|
ModelPool.releaseAllModels()
|
||||||
|
|
||||||
|
cacher = EggCacher()
|
||||||
|
for x in sys.argv[1:]:
|
||||||
|
cacher.traversePath(os.path.abspath(x))
|
||||||
|
|
||||||
if (MODELCACHE.getValue().isEmpty()==0):
|
|
||||||
print "The config variable 'model-cache-dir' is not set."
|
|
||||||
print "You cannot cache egg files until you configure a cache dir."
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ Section "${SMDIRECTORY}" SecCore
|
|||||||
SetOutPath $INSTDIR\models\audio
|
SetOutPath $INSTDIR\models\audio
|
||||||
File /r /x CVS "${PANDA}\models\audio\*"
|
File /r /x CVS "${PANDA}\models\audio\*"
|
||||||
SetOutPath $INSTDIR\bin
|
SetOutPath $INSTDIR\bin
|
||||||
File /r "${PANDA}\bin\pzip.exe"
|
File /r "${PANDA}\bin\eggcacher.exe"
|
||||||
SetOutpath $INSTDIR\game
|
SetOutpath $INSTDIR\game
|
||||||
File /r "${PPGAME}\*"
|
File /r "${PPGAME}\*"
|
||||||
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" "$INSTDIR\python\ppython.exe" "${PPMAIN}" "$INSTDIR\${PPICON}" 0 SW_SHOWMINIMIZED "" "Play ${NAME}"
|
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" "$INSTDIR\python\ppython.exe" "${PPMAIN}" "$INSTDIR\${PPICON}" 0 SW_SHOWMINIMIZED "" "Play ${NAME}"
|
||||||
@ -151,10 +151,10 @@ Section "${SMDIRECTORY}" SecCore
|
|||||||
WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"
|
WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"
|
||||||
WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/wiki/index.php"
|
WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/wiki/index.php"
|
||||||
SetOutPath $INSTDIR\samples\GreetingCard
|
SetOutPath $INSTDIR\samples\GreetingCard
|
||||||
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Greeting Card.lnk" "$INSTDIR\python\ppython.exe" 'GreetingCard.py "$SMPROGRAMS\${SMDIRECTORY}"' "$INSTDIR\bin\pzip.exe" 0 SW_SHOWMINIMIZED "" "Panda Greeting Card"
|
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Greeting Card.lnk" "$INSTDIR\python\ppython.exe" 'GreetingCard.py "$SMPROGRAMS\${SMDIRECTORY}"' "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Panda Greeting Card"
|
||||||
SetOutPath $INSTDIR
|
SetOutPath $INSTDIR
|
||||||
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\pzip.exe" 0 "" "" "Panda Manual"
|
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Manual"
|
||||||
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\pzip.exe" 0 "" "" "Panda Website"
|
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Website"
|
||||||
|
|
||||||
FindFirst $0 $1 $INSTDIR\samples\*--*
|
FindFirst $0 $1 $INSTDIR\samples\*--*
|
||||||
loop:
|
loop:
|
||||||
@ -182,8 +182,8 @@ Section "${SMDIRECTORY}" SecCore
|
|||||||
Call StrRep
|
Call StrRep
|
||||||
Pop $R0
|
Pop $R0
|
||||||
StrCpy $TUTNAME $R0
|
StrCpy $TUTNAME $R0
|
||||||
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\$READABLE\Run $TUTNAME.lnk" "$INSTDIR\python\ppython.exe" "$3" "$INSTDIR\bin\pzip.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
|
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\$READABLE\Run $TUTNAME.lnk" "$INSTDIR\python\ppython.exe" "$3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
|
||||||
CreateShortCut "$INSTDIR\samples\$1\Run $TUTNAME.lnk" "$INSTDIR\python\ppython.exe" "$3" "$INSTDIR\bin\pzip.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
|
CreateShortCut "$INSTDIR\samples\$1\Run $TUTNAME.lnk" "$INSTDIR\python\ppython.exe" "$3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
|
||||||
FindNext $2 $3
|
FindNext $2 $3
|
||||||
goto iloop
|
goto iloop
|
||||||
idone:
|
idone:
|
||||||
@ -201,8 +201,9 @@ Section -post
|
|||||||
|
|
||||||
!ifndef PPGAME
|
!ifndef PPGAME
|
||||||
|
|
||||||
# Install the visual studio runtime system.
|
# Preload all EGG files into the model-cache
|
||||||
# ExecWait '"$INSTDIR\bin\vcredist_x86.exe" /Q:a /C:"msiexec.exe /qn /i vcredist.msi"'
|
ExecWait '"$INSTDIR\bin\eggcacher.exe" samples models"
|
||||||
|
|
||||||
# Add the "bin" directory to the PATH.
|
# Add the "bin" directory to the PATH.
|
||||||
Push "$INSTDIR\python"
|
Push "$INSTDIR\python"
|
||||||
Call RemoveFromPath
|
Call RemoveFromPath
|
||||||
|
@ -68,6 +68,8 @@ audio-library-name p3fmod_audio
|
|||||||
|
|
||||||
hardware-animated-vertices 0
|
hardware-animated-vertices 0
|
||||||
|
|
||||||
# Enable the bam-cache
|
# Enable the model-cache, but only for models, not textures.
|
||||||
|
|
||||||
model-cache-dir $THIS_PRC_DIR/../modelcache
|
model-cache-dir $THIS_PRC_DIR/../modelcache
|
||||||
|
model-cache-textures #f
|
||||||
|
|
||||||
|
@ -3150,6 +3150,8 @@ if (OMIT.count("PYTHON")==0):
|
|||||||
EnqueueLink(opts=['WINUSER'], dll='genpycode.exe', obj=['genpycode.obj'])
|
EnqueueLink(opts=['WINUSER'], dll='genpycode.exe', obj=['genpycode.obj'])
|
||||||
EnqueueCxx(ipath=IPATH, opts=['BUILDING_PACKPANDA'], src='ppython.cxx', obj='packpanda.obj')
|
EnqueueCxx(ipath=IPATH, opts=['BUILDING_PACKPANDA'], src='ppython.cxx', obj='packpanda.obj')
|
||||||
EnqueueLink(opts=['WINUSER'], dll='packpanda.exe', obj=['packpanda.obj'])
|
EnqueueLink(opts=['WINUSER'], dll='packpanda.exe', obj=['packpanda.obj'])
|
||||||
|
EnqueueCxx(ipath=IPATH, opts=['BUILDING_EGGCACHER'], src='ppython.cxx', obj='eggcacher.obj')
|
||||||
|
EnqueueLink(opts=['WINUSER'], dll='eggcacher.exe', obj=['eggcacher.obj'])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -70,6 +70,8 @@ PUBLISHED:
|
|||||||
INLINE static void list_contents();
|
INLINE static void list_contents();
|
||||||
static void write(ostream &out);
|
static void write(ostream &out);
|
||||||
|
|
||||||
|
static ModelPool *get_ptr();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
INLINE ModelPool();
|
INLINE ModelPool();
|
||||||
|
|
||||||
@ -86,8 +88,6 @@ private:
|
|||||||
int ns_garbage_collect();
|
int ns_garbage_collect();
|
||||||
void ns_list_contents(ostream &out) const;
|
void ns_list_contents(ostream &out) const;
|
||||||
|
|
||||||
static ModelPool *get_ptr();
|
|
||||||
|
|
||||||
static ModelPool *_global_ptr;
|
static ModelPool *_global_ptr;
|
||||||
|
|
||||||
Mutex _lock;
|
Mutex _lock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user