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

View File

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

View File

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

View File

@ -143,7 +143,7 @@ class CompilationEnvironment:
self.arch = '-arch i386' self.arch = '-arch i386'
elif proc == 'ppc': elif proc == 'ppc':
self.arch = '-arch ppc' self.arch = '-arch ppc'
elif proc == 'x86_64': elif proc == 'amd64':
self.arch = '-arch x86_64' self.arch = '-arch x86_64'
self.compileObj = "gcc -fPIC -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s" 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" 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 target_arch = None
universal = False universal = False
for pkg in PkgListGet(): for pkg in PkgListGet():
longopts.append("use-" + pkg.lower())
longopts.append("no-" + pkg.lower()) longopts.append("no-" + pkg.lower())
longopts.append(pkg.lower() + "-incdir=") longopts.append(pkg.lower() + "-incdir=")
longopts.append(pkg.lower() + "-libdir=") longopts.append(pkg.lower() + "-libdir=")
@ -1835,6 +1836,8 @@ def Package(target, inputs, opts):
command += " -R \"%s\"" % SDK["MACOSX"] command += " -R \"%s\"" % SDK["MACOSX"]
for arch in OSX_ARCHS: for arch in OSX_ARCHS:
if arch == "x86_64":
arch = "amd64"
command += " -P osx_%s" % arch command += " -P osx_%s" % arch
command += " -i \"" + GetOutputDir() + "/stage\"" command += " -i \"" + GetOutputDir() + "/stage\""

View File

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

View File

@ -116,7 +116,7 @@ init_libtinydisplay() {
ps->set_system_tag("TinyPanda", "native_window_system", "Win"); ps->set_system_tag("TinyPanda", "native_window_system", "Win");
#endif #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(); TinyOsxGraphicsPipe::init_type();
TinyOsxGraphicsWindow::init_type(); TinyOsxGraphicsWindow::init_type();
selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(), selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(),
@ -150,7 +150,7 @@ get_pipe_type_p3tinydisplay() {
return TinyWinGraphicsPipe::get_class_type().get_index(); return TinyWinGraphicsPipe::get_class_type().get_index();
#endif #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(); return TinyOsxGraphicsPipe::get_class_type().get_index();
#endif #endif

View File

@ -14,7 +14,7 @@
#include "pandabase.h" #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 "tinyOsxGraphicsPipe.h"
#include "config_tinydisplay.h" #include "config_tinydisplay.h"

View File

@ -17,7 +17,7 @@
#include "pandabase.h" #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 // We have to include this early, before anyone includes
// netinet/tcp.h, which will define TCP_NODELAY and other symbols and // netinet/tcp.h, which will define TCP_NODELAY and other symbols and

View File

@ -17,7 +17,7 @@
#include "pandabase.h" #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 <Carbon/Carbon.h>

View File

@ -11,7 +11,7 @@
#include "pandabase.h" #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 <Carbon/Carbon.h>
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>