Packpanda added

This commit is contained in:
Josh Yelon 2005-08-03 21:58:04 +00:00
parent 85072b1e7d
commit d11cb8b183
2 changed files with 147 additions and 0 deletions

View File

@ -131,8 +131,10 @@ Section "${SMDIRECTORY}" SecCore
File /r /x CVS ${PANDA}\epydoc\*
SetOutPath $INSTDIR
File /r /x CVS ${PANDA}\ReleaseNotes
!ifdef PYEXTRAS
SetOutPath $INSTDIR\python\lib
File /nonfatal /r ${PYEXTRAS}\*
!endif
SetOutPath $INSTDIR\models
File /r /x CVS ${PANDA}\models\*
SetOutPath $INSTDIR\samples

View File

@ -0,0 +1,145 @@
##############################################################################
#
# packpanda - this is a tool that packages up a panda game into a
# convenient, easily-downloaded windows executable. Packpanda relies on
# NSIS, the netscape scriptable install system, to do the hard work.
#
# This is intentionally a very simplistic game-packer with very
# limited options. The goal is simplicity, not feature richness.
# There are dozens of complex, powerful packaging tools already out
# there. This one is for people who just want to do it quick and
# easy.
#
##############################################################################
import sys,os,getopt,compileall
OPTIONLIST = [
("game", 1, "Name of directory containing game"),
("version", 1, "Version number to add to game name"),
("fast", 0, "Use fast compression instead of good compression"),
("bam", 0, "Convert all EGG files to BAM"),
("pyc", 0, "Convert all PY files to PYC"),
]
def ParseFailure():
print ""
print "packpanda usage:"
print ""
for (opt, hasval, explanation) in OPTIONLIST:
if (hasval):
print " --%-10s %s"%(opt+" x",explanation)
else:
print " --%-10s %s"%(opt+" ",explanation)
sys.exit(1)
def ParseOptions(args):
try:
options = {}
longopts = []
for (opt, hasval, explanation) in OPTIONLIST:
if (hasval): longopts.append(opt+"=")
else: longopts.append(opt)
options[opt] = 0
if (hasval): options[opt]=""
opts, extras = getopt.getopt(args, "", longopts)
for option,value in opts:
for (opt, hasval, explanation) in OPTIONLIST:
if (option == "--"+opt):
if (hasval): options[opt] = value
else: options[opt] = 1
return options
except: ParseFailure();
OPTIONS = ParseOptions(sys.argv[1:])
##############################################################################
#
# Identify the main parts of the game: GAME, NAME, MAIN, ICON, IMAGE
#
##############################################################################
VER=OPTIONS["version"]
GAME=OPTIONS["game"]
if (GAME==""):
print "You must specify the --game option."
ParseFailure()
GAME=os.path.abspath(GAME)
NAME=os.path.basename(GAME)
STARTMENU=os.path.basename(GAME)
if (VER!=""): STARTMENU=STARTMENU+" "+VER
MAIN=NAME+".py"
ICON=os.path.join(GAME,NAME+".ico")
IMAGE=os.path.join(GAME,NAME+".bmp")
OUTPUT=os.path.basename(GAME)
if (VER!=""): OUTPUT=OUTPUT+"-"+VER
OUTPUT=os.path.abspath(OUTPUT+".exe")
INSTALLTO='C:\\'+os.path.basename(GAME)
if (VER!=""): INSTALLTO=INSTALLTO+"-"+VER
COMPRESS="lzma"
if (OPTIONS["fast"]): COMPRESS="zlib"
def PrintFileStatus(label, file):
if (os.path.exists(file)):
print "%-15s: %s"%(label,file)
else:
print "%-15s: %s (MISSING)"%(label,file)
PrintFileStatus("Game",GAME)
print "%-15s: %s"%("Name",NAME)
print "%-15s: %s"%("Start Menu",STARTMENU)
PrintFileStatus("Main",os.path.join(GAME,MAIN))
PrintFileStatus("Icon",ICON)
PrintFileStatus("Image",IMAGE)
print "%-15s: %s"%("Output",OUTPUT)
print "%-15s: %s"%("Install To",INSTALLTO)
if (os.path.isdir(GAME)==0):
sys.exit("Difficulty reading "+GAME+". Cannot continue.")
if (os.path.isfile(os.path.join(GAME,MAIN))==0):
sys.exit("Difficulty reading "+MAIN+". Cannot continue.")
##############################################################################
#
# Locate the relevant trees.
#
##############################################################################
PANDA=None
for dir in sys.path:
if os.path.exists(os.path.join(dir,"direct")) and os.path.exists(os.path.join(dir,"pandac")) and os.path.exists(os.path.join(dir,"python")):
PANDA=os.path.abspath(dir)
if (PANDA is None):
sys.exit("Cannot locate the panda root directory in the python path (cannot locate directory containing direct and pandac).")
if (os.path.exists(os.path.join("PANDA","..","makepanda","makepanda.py"))) and (os.path.exists(os.path.join("PANDA","..","thirdparty","win-nsis","makensis.exe"))):
PSOURCE=os.path.abspath(os.path.join(PANDA,".."))
NSIS=os.path.abspath(os.path.join(PANDA,"..","thirdparty","win-nsis"))
else:
PSOURCE=PANDA
NSIS=os.path.join(PANDA,"nsis")
##############################################################################
#
# Run NSIS. Yay!
#
##############################################################################
CMD=NSIS+"\\makensis.exe /V2 "
CMD=CMD+'/DCOMPRESSOR="'+COMPRESS+'" '
CMD=CMD+'/DFULLNAME="'+NAME+'" '
CMD=CMD+'/DSMDIRECTORY="'+STARTMENU+'" '
CMD=CMD+'/DINSTALLDIR="'+INSTALLTO+'" '
CMD=CMD+'/DPANDA="'+PANDA+'" '
CMD=CMD+'/DPSOURCE="'+PSOURCE+'" '
CMD=CMD+'/DOUTFILE="'+OUTPUT+'" '
CMD=CMD+'/DPPGAMEID="'+NAME+'" '
CMD=CMD+'/DPPGAMEPATH="'+GAME+'" '
CMD=CMD+'/DPPGAMEPY="'+MAIN+'" '
CMD=CMD+'"'+PSOURCE+'\\direct\\src\\directscripts\\packpanda.nsi"'
print ""
print CMD
print "packing..."
os.system(CMD)