|
@@ -39,7 +39,8 @@ class Packager:
|
|
|
newName = None, deleteTemp = False,
|
|
newName = None, deleteTemp = False,
|
|
|
explicit = False, compress = None, extract = None,
|
|
explicit = False, compress = None, extract = None,
|
|
|
text = None, unprocessed = None,
|
|
text = None, unprocessed = None,
|
|
|
- executable = None, platformSpecific = None):
|
|
|
|
|
|
|
+ executable = None, dependencyDir = None,
|
|
|
|
|
+ platformSpecific = None):
|
|
|
assert isinstance(filename, Filename)
|
|
assert isinstance(filename, Filename)
|
|
|
self.filename = Filename(filename)
|
|
self.filename = Filename(filename)
|
|
|
self.newName = newName
|
|
self.newName = newName
|
|
@@ -50,6 +51,7 @@ class Packager:
|
|
|
self.text = text
|
|
self.text = text
|
|
|
self.unprocessed = unprocessed
|
|
self.unprocessed = unprocessed
|
|
|
self.executable = executable
|
|
self.executable = executable
|
|
|
|
|
+ self.dependencyDir = dependencyDir
|
|
|
self.platformSpecific = platformSpecific
|
|
self.platformSpecific = platformSpecific
|
|
|
|
|
|
|
|
if not self.newName:
|
|
if not self.newName:
|
|
@@ -73,6 +75,11 @@ class Packager:
|
|
|
if self.executable is None:
|
|
if self.executable is None:
|
|
|
self.executable = (ext in packager.executableExtensions)
|
|
self.executable = (ext in packager.executableExtensions)
|
|
|
|
|
|
|
|
|
|
+ if self.executable and self.dependencyDir is None:
|
|
|
|
|
+ # By default, install executable dependencies in the
|
|
|
|
|
+ # same directory with the executable itself.
|
|
|
|
|
+ self.dependencyDir = Filename(self.newName).getDirname()
|
|
|
|
|
+
|
|
|
if self.extract is None:
|
|
if self.extract is None:
|
|
|
self.extract = self.executable or (ext in packager.extractExtensions)
|
|
self.extract = self.executable or (ext in packager.extractExtensions)
|
|
|
if self.platformSpecific is None:
|
|
if self.platformSpecific is None:
|
|
@@ -779,7 +786,9 @@ class Packager:
|
|
|
for filename in filenames:
|
|
for filename in filenames:
|
|
|
filename = Filename.fromOsSpecific(filename)
|
|
filename = Filename.fromOsSpecific(filename)
|
|
|
filename.resolveFilename(path)
|
|
filename.resolveFilename(path)
|
|
|
- self.addFile(filename, newName = filename.getBasename(),
|
|
|
|
|
|
|
+
|
|
|
|
|
+ newName = Filename(file.dependencyDir, filename.getBasename())
|
|
|
|
|
+ self.addFile(filename, newName = newName.cStr(),
|
|
|
explicit = False, executable = True)
|
|
explicit = False, executable = True)
|
|
|
|
|
|
|
|
def __parseDependenciesWindows(self, tempFile):
|
|
def __parseDependenciesWindows(self, tempFile):
|
|
@@ -851,13 +860,19 @@ class Packager:
|
|
|
""" Copies the given library file to a temporary directory,
|
|
""" Copies the given library file to a temporary directory,
|
|
|
and alters the dependencies so that it doesn't contain absolute
|
|
and alters the dependencies so that it doesn't contain absolute
|
|
|
framework dependencies. """
|
|
framework dependencies. """
|
|
|
-
|
|
|
|
|
- # Copy the file to a temporary location because we don't want
|
|
|
|
|
- # to modify the original (there's a big chance that we break it)
|
|
|
|
|
- assert file.filename.exists(), "File doesn't exist: %s" % ffilename
|
|
|
|
|
- tmpfile = Filename.fromOsSpecific("/tmp/p3d_" + hashlib.md5(file.filename.toOsSpecific()).hexdigest())
|
|
|
|
|
- if not tmpfile.exists():
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if not file.deleteTemp:
|
|
|
|
|
+ # Copy the file to a temporary location because we
|
|
|
|
|
+ # don't want to modify the original (there's a big
|
|
|
|
|
+ # chance that we break it).
|
|
|
|
|
+
|
|
|
|
|
+ # Copy it every time, because the source file might
|
|
|
|
|
+ # have changed since last time we ran.
|
|
|
|
|
+ assert file.filename.exists(), "File doesn't exist: %s" % ffilename
|
|
|
|
|
+ tmpfile = Filename.temporary('', "p3d_" + file.filename.getBasename())
|
|
|
file.filename.copyTo(tmpfile)
|
|
file.filename.copyTo(tmpfile)
|
|
|
|
|
+ file.filename = tmpfile
|
|
|
|
|
+ file.deleteTemp = True
|
|
|
|
|
|
|
|
# Alter the dependencies to have a relative path rather than absolute
|
|
# Alter the dependencies to have a relative path rather than absolute
|
|
|
for filename in framework_deps:
|
|
for filename in framework_deps:
|
|
@@ -865,7 +880,6 @@ class Packager:
|
|
|
os.system('install_name_tool -id "%s" "%s"' % (os.path.basename(filename), tmpfile.toOsSpecific()))
|
|
os.system('install_name_tool -id "%s" "%s"' % (os.path.basename(filename), tmpfile.toOsSpecific()))
|
|
|
else:
|
|
else:
|
|
|
os.system('install_name_tool -change "%s" "%s" "%s"' % (filename, os.path.basename(filename), tmpfile.toOsSpecific()))
|
|
os.system('install_name_tool -change "%s" "%s" "%s"' % (filename, os.path.basename(filename), tmpfile.toOsSpecific()))
|
|
|
- self.sourceFilenames[file.filename].filename = tmpfile
|
|
|
|
|
|
|
|
|
|
def __addImplicitDependenciesOSX(self):
|
|
def __addImplicitDependenciesOSX(self):
|
|
|
""" Walks through the list of files, looking for dylib's
|
|
""" Walks through the list of files, looking for dylib's
|
|
@@ -915,7 +929,7 @@ class Packager:
|
|
|
if len(framework_deps) > 0:
|
|
if len(framework_deps) > 0:
|
|
|
# Fixes dependencies like @executable_path/../Library/Frameworks/Cg.framework/Cg
|
|
# Fixes dependencies like @executable_path/../Library/Frameworks/Cg.framework/Cg
|
|
|
self.__alterFrameworkDependencies(file, framework_deps)
|
|
self.__alterFrameworkDependencies(file, framework_deps)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for filename in filenames:
|
|
for filename in filenames:
|
|
|
if '.framework/' in filename:
|
|
if '.framework/' in filename:
|
|
|
# It references a framework, and besides the fact
|
|
# It references a framework, and besides the fact
|
|
@@ -926,7 +940,9 @@ class Packager:
|
|
|
# It's just a normal library - find it on the path.
|
|
# It's just a normal library - find it on the path.
|
|
|
filename = Filename.fromOsSpecific(filename)
|
|
filename = Filename.fromOsSpecific(filename)
|
|
|
filename.resolveFilename(path)
|
|
filename.resolveFilename(path)
|
|
|
- self.addFile(filename, newName = filename.getBasename(),
|
|
|
|
|
|
|
+
|
|
|
|
|
+ newName = Filename(file.dependencyDir, filename.getBasename())
|
|
|
|
|
+ self.addFile(filename, newName = newName.cStr(),
|
|
|
explicit = False, executable = True)
|
|
explicit = False, executable = True)
|
|
|
|
|
|
|
|
def __parseDependenciesOSX(self, tempFile):
|
|
def __parseDependenciesOSX(self, tempFile):
|
|
@@ -998,7 +1014,9 @@ class Packager:
|
|
|
for filename in filenames:
|
|
for filename in filenames:
|
|
|
filename = Filename.fromOsSpecific(filename)
|
|
filename = Filename.fromOsSpecific(filename)
|
|
|
filename.resolveFilename(path)
|
|
filename.resolveFilename(path)
|
|
|
- self.addFile(filename, newName = filename.getBasename(),
|
|
|
|
|
|
|
+
|
|
|
|
|
+ newName = Filename(file.dependencyDir, filename.getBasename())
|
|
|
|
|
+ self.addFile(filename, newName = newName.cStr(),
|
|
|
explicit = False, executable = True)
|
|
explicit = False, executable = True)
|
|
|
|
|
|
|
|
def __parseDependenciesPosix(self, tempFile):
|
|
def __parseDependenciesPosix(self, tempFile):
|
|
@@ -2517,6 +2535,22 @@ class Packager:
|
|
|
# an associated dynamic library. Note that the .exe and .dll
|
|
# an associated dynamic library. Note that the .exe and .dll
|
|
|
# extensions are automatically replaced with the appropriate
|
|
# extensions are automatically replaced with the appropriate
|
|
|
# platform-specific extensions.
|
|
# platform-specific extensions.
|
|
|
|
|
+
|
|
|
|
|
+ if self.platform.startswith('osx'):
|
|
|
|
|
+ # On Mac, we package up a P3DPython.app bundle. This
|
|
|
|
|
+ # includes specifications in the plist file to avoid
|
|
|
|
|
+ # creating a dock icon and stuff.
|
|
|
|
|
+
|
|
|
|
|
+ # Find p3dpython.plist in the direct source tree.
|
|
|
|
|
+ import direct
|
|
|
|
|
+ plist = Filename(direct.__path__[0], 'plugin/p3dpython.plist')
|
|
|
|
|
+ self.do_makeBundle('P3DPython.app', plist, executable = 'p3dpython',
|
|
|
|
|
+ dependencyDir = '')
|
|
|
|
|
+
|
|
|
|
|
+ else:
|
|
|
|
|
+ # Anywhere else, we just ship the executable file p3dcert.exe.
|
|
|
|
|
+ self.do_file('p3dcert.exe')
|
|
|
|
|
+
|
|
|
self.do_file('p3dpython.exe')
|
|
self.do_file('p3dpython.exe')
|
|
|
if PandaSystem.getPlatform().startswith('win'):
|
|
if PandaSystem.getPlatform().startswith('win'):
|
|
|
self.do_file('p3dpythonw.exe')
|
|
self.do_file('p3dpythonw.exe')
|
|
@@ -2574,6 +2608,27 @@ class Packager:
|
|
|
freezer.reset()
|
|
freezer.reset()
|
|
|
package.mainModule = None
|
|
package.mainModule = None
|
|
|
|
|
|
|
|
|
|
+ def do_makeBundle(self, bundleName, plist, executable = None,
|
|
|
|
|
+ resources = None, dependencyDir = None):
|
|
|
|
|
+ """ Constructs a minimal OSX "bundle" consisting of an
|
|
|
|
|
+ executable and a plist file, with optional resource files
|
|
|
|
|
+ (such as icons), and adds it to the package under the given
|
|
|
|
|
+ name. """
|
|
|
|
|
+
|
|
|
|
|
+ contents = bundleName + '/Contents'
|
|
|
|
|
+
|
|
|
|
|
+ self.addFiles([plist], newName = contents + '/Info.plist',
|
|
|
|
|
+ extract = True)
|
|
|
|
|
+ if executable:
|
|
|
|
|
+ basename = Filename(executable).getBasename()
|
|
|
|
|
+ self.addFiles([executable], newName = contents + '/MacOS/' + basename,
|
|
|
|
|
+ extract = True, executable = True, dependencyDir = dependencyDir)
|
|
|
|
|
+ if resources:
|
|
|
|
|
+ self.addFiles(resources, newDir = contents + '/Resources',
|
|
|
|
|
+ extract = True, dependencyDir = dependencyDir)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def do_file(self, *args, **kw):
|
|
def do_file(self, *args, **kw):
|
|
|
""" Adds the indicated file or files to the current package.
|
|
""" Adds the indicated file or files to the current package.
|
|
|
See addFiles(). """
|
|
See addFiles(). """
|
|
@@ -2582,7 +2637,7 @@ class Packager:
|
|
|
|
|
|
|
|
def addFiles(self, filenames, text = None, newName = None,
|
|
def addFiles(self, filenames, text = None, newName = None,
|
|
|
newDir = None, extract = None, executable = None,
|
|
newDir = None, extract = None, executable = None,
|
|
|
- deleteTemp = False, literal = False):
|
|
|
|
|
|
|
+ deleteTemp = False, literal = False, dependencyDir = None):
|
|
|
|
|
|
|
|
""" Adds the indicated arbitrary files to the current package.
|
|
""" Adds the indicated arbitrary files to the current package.
|
|
|
|
|
|
|
@@ -2705,7 +2760,8 @@ class Packager:
|
|
|
self.currentPackage.addFile(
|
|
self.currentPackage.addFile(
|
|
|
filename, newName = name, extract = extract,
|
|
filename, newName = name, extract = extract,
|
|
|
explicit = explicit, executable = executable,
|
|
explicit = explicit, executable = executable,
|
|
|
- text = text, deleteTemp = deleteTemp)
|
|
|
|
|
|
|
+ text = text, deleteTemp = deleteTemp,
|
|
|
|
|
+ dependencyDir = dependencyDir)
|
|
|
|
|
|
|
|
def do_exclude(self, filename):
|
|
def do_exclude(self, filename):
|
|
|
""" Marks the indicated filename as not to be included. The
|
|
""" Marks the indicated filename as not to be included. The
|