Fixes for 64-bit OS X build on newer OS X versions

This commit is contained in:
rdb 2015-03-29 22:06:32 +02:00
parent 982ece639d
commit 5827959056
11 changed files with 41 additions and 22 deletions

View File

@ -1119,14 +1119,19 @@ class Packager:
# Skip this file.
continue
origFilename = Filename(file.filename)
tempFile = Filename.temporary('', 'p3d_', '.txt')
command = '/usr/bin/otool -arch all -L "%s" >"%s"' % (
file.filename.toOsSpecific(),
origFilename.toOsSpecific(),
tempFile.toOsSpecific())
if self.arch:
arch = self.arch
if arch == "amd64":
arch = "x86_64"
command = '/usr/bin/otool -arch %s -L "%s" >"%s"' % (
self.arch,
file.filename.toOsSpecific(),
arch,
origFilename.toOsSpecific(),
tempFile.toOsSpecific())
exitStatus = os.system(command)
if exitStatus != 0:
@ -1137,13 +1142,13 @@ class Packager:
filenames = self.__parseDependenciesOSX(tempFile)
tempFile.unlink()
if filenames is None:
self.notify.warning("Unable to determine dependencies from %s" % (file.filename))
self.notify.warning("Unable to determine dependencies from %s" % (origFilename))
continue
# Attempt to resolve the dependent filename relative
# to the original filename, before we resolve it along
# the PATH.
path = DSearchPath(Filename(file.filename.getDirname()))
path = DSearchPath(Filename(origFilename.getDirname()))
# Find the dependencies that are referencing a framework
framework_deps = []
@ -1157,7 +1162,7 @@ class Packager:
for filename in filenames:
if '@loader_path' in filename:
filename = filename.replace('@loader_path', file.filename.getDirname())
filename = filename.replace('@loader_path', origFilename.getDirname())
if False and '.framework/' in filename:
# It references a framework, and besides the fact
@ -2085,6 +2090,10 @@ class Packager:
# particular architecture, use lipo to strip out the
# part of the file for that architecture.
arch = self.arch
if arch == "amd64":
arch = "x86_64"
# First, we need to verify that it is in fact a
# universal binary.
tfile = Filename.temporary('', 'p3d_')
@ -2110,25 +2119,24 @@ class Packager:
arches = lipoData.rsplit(':', 1)[1]
arches = arches.split()
if arches == [self.arch]:
if arches == [arch]:
# The file only contains the one architecture that
# we want anyway.
file.filename.setBinary()
self.multifile.addSubfile(file.newName, file.filename, compressionLevel)
return True
if self.arch not in arches:
if arch not in arches:
# The file doesn't support the architecture that we
# want at all. Omit the file.
self.notify.warning("%s doesn't support architecture %s" % (
file.filename, self.arch))
return False
# The file contains multiple architectures. Get
# out just the one we want.
command = '/usr/bin/lipo -thin %s -output "%s" "%s"' % (
self.arch, tfile.toOsSpecific(),
arch, tfile.toOsSpecific(),
file.filename.toOsSpecific())
exitStatus = os.system(command)
if exitStatus != 0:

View File

@ -90,7 +90,7 @@ Options:
each supported architecture). On other platforms, this option
does nothing. This is therefore safe to apply in all cases, if
you wish to take advantage of universal binaries. This is
equivalent to "-P osx_i386 -P osx_x86_64" on Mac platforms.
equivalent to "-P osx_i386 -P osx_amd64" on Mac platforms.
-P platform
Specify the platform to masquerade as. The default is whatever
@ -215,7 +215,7 @@ if universalBinaries:
print '\nYou may not specify both -u and -P.\n'
sys.exit(1)
if PandaSystem.getPlatform().startswith('osx_'):
platforms = ['osx_i386', 'osx_x86_64']
platforms = ['osx_i386', 'osx_amd64']
if not platforms:
platforms = [PandaSystem.getPlatform()]

