mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
package -> plugin, and other minor changes
This commit is contained in:
parent
d9986dad01
commit
d315933ac5
@ -78,10 +78,13 @@ file libtinydisplay.dll
|
||||
# variables.
|
||||
inline_file Config.prc extract=1 <<- <EOF>
|
||||
plugin-path $PANDA3D_ROOT
|
||||
|
||||
aux-display pandagl
|
||||
aux-display pandadx9
|
||||
aux-display pandadx8
|
||||
aux-display tinydisplay
|
||||
|
||||
default-model-extension .bam
|
||||
<EOF>
|
||||
|
||||
end_package panda3d
|
||||
|
@ -712,23 +712,23 @@ read_contents_file(const string &contents_filename) {
|
||||
|
||||
TiXmlElement *xcontents = doc.FirstChildElement("contents");
|
||||
if (xcontents != NULL) {
|
||||
TiXmlElement *xpackage = xcontents->FirstChildElement("package");
|
||||
while (xpackage != NULL) {
|
||||
const char *name = xpackage->Attribute("name");
|
||||
TiXmlElement *xplugin = xcontents->FirstChildElement("plugin");
|
||||
while (xplugin != NULL) {
|
||||
const char *name = xplugin->Attribute("name");
|
||||
if (name != NULL && strcmp(name, "coreapi") == 0) {
|
||||
const char *platform = xpackage->Attribute("platform");
|
||||
const char *platform = xplugin->Attribute("platform");
|
||||
if (platform != NULL && strcmp(platform, DTOOL_PLATFORM) == 0) {
|
||||
get_core_api(xpackage);
|
||||
get_core_api(xplugin);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
xpackage = xpackage->NextSiblingElement("package");
|
||||
xplugin = xplugin->NextSiblingElement("plugin");
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find the coreapi package description.
|
||||
nout << "No coreapi package defined in contents file for "
|
||||
// Couldn't find the coreapi plugin description.
|
||||
nout << "No coreapi plugin defined in contents file for "
|
||||
<< DTOOL_PLATFORM << "\n";
|
||||
return false;
|
||||
}
|
||||
@ -828,8 +828,8 @@ feed_file(PPDownloadRequest *req, const string &filename) {
|
||||
// if necessary.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PPInstance::
|
||||
get_core_api(TiXmlElement *xpackage) {
|
||||
_core_api_dll.load_xml(xpackage);
|
||||
get_core_api(TiXmlElement *xplugin) {
|
||||
_core_api_dll.load_xml(xplugin);
|
||||
|
||||
if (_core_api_dll.quick_verify(_root_dir)) {
|
||||
// The DLL file is good. Just load it.
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
void feed_file(PPDownloadRequest *req, const string &filename);
|
||||
|
||||
bool read_contents_file(const string &contents_filename);
|
||||
void get_core_api(TiXmlElement *xpackage);
|
||||
void get_core_api(TiXmlElement *xplugin);
|
||||
void downloaded_plugin(const string &filename);
|
||||
void do_load_plugin();
|
||||
|
||||
|
@ -370,23 +370,23 @@ read_contents_file(Filename contents_filename, const string &download_url,
|
||||
|
||||
TiXmlElement *xcontents = doc.FirstChildElement("contents");
|
||||
if (xcontents != NULL) {
|
||||
TiXmlElement *xpackage = xcontents->FirstChildElement("package");
|
||||
while (xpackage != NULL) {
|
||||
const char *name = xpackage->Attribute("name");
|
||||
TiXmlElement *xplugin = xcontents->FirstChildElement("plugin");
|
||||
while (xplugin != NULL) {
|
||||
const char *name = xplugin->Attribute("name");
|
||||
if (name != NULL && strcmp(name, "coreapi") == 0) {
|
||||
const char *xplatform = xpackage->Attribute("platform");
|
||||
const char *xplatform = xplugin->Attribute("platform");
|
||||
if (xplatform != NULL && strcmp(xplatform, this_platform.c_str()) == 0) {
|
||||
return get_core_api(contents_filename, download_url, this_platform,
|
||||
xpackage);
|
||||
xplugin);
|
||||
}
|
||||
}
|
||||
|
||||
xpackage = xpackage->NextSiblingElement("package");
|
||||
xplugin = xplugin->NextSiblingElement("plugin");
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find the coreapi package description.
|
||||
cerr << "No coreapi package defined in contents file for "
|
||||
// Couldn't find the coreapi plugin description.
|
||||
cerr << "No coreapi plugin defined in contents file for "
|
||||
<< this_platform << "\n";
|
||||
return false;
|
||||
}
|
||||
@ -401,8 +401,8 @@ read_contents_file(Filename contents_filename, const string &download_url,
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Panda3D::
|
||||
get_core_api(const Filename &contents_filename, const string &download_url,
|
||||
const string &this_platform, TiXmlElement *xpackage) {
|
||||
_core_api_dll.load_xml(xpackage);
|
||||
const string &this_platform, TiXmlElement *xplugin) {
|
||||
_core_api_dll.load_xml(xplugin);
|
||||
|
||||
if (!_core_api_dll.quick_verify(_root_dir)) {
|
||||
// The DLL file needs to be downloaded. Go get it.
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
const string &this_platform);
|
||||
bool get_core_api(const Filename &contents_filename,
|
||||
const string &download_url, const string &this_platform,
|
||||
TiXmlElement *xpackage);
|
||||
TiXmlElement *xplugin);
|
||||
void run_getters();
|
||||
void handle_request(P3D_request *request);
|
||||
void make_parent_window(P3D_window_handle &parent_window,
|
||||
|
@ -23,7 +23,12 @@ Options:
|
||||
import sys
|
||||
import getopt
|
||||
import os
|
||||
import md5
|
||||
|
||||
try:
|
||||
import hashlib
|
||||
except ImportError:
|
||||
# Legacy Python support
|
||||
import md5 as hashlib
|
||||
|
||||
class ArgumentError(AttributeError):
|
||||
pass
|
||||
@ -40,7 +45,7 @@ class FileSpec:
|
||||
self.size = s.st_size
|
||||
self.timestamp = int(s.st_mtime)
|
||||
|
||||
m = md5.new()
|
||||
m = hashlib.md5()
|
||||
m.update(open(pathname, 'rb').read())
|
||||
self.hash = m.hexdigest()
|
||||
|
||||
@ -70,9 +75,9 @@ class ContentsMaker:
|
||||
print >> f, '<?xml version="1.0" ?>'
|
||||
print >> f, ''
|
||||
print >> f, '<contents>'
|
||||
for packageName, packagePlatform, packageVersion, file in self.packages:
|
||||
print >> f, ' <package name="%s" platform="%s" version="%s" %s />' % (
|
||||
packageName, packagePlatform or '', packageVersion, file.getParams())
|
||||
for type, packageName, packagePlatform, packageVersion, file in self.packages:
|
||||
print >> f, ' <%s name="%s" platform="%s" version="%s" %s />' % (
|
||||
type, packageName, packagePlatform or '', packageVersion, file.getParams())
|
||||
print >> f, '</contents>'
|
||||
f.close()
|
||||
|
||||
@ -93,12 +98,15 @@ class ContentsMaker:
|
||||
localpath = dirpath[len(prefix):].replace(os.sep, '/') + '/'
|
||||
xml = dirpath[len(prefix):].replace(os.sep, '_') + '.xml'
|
||||
|
||||
type = 'package'
|
||||
|
||||
# A special case: the "plugin" and "coreapi" directories
|
||||
# don't have xml files, just dll's.
|
||||
if xml.startswith('plugin_') or xml.startswith('coreapi_'):
|
||||
if filenames:
|
||||
assert len(filenames) == 1
|
||||
xml = filenames[0]
|
||||
type = 'plugin'
|
||||
|
||||
if xml not in filenames:
|
||||
continue
|
||||
@ -106,17 +114,28 @@ class ContentsMaker:
|
||||
if localpath.count('/') == 2:
|
||||
packageName, packageVersion, junk = localpath.split('/')
|
||||
packagePlatform = None
|
||||
file = FileSpec(localpath + xml,
|
||||
os.path.join(self.installDir, localpath + xml))
|
||||
print file.filename
|
||||
self.packages.append((packageName, packagePlatform, packageVersion, file))
|
||||
|
||||
if localpath.count('/') == 3:
|
||||
elif localpath.count('/') == 3:
|
||||
packageName, packagePlatform, packageVersion, junk = localpath.split('/')
|
||||
file = FileSpec(localpath + xml,
|
||||
os.path.join(self.installDir, localpath + xml))
|
||||
print file.filename
|
||||
self.packages.append((packageName, packagePlatform, packageVersion, file))
|
||||
else:
|
||||
continue
|
||||
|
||||
file = FileSpec(localpath + xml,
|
||||
os.path.join(self.installDir, localpath + xml))
|
||||
print file.filename
|
||||
self.packages.append((type, packageName, packagePlatform, packageVersion, file))
|
||||
|
||||
if type == 'package':
|
||||
# Look for an _import.xml file, too.
|
||||
xml = xml[:-4] + '_import.xml'
|
||||
try:
|
||||
file = FileSpec(localpath + xml,
|
||||
os.path.join(self.installDir, localpath + xml))
|
||||
except OSError:
|
||||
file = None
|
||||
if file:
|
||||
print file.filename
|
||||
self.packages.append(('import', packageName, packagePlatform, packageVersion, file))
|
||||
|
||||
|
||||
def makeContents(args):
|
||||
|
@ -35,15 +35,6 @@ import os
|
||||
import types
|
||||
import __builtin__
|
||||
|
||||
MultifileRoot = '/mf'
|
||||
|
||||
# This defines the default prc file that is implicitly loaded with an
|
||||
# application.
|
||||
AppPrcFilename = 'App.prc'
|
||||
AppPrc = """
|
||||
default-model-extension .bam
|
||||
"""
|
||||
|
||||
class ArgumentError(AttributeError):
|
||||
pass
|
||||
|
||||
@ -76,6 +67,11 @@ class AppRunner(DirectObject):
|
||||
# TODO: we need one of these per instance, not per session.
|
||||
self.instanceId = None
|
||||
|
||||
# The mount point for the multifile. For now, this is always
|
||||
# the same, but when we move to multiple-instance sessions, it
|
||||
# may have to be different for each instance.
|
||||
self.multifileRoot = '/mf'
|
||||
|
||||
# The attributes of this object will be exposed as attributes
|
||||
# of the plugin instance in the DOM.
|
||||
self.attributes = ScriptAttributes()
|
||||
@ -177,13 +173,10 @@ class AppRunner(DirectObject):
|
||||
|
||||
# Now set up Python to import this stuff.
|
||||
VFSImporter.register()
|
||||
sys.path = [ MultifileRoot ] + sys.path
|
||||
sys.path = [ self.multifileRoot ] + sys.path
|
||||
|
||||
# Put our root directory on the model-path and prc-path, too.
|
||||
getModelPath().prependDirectory(MultifileRoot)
|
||||
|
||||
# Load the implicit App.prc file.
|
||||
loadPrcFileData(AppPrcFilename, AppPrc)
|
||||
# Put our root directory on the model-path, too.
|
||||
getModelPath().prependDirectory(self.multifileRoot)
|
||||
|
||||
# Replace the builtin open and file symbols so user code will get
|
||||
# our versions by default, which can open and read files out of
|
||||
@ -196,7 +189,7 @@ class AppRunner(DirectObject):
|
||||
if not self.fullDiskAccess:
|
||||
# Make "/mf" our "current directory", for running the multifiles
|
||||
# we plan to mount there.
|
||||
vfs.chdir(MultifileRoot)
|
||||
vfs.chdir(self.multifileRoot)
|
||||
|
||||
def startIfReady(self):
|
||||
if self.started:
|
||||
@ -223,7 +216,7 @@ class AppRunner(DirectObject):
|
||||
if mainName:
|
||||
moduleName = mainName
|
||||
|
||||
root = MultifileRoot
|
||||
root = self.multifileRoot
|
||||
if '.' in moduleName:
|
||||
root += '/' + '/'.join(moduleName.split('.')[:-1])
|
||||
v = VFSImporter.VFSImporter(root)
|
||||
@ -308,8 +301,8 @@ class AppRunner(DirectObject):
|
||||
self.initPackedAppEnvironment()
|
||||
|
||||
# Mount the Multifile under /mf, by convention.
|
||||
vfs.mount(mf, MultifileRoot, vfs.MFReadOnly)
|
||||
VFSImporter.freeze_new_modules(mf, MultifileRoot)
|
||||
vfs.mount(mf, self.multifileRoot, vfs.MFReadOnly)
|
||||
VFSImporter.freeze_new_modules(mf, self.multifileRoot)
|
||||
|
||||
# Load any prc files in the root. We have to load them
|
||||
# explicitly, since the ConfigPageManager can't directly look
|
||||
@ -319,7 +312,7 @@ class AppRunner(DirectObject):
|
||||
for f in mf.getSubfileNames():
|
||||
fn = Filename(f)
|
||||
if fn.getDirname() == '' and fn.getExtension() == 'prc':
|
||||
pathname = '%s/%s' % (MultifileRoot, f)
|
||||
pathname = '%s/%s' % (self.multifileRoot, f)
|
||||
data = open(pathname, 'r').read()
|
||||
loadPrcFileData(pathname, data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user