mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
executable p3d's
This commit is contained in:
parent
0c13f6a654
commit
d163bc6412
@ -158,12 +158,42 @@ read_header(const string &pathname) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < _header_size; ++i) {
|
char this_header[_header_size];
|
||||||
int ch = _in.get();
|
_in.seekg(0);
|
||||||
if (ch != _header[i]) {
|
_in.read(this_header, _header_size);
|
||||||
nout << "Failed header check: " << pathname << "\n";
|
if (_in.fail() || _in.gcount() != (unsigned)_header_size) {
|
||||||
return false;
|
nout
|
||||||
|
<< "Unable to read Multifile header " << pathname << ".\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here's a special case: if the multifile begins with a hash
|
||||||
|
// character, then we skip at least 6 characters, and continue
|
||||||
|
// reading and discarding lines of ASCII text, until we come across
|
||||||
|
// a nonempty line that does not begin with a hash character. This
|
||||||
|
// allows a P3D application (which is a multifile) to be run
|
||||||
|
// directly on the command line on Unix-based systems.
|
||||||
|
if (this_header[0] == '#') {
|
||||||
|
int ch = '#';
|
||||||
|
while (ch != EOF && ch == '#') {
|
||||||
|
// Skip to the end of the line.
|
||||||
|
while (ch != EOF && ch != '\n') {
|
||||||
|
ch = _in.get();
|
||||||
|
}
|
||||||
|
// Skip to the first non-whitespace character of the line.
|
||||||
|
while (ch != EOF && (isspace(ch) || ch == '\r')) {
|
||||||
|
ch = _in.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now fill up the header.
|
||||||
|
this_header[0] = ch;
|
||||||
|
_in.read(this_header + 1, _header_size - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp(this_header, _header, _header_size) != 0) {
|
||||||
|
nout << "Failed header check: " << pathname << "\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int major = read_uint16();
|
unsigned int major = read_uint16();
|
||||||
|
@ -174,10 +174,14 @@ class Packager:
|
|||||||
if self.dryRun:
|
if self.dryRun:
|
||||||
self.multifile = None
|
self.multifile = None
|
||||||
else:
|
else:
|
||||||
|
self.multifile = Multifile()
|
||||||
|
|
||||||
|
if self.p3dApplication:
|
||||||
|
self.multifile.setHeaderPrefix('#! /usr/bin/env panda3d\n')
|
||||||
|
|
||||||
# Write the multifile to a temporary filename until we
|
# Write the multifile to a temporary filename until we
|
||||||
# know enough to determine the output filename.
|
# know enough to determine the output filename.
|
||||||
multifileFilename = Filename.temporary('', self.packageName)
|
multifileFilename = Filename.temporary('', self.packageName)
|
||||||
self.multifile = Multifile()
|
|
||||||
self.multifile.openReadWrite(multifileFilename)
|
self.multifile.openReadWrite(multifileFilename)
|
||||||
|
|
||||||
self.extracts = []
|
self.extracts = []
|
||||||
@ -252,7 +256,7 @@ class Packager:
|
|||||||
xmodule.SetAttribute('forbid', '1')
|
xmodule.SetAttribute('forbid', '1')
|
||||||
if mdef.exclude and mdef.allowChildren:
|
if mdef.exclude and mdef.allowChildren:
|
||||||
xmodule.SetAttribute('allowChildren', '1')
|
xmodule.SetAttribute('allowChildren', '1')
|
||||||
self.components.append((newName.lower(), xmodule))
|
self.components.append(('m', newName.lower(), xmodule))
|
||||||
|
|
||||||
# Now look for implicit shared-library dependencies.
|
# Now look for implicit shared-library dependencies.
|
||||||
if PandaSystem.getPlatform().startswith('win'):
|
if PandaSystem.getPlatform().startswith('win'):
|
||||||
@ -356,10 +360,14 @@ class Packager:
|
|||||||
|
|
||||||
multifileFilename.renameTo(self.packageFullpath)
|
multifileFilename.renameTo(self.packageFullpath)
|
||||||
|
|
||||||
if not self.p3dApplication:
|
if self.p3dApplication:
|
||||||
|
# Make the application file executable.
|
||||||
|
os.chmod(self.packageFullpath.toOsSpecific(), 0755)
|
||||||
|
else:
|
||||||
self.compressMultifile()
|
self.compressMultifile()
|
||||||
self.writeDescFile()
|
self.writeDescFile()
|
||||||
self.writeImportDescFile()
|
self.writeImportDescFile()
|
||||||
|
|
||||||
|
|
||||||
# Now that all the files have been packed, we can delete
|
# Now that all the files have been packed, we can delete
|
||||||
# the temporary files.
|
# the temporary files.
|
||||||
@ -757,7 +765,7 @@ class Packager:
|
|||||||
xpackage.InsertEndChild(xrequires)
|
xpackage.InsertEndChild(xrequires)
|
||||||
|
|
||||||
self.components.sort()
|
self.components.sort()
|
||||||
for name, xcomponent in self.components:
|
for type, name, xcomponent in self.components:
|
||||||
xpackage.InsertEndChild(xcomponent)
|
xpackage.InsertEndChild(xcomponent)
|
||||||
|
|
||||||
doc.InsertEndChild(xpackage)
|
doc.InsertEndChild(xpackage)
|
||||||
@ -935,7 +943,7 @@ class Packager:
|
|||||||
|
|
||||||
xcomponent = TiXmlElement('component')
|
xcomponent = TiXmlElement('component')
|
||||||
xcomponent.SetAttribute('filename', newName)
|
xcomponent.SetAttribute('filename', newName)
|
||||||
self.components.append((newName.lower(), xcomponent))
|
self.components.append(('c', newName.lower(), xcomponent))
|
||||||
|
|
||||||
def addFoundTexture(self, filename):
|
def addFoundTexture(self, filename):
|
||||||
""" Adds the newly-discovered texture to the output, if it has
|
""" Adds the newly-discovered texture to the output, if it has
|
||||||
@ -979,7 +987,7 @@ class Packager:
|
|||||||
|
|
||||||
xcomponent = TiXmlElement('component')
|
xcomponent = TiXmlElement('component')
|
||||||
xcomponent.SetAttribute('filename', file.newName)
|
xcomponent.SetAttribute('filename', file.newName)
|
||||||
self.components.append((file.newName.lower(), xcomponent))
|
self.components.append(('c', file.newName.lower(), xcomponent))
|
||||||
|
|
||||||
def requirePackage(self, package):
|
def requirePackage(self, package):
|
||||||
""" Indicates a dependency on the given package. This
|
""" Indicates a dependency on the given package. This
|
||||||
|
@ -7,12 +7,12 @@ tree of .py files and models, into a p3d file for convenient
|
|||||||
distribution. The resulting p3d file can be run by the Panda3D
|
distribution. The resulting p3d file can be run by the Panda3D
|
||||||
runtime executable, or by the Panda3D web browser plugin.
|
runtime executable, or by the Panda3D web browser plugin.
|
||||||
|
|
||||||
Also see ppackage.py, which can be used to build p3d files more
|
Also see ppackage, which can be used to build p3d files more
|
||||||
generally, using a pdef description file.
|
generally, using a pdef description file.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
packp3d.py [opts] app.p3d
|
%s [opts] app.p3d
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ def makePackedApp(args):
|
|||||||
elif option == '-x':
|
elif option == '-x':
|
||||||
versionIndependent = True
|
versionIndependent = True
|
||||||
elif option == '-h':
|
elif option == '-h':
|
||||||
print __doc__
|
print __doc__ % (os.path.split(sys.argv[0])[1])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
|
@ -22,7 +22,7 @@ This script is actually a wrapper around Panda's Packager.py.
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
ppackage.py [opts] package.pdef
|
%s [opts] package.pdef
|
||||||
|
|
||||||
Required:
|
Required:
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ from direct.showutil import make_contents
|
|||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
|
|
||||||
def usage(code, msg = ''):
|
def usage(code, msg = ''):
|
||||||
print >> sys.stderr, __doc__
|
print >> sys.stderr, __doc__ % (os.path.split(sys.argv[0])[1])
|
||||||
print >> sys.stderr, msg
|
print >> sys.stderr, msg
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user