View File

@ -461,7 +461,10 @@ def makeInstaller():
infoFilename = None
descriptionFilename = None
packagemaker = "/Developer/usr/bin/packagemaker"
packagemaker = "/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"
if not os.path.exists(packagemaker):
packagemaker = "/Developer/usr/bin/packagemaker"
if os.path.exists(packagemaker):
# PackageMaker 3.0 or better, e.g. OSX 10.5.
CMD = packagemaker
@ -469,7 +472,7 @@ def makeInstaller():
CMD += ' --version "%s"' % options.version
CMD += ' --title "%s"' % options.long_name
CMD += ' --out "%s"' % (pkgname)
CMD += ' --target 10.4' # The earliest version of OSX supported by Panda
CMD += ' --target 10.5' # The earliest version of OSX supported by Panda
CMD += ' --domain system'
CMD += ' --root "%s"' % tmproot
CMD += ' --resources "%s"' % tmpresdir
@ -520,7 +523,11 @@ def makeInstaller():
# Pack the .pkg into a .dmg
if not os.path.exists(tmproot): os.makedirs(tmproot)
shutil.copytree(pkgname, os.path.join(tmproot, pkgname))
if os.path.isdir(pkgname):
shutil.copytree(pkgname, os.path.join(tmproot, pkgname))
else:
shutil.copyfile(pkgname, os.path.join(tmproot, pkgname))
tmpdmg = tempfile.mktemp('', 'p3d-setup') + ".dmg"
CMD = 'hdiutil create "%s" -srcfolder "%s"' % (tmpdmg, tmproot)
print ""

View File

@ -143,7 +143,7 @@ class CompilationEnvironment:
self.arch = '-arch i386'
elif proc == 'ppc':
self.arch = '-arch ppc'
elif proc == 'x86_64':
elif proc == 'amd64':
self.arch = '-arch x86_64'
self.compileObj = "gcc -fPIC -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s"
self.linkExe = "gcc %(arch)s -o %(basename)s %(basename)s.o -framework Python"

View File

@ -184,6 +184,7 @@ def parseopts(args):
target_arch = None
universal = False
for pkg in PkgListGet():
longopts.append("use-" + pkg.lower())
longopts.append("no-" + pkg.lower())
longopts.append(pkg.lower() + "-incdir=")
longopts.append(pkg.lower() + "-libdir=")
@ -1835,6 +1836,8 @@ def Package(target, inputs, opts):
command += " -R \"%s\"" % SDK["MACOSX"]
for arch in OSX_ARCHS:
if arch == "x86_64":
arch = "amd64"
command += " -P osx_%s" % arch
command += " -i \"" + GetOutputDir() + "/stage\""

View File

@ -16,6 +16,7 @@
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
using namespace std;

View File

@ -116,7 +116,7 @@ init_libtinydisplay() {
ps->set_system_tag("TinyPanda", "native_window_system", "Win");
#endif
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
TinyOsxGraphicsPipe::init_type();
TinyOsxGraphicsWindow::init_type();
selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(),
@ -150,7 +150,7 @@ get_pipe_type_p3tinydisplay() {
return TinyWinGraphicsPipe::get_class_type().get_index();
#endif
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
return TinyOsxGraphicsPipe::get_class_type().get_index();
#endif

View File

@ -14,7 +14,7 @@
#include "pandabase.h"
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
#include "tinyOsxGraphicsPipe.h"
#include "config_tinydisplay.h"

View File

@ -17,7 +17,7 @@
#include "pandabase.h"
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
// We have to include this early, before anyone includes
// netinet/tcp.h, which will define TCP_NODELAY and other symbols and

View File

@ -17,7 +17,7 @@
#include "pandabase.h"
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
#include <Carbon/Carbon.h>

View File

@ -11,7 +11,7 @@
#include "pandabase.h"
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON)
#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
#include <Carbon/Carbon.h>
#include <Cocoa/Cocoa.h>