mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
integrate genPyCodeNative with genPyCode
This commit is contained in:
parent
e451e12df4
commit
ae031f102a
@ -773,10 +773,10 @@ class Actor(PandaObject, NodePath):
|
|||||||
# Store a dictionary of jointName : node to list the controls
|
# Store a dictionary of jointName : node to list the controls
|
||||||
# requested for joints. The controls will actually be applied
|
# requested for joints. The controls will actually be applied
|
||||||
# later, when we load up the animations in bindAnim().
|
# later, when we load up the animations in bindAnim().
|
||||||
if self.__controlJoints.has_key(bundle):
|
if self.__controlJoints.has_key(bundle.this):
|
||||||
self.__controlJoints[bundle][jointName] = node
|
self.__controlJoints[bundle.this][jointName] = node
|
||||||
else:
|
else:
|
||||||
self.__controlJoints[bundle] = { jointName : node }
|
self.__controlJoints[bundle.this] = { jointName : node }
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@ -1361,7 +1361,7 @@ class Actor(PandaObject, NodePath):
|
|||||||
|
|
||||||
# Are there any controls requested for joints in this bundle?
|
# Are there any controls requested for joints in this bundle?
|
||||||
# If so, apply them.
|
# If so, apply them.
|
||||||
controlDict = self.__controlJoints.get(bundle, None)
|
controlDict = self.__controlJoints.get(bundle.this, None)
|
||||||
if controlDict:
|
if controlDict:
|
||||||
for jointName, node in controlDict.items():
|
for jointName, node in controlDict.items():
|
||||||
if node:
|
if node:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from extension_native_helpers import *
|
from extension_native_helpers import *
|
||||||
from libdirect import *
|
from libpandaegg import *
|
||||||
####################################################################
|
####################################################################
|
||||||
#Dtool_funcToMethod(func, class)
|
#Dtool_funcToMethod(func, class)
|
||||||
#del func
|
#del func
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from extension_native_helpers import *
|
from extension_native_helpers import *
|
||||||
from libdirect import *
|
from libpandaegg import *
|
||||||
####################################################################
|
####################################################################
|
||||||
#Dtool_funcToMethod(func, class)
|
#Dtool_funcToMethod(func, class)
|
||||||
#del func
|
#del func
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from extension_native_helpers import *
|
from extension_native_helpers import *
|
||||||
from libdirect import *
|
from libpanda import *
|
||||||
####################################################################
|
####################################################################
|
||||||
#Dtool_funcToMethod(func, class)
|
#Dtool_funcToMethod(func, class)
|
||||||
#del func
|
#del func
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
from libpandaexpressModules import *
|
|
||||||
from libpandaModules import *
|
|
||||||
from libpandaphysicsModules import *
|
|
||||||
from libdirectModules import *
|
|
||||||
from libpandafxModules import *
|
|
||||||
from libpandaeggModules import *
|
|
||||||
from libotpModules import *
|
|
||||||
from libtoontownModules import *
|
|
||||||
from libpiratesModules import *
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
from PandaModules import *
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
from libdirect import *
|
|
||||||
|
|
||||||
from direct.extensions_native import CInterval_extensions
|
|
@ -1,5 +0,0 @@
|
|||||||
try:
|
|
||||||
from libotp import *
|
|
||||||
except ImportError , e:
|
|
||||||
print " ** Warning * Failed to load -->", e
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
from libpanda import *
|
|
||||||
|
|
||||||
## import pathing files..
|
|
||||||
from direct.extensions_native import NodePathCollection_extensions
|
|
||||||
from direct.extensions_native import NodePath_extensions
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
from libpandaegg import *
|
|
@ -1,4 +0,0 @@
|
|||||||
from libpandaexpress import *
|
|
||||||
|
|
||||||
from direct.extensions_native import HTTPChannel_extensions
|
|
||||||
#from direct.extensions_native import ConfigVariableDouble_extensions
|
|
@ -1 +0,0 @@
|
|||||||
from libpandafx import *
|
|
@ -1 +0,0 @@
|
|||||||
from libpandaphysics import *
|
|
@ -1,4 +0,0 @@
|
|||||||
try:
|
|
||||||
from libpirates import *
|
|
||||||
except ImportError , e:
|
|
||||||
print " ** Warning * Failed to load -->", e
|
|
@ -1,5 +0,0 @@
|
|||||||
try:
|
|
||||||
from libtoontown import *
|
|
||||||
except ImportError , e:
|
|
||||||
print " ** Warning * Failed to load -->", e
|
|
||||||
|
|
@ -6,6 +6,7 @@ import getopt
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import types
|
||||||
from direct.ffi import FFIConstants
|
from direct.ffi import FFIConstants
|
||||||
|
|
||||||
# Define a help string for the user
|
# Define a help string for the user
|
||||||
@ -56,6 +57,7 @@ etcPath = []
|
|||||||
doSqueeze = True
|
doSqueeze = True
|
||||||
deleteSourceAfterSqueeze = True
|
deleteSourceAfterSqueeze = True
|
||||||
generateManual = False
|
generateManual = False
|
||||||
|
native = False # This is set by genPyCode.py
|
||||||
|
|
||||||
def doGetopts():
|
def doGetopts():
|
||||||
global outputDir
|
global outputDir
|
||||||
@ -80,7 +82,7 @@ def doGetopts():
|
|||||||
|
|
||||||
# Extract the args the user passed in
|
# Extract the args the user passed in
|
||||||
try:
|
try:
|
||||||
opts, pargs = getopt.getopt(sys.argv[1:], 'hvOd:x:i:e:rnsgtpom')
|
opts, pargs = getopt.getopt(sys.argv[1:], 'hvOd:x:Ni:e:rnsgtpom')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# User passed in a bad option, print the error and the help, then exit
|
# User passed in a bad option, print the error and the help, then exit
|
||||||
print e
|
print e
|
||||||
@ -184,6 +186,55 @@ def doErrorCheck():
|
|||||||
FFIConstants.notify.debug('Generating code for: ' + `codeLibs`)
|
FFIConstants.notify.debug('Generating code for: ' + `codeLibs`)
|
||||||
FFIConstants.CodeModuleNameList = codeLibs
|
FFIConstants.CodeModuleNameList = codeLibs
|
||||||
|
|
||||||
|
def generateNativeWrappers():
|
||||||
|
# Empty out the codeDir of unnecessary crud from previous runs
|
||||||
|
# before we begin.
|
||||||
|
for file in os.listdir(outputDir):
|
||||||
|
pathname = os.path.join(outputDir, file)
|
||||||
|
if not os.path.isdir(pathname):
|
||||||
|
os.unlink(pathname)
|
||||||
|
|
||||||
|
# Generate __init__.py
|
||||||
|
initFilename = os.path.join(outputDir, '__init__.py')
|
||||||
|
init = open(initFilename, 'w')
|
||||||
|
|
||||||
|
# Generate PandaModules.py
|
||||||
|
pandaModulesFilename = os.path.join(outputDir, 'PandaModules.py')
|
||||||
|
pandaModules = open(pandaModulesFilename, 'w')
|
||||||
|
|
||||||
|
# Copy in any helper classes from the extensions_native directory
|
||||||
|
extensionHelperFiles = [ 'extension_native_helpers.py' ]
|
||||||
|
for name in extensionHelperFiles:
|
||||||
|
inFilename = os.path.join(extensionsDir, name)
|
||||||
|
outFilename = os.path.join(outputDir, name)
|
||||||
|
if os.path.exists(inFilename):
|
||||||
|
inFile = open(inFilename, 'r')
|
||||||
|
outFile = open(outFilename, 'w')
|
||||||
|
outFile.write(inFile.read())
|
||||||
|
|
||||||
|
# Generate a series of "libpandaModules.py" etc. files, one for
|
||||||
|
# each named module.
|
||||||
|
for moduleName in FFIConstants.CodeModuleNameList:
|
||||||
|
print 'Importing code library: ' + moduleName
|
||||||
|
exec('import %s as module' % moduleName)
|
||||||
|
|
||||||
|
pandaModules.write('from %sModules import *\n' % (moduleName))
|
||||||
|
|
||||||
|
moduleModulesFilename = os.path.join(outputDir, '%sModules.py' % (moduleName))
|
||||||
|
moduleModules = open(moduleModulesFilename, 'w')
|
||||||
|
|
||||||
|
moduleModules.write('from %s import *\n\n' % (moduleName))
|
||||||
|
|
||||||
|
# Now look for extensions
|
||||||
|
for className, classDef in module.__dict__.items():
|
||||||
|
if type(classDef) == types.TypeType:
|
||||||
|
extensionFilename = os.path.join(extensionsDir, '%s_extensions.py' % (className))
|
||||||
|
if os.path.exists(extensionFilename):
|
||||||
|
print ' Found extensions for class: %s' % (className)
|
||||||
|
extension = open(extensionFilename, 'r')
|
||||||
|
moduleModules.write(extension.read())
|
||||||
|
moduleModules.write('\n')
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
global outputDir
|
global outputDir
|
||||||
@ -200,10 +251,17 @@ def run():
|
|||||||
doErrorCheck()
|
doErrorCheck()
|
||||||
|
|
||||||
# Ok, now we can start generating code
|
# Ok, now we can start generating code
|
||||||
|
if native:
|
||||||
|
generateNativeWrappers()
|
||||||
|
|
||||||
|
else:
|
||||||
from direct.ffi import FFIInterrogateDatabase
|
from direct.ffi import FFIInterrogateDatabase
|
||||||
db = FFIInterrogateDatabase.FFIInterrogateDatabase(etcPath = etcPath)
|
db = FFIInterrogateDatabase.FFIInterrogateDatabase(etcPath = etcPath)
|
||||||
db.generateCode(outputDir, extensionsDir)
|
db.generateCode(outputDir, extensionsDir)
|
||||||
|
|
||||||
|
if doSqueeze:
|
||||||
|
db.squeezeGeneratedCode(outputDir, deleteSourceAfterSqueeze)
|
||||||
|
|
||||||
if generateManual:
|
if generateManual:
|
||||||
import epydoc.cli
|
import epydoc.cli
|
||||||
import direct.directbase.DirectStart
|
import direct.directbase.DirectStart
|
||||||
@ -211,6 +269,3 @@ def run():
|
|||||||
cmd = ["epydoc","-n","Panda3D","-o",mandir,"--docformat","panda","--ignore-param-mismatch",outputDir,directDir]
|
cmd = ["epydoc","-n","Panda3D","-o",mandir,"--docformat","panda","--ignore-param-mismatch",outputDir,directDir]
|
||||||
sys.argv = cmd
|
sys.argv = cmd
|
||||||
epydoc.cli.cli()
|
epydoc.cli.cli()
|
||||||
|
|
||||||
if doSqueeze:
|
|
||||||
db.squeezeGeneratedCode(outputDir,deleteSourceAfterSqueeze)
|
|
||||||
|
@ -107,12 +107,15 @@ from direct.ffi import FFIConstants
|
|||||||
|
|
||||||
# The following parameters were baked in to this script at the time
|
# The following parameters were baked in to this script at the time
|
||||||
# ppremake was run in Direct.
|
# ppremake was run in Direct.
|
||||||
|
#define extensions_name $[if $[PYTHON_NATIVE],extensions_native,extensions]
|
||||||
|
|
||||||
DoGenPyCode.outputDir = r'$[osfilename $[install_lib_dir]/pandac]'
|
DoGenPyCode.outputDir = r'$[osfilename $[install_lib_dir]/pandac]'
|
||||||
DoGenPyCode.extensionsDir = r'$[osfilename $[TOPDIR]/src/extensions]'
|
DoGenPyCode.extensionsDir = r'$[osfilename $[TOPDIR]/src/$[extensions_name]]'
|
||||||
DoGenPyCode.interrogateLib = r'libdtoolconfig'
|
DoGenPyCode.interrogateLib = r'libdtoolconfig'
|
||||||
DoGenPyCode.codeLibs = r'$[GENPYCODE_LIBS]'.split()
|
DoGenPyCode.codeLibs = r'$[GENPYCODE_LIBS]'.split()
|
||||||
DoGenPyCode.etcPath = [r'$[osfilename $[install_igatedb_dir]]']
|
DoGenPyCode.etcPath = [r'$[osfilename $[install_igatedb_dir]]']
|
||||||
DoGenPyCode.directDir = r'$[osfilename $[TOPDIR]]'
|
DoGenPyCode.directDir = r'$[osfilename $[TOPDIR]]'
|
||||||
|
DoGenPyCode.native = $[if $[PYTHON_NATIVE],1,0]
|
||||||
|
|
||||||
#if $[>= $[OPTIMIZE], 4]
|
#if $[>= $[OPTIMIZE], 4]
|
||||||
FFIConstants.wantComments = 0
|
FFIConstants.wantComments = 0
|
||||||
@ -125,7 +128,7 @@ FFIConstants.wantTypeChecking = 0
|
|||||||
# on the baked-in stuff--replace it with the dynamic settings from
|
# on the baked-in stuff--replace it with the dynamic settings from
|
||||||
# ctattach.
|
# ctattach.
|
||||||
DoGenPyCode.outputDir = os.path.join(directDir, 'lib', 'pandac')
|
DoGenPyCode.outputDir = os.path.join(directDir, 'lib', 'pandac')
|
||||||
DoGenPyCode.extensionsDir = os.path.join(directDir, 'src', 'extensions')
|
DoGenPyCode.extensionsDir = os.path.join(directDir, 'src', '$[extensions_name]')
|
||||||
DoGenPyCode.etcPath = []
|
DoGenPyCode.etcPath = []
|
||||||
|
|
||||||
# Look for additional packages (other than the basic three)
|
# Look for additional packages (other than the basic three)
|
||||||
|
@ -1,48 +1,4 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
if [ -z "${DIRECT}" ]; then
|
echo "genPyCodeNative is now deprecated; just use genPyCode."
|
||||||
if [ -d "direct" ]; then
|
|
||||||
echo "$0: \$DIRECT is not defined, using ./direct/ instead."
|
|
||||||
DIRECT="direct"
|
|
||||||
else
|
|
||||||
echo "$0: \$DIRECT is not defined and there is no ./direct/ at cwd. exiting."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${INSTALL_DIR}" ]; then
|
|
||||||
if [ -n "${DIRECT}" -a -d "${DIRECT}" ]; then
|
|
||||||
|
|
||||||
# echo "$0: \$INSTALL_DIR is not defined, using \$DIRECT (${DIRECT}) instead."
|
|
||||||
INSTALL_DIR="${DIRECT}"
|
|
||||||
else
|
|
||||||
echo "$0: \$INSTALL_DIR is not defined and \$DIRECT is not a suitable default. exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e ${INSTALL_DIR}/lib/pandac ]; then
|
|
||||||
mkdir ${INSTALL_DIR}/lib/pandac || exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d ${INSTALL_DIR}/lib/pandac ]; then
|
|
||||||
|
|
||||||
rm `find ${INSTALL_DIR}/lib/pandac/. -maxdepth 1 -type f -print`
|
|
||||||
|
|
||||||
cp ${DIRECT}/src/extensions_native/PandaModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpandaModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpandaphysicsModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/__init__.py* ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpandaeggModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpiratesModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libdirectModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpandaexpressModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libtoontownModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libotpModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
cp ${DIRECT}/src/extensions_native/libpandafxModules.py ${INSTALL_DIR}/lib/pandac/.
|
|
||||||
else
|
|
||||||
echo "$0: \"${INSTALL_DIR}/lib/pandac\" is not a directory"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$0: finished."
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user