mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
make genPyCode work on Linux and non-ctattach platforms
This commit is contained in:
parent
de2502a7b0
commit
029f99a1cc
@ -694,6 +694,12 @@ class FFIInterrogateDatabase:
|
|||||||
|
|
||||||
|
|
||||||
def generateCode(self, codeDir, extensionsDir):
|
def generateCode(self, codeDir, extensionsDir):
|
||||||
|
# Empty out the codeDir of unnecessary crud from previous runs
|
||||||
|
# before we begin.
|
||||||
|
for file in os.listdir(codeDir):
|
||||||
|
pathname = os.path.join(codeDir, file)
|
||||||
|
os.unlink(pathname)
|
||||||
|
|
||||||
# Import all the C++ modules
|
# Import all the C++ modules
|
||||||
for CModuleName in FFIConstants.CodeModuleNameList:
|
for CModuleName in FFIConstants.CodeModuleNameList:
|
||||||
self.generateCodeLib(codeDir, extensionsDir, CModuleName)
|
self.generateCodeLib(codeDir, extensionsDir, CModuleName)
|
||||||
|
@ -330,17 +330,28 @@ exec "import %(start)s"
|
|||||||
# create bootstrap code
|
# create bootstrap code
|
||||||
|
|
||||||
fp = open(bootstrap, "w")
|
fp = open(bootstrap, "w")
|
||||||
# Note: Jesse Schell changed the following line to be very
|
# Note: David Rose adjusted the following to be more general.
|
||||||
# panda specific
|
|
||||||
fp.write("""\
|
fp.write("""\
|
||||||
#%(localMagic)s %(archiveid)s
|
#%(localMagic)s %(archiveid)s
|
||||||
import ihooks,zlib,marshal,os
|
import ihooks,zlib,marshal,os,sys
|
||||||
try:
|
|
||||||
directroot = os.environ["DIRECT"]
|
def searchPath(filename):
|
||||||
except KeyError:
|
# Look along the python load path for the indicated filename.
|
||||||
print "Warning: environment variable DIRECT is not set."
|
# Returns the located pathname, or None if the filename is not
|
||||||
directroot = ""
|
# found.
|
||||||
archivePath = directroot + "\\lib\\py\\%(archive)s"
|
for dir in sys.path:
|
||||||
|
pathname = os.path.join(dir, filename)
|
||||||
|
if os.path.exists(pathname):
|
||||||
|
return pathname
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Look for %(archive)s along the sys.path.
|
||||||
|
archiveName = "%(archive)s"
|
||||||
|
archivePath = searchPath(archiveName)
|
||||||
|
if archivePath == None:
|
||||||
|
raise ImportError, "Could not locate %%s on PYTHONPATH." %% (archiveName)
|
||||||
|
|
||||||
f=open(archivePath,"rb")
|
f=open(archivePath,"rb")
|
||||||
exec marshal.loads(%(zbegin)sf.read(%(loaderlen)d)%(zend)s)
|
exec marshal.loads(%(zbegin)sf.read(%(loaderlen)d)%(zend)s)
|
||||||
boot("%(app)s",f,%(size)d)
|
boot("%(app)s",f,%(size)d)
|
||||||
|
@ -3,7 +3,7 @@ import sys
|
|||||||
import getopt
|
import getopt
|
||||||
import pandaSqueezeTool
|
import pandaSqueezeTool
|
||||||
|
|
||||||
# Assumption: We will be squeezing the files from C:\Panda\lib\py
|
# Assumption: We will be squeezing the files from the current directory.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, pargs = getopt.getopt(sys.argv[1:], 'O')
|
opts, pargs = getopt.getopt(sys.argv[1:], 'O')
|
||||||
@ -22,8 +22,7 @@ for opt in opts:
|
|||||||
print 'Squeezing pyo files'
|
print 'Squeezing pyo files'
|
||||||
|
|
||||||
def getSqueezeableFiles():
|
def getSqueezeableFiles():
|
||||||
directDir = os.getenv('DIRECT')
|
fileList = os.listdir(".")
|
||||||
fileList = os.listdir(directDir + "\lib\py")
|
|
||||||
newFileList = []
|
newFileList = []
|
||||||
if fOptimized:
|
if fOptimized:
|
||||||
targetFileExtension = ".pyo"
|
targetFileExtension = ".pyo"
|
||||||
@ -32,12 +31,15 @@ def getSqueezeableFiles():
|
|||||||
for i in fileList:
|
for i in fileList:
|
||||||
base,ext = os.path.splitext(i)
|
base,ext = os.path.splitext(i)
|
||||||
if (ext == ".py"):
|
if (ext == ".py"):
|
||||||
j = directDir + "/lib/py/" + i
|
newFileList.append(i)
|
||||||
newFileList.append(j)
|
|
||||||
return newFileList
|
return newFileList
|
||||||
|
|
||||||
def squeezePandaFiles():
|
def squeezePandaFiles():
|
||||||
l = getSqueezeableFiles()
|
l = getSqueezeableFiles()
|
||||||
pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l)
|
pandaSqueezeTool.squeeze("PandaModules", "PandaModulesUnsqueezed", l)
|
||||||
|
|
||||||
|
# Clean up the source files now that they've been squeezed.
|
||||||
|
for i in l:
|
||||||
|
os.unlink(i)
|
||||||
|
|
||||||
squeezePandaFiles()
|
squeezePandaFiles()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user