From 5827959056d8722209e5601f4bf42ec153a05e80 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 29 Mar 2015 22:06:32 +0200 Subject: [PATCH] Fixes for 64-bit OS X build on newer OS X versions --- direct/src/p3d/Packager.py | 28 ++++++++++++------- direct/src/p3d/ppackage.py | 4 +-- direct/src/plugin_installer/make_installer.py | 13 +++++++-- direct/src/showutil/FreezeTool.py | 2 +- makepanda/makepanda.py | 3 ++ panda/src/display/subprocessWindowBuffer.cxx | 1 + panda/src/tinydisplay/config_tinydisplay.cxx | 4 +-- panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx | 2 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.h | 2 +- panda/src/tinydisplay/tinyOsxGraphicsWindow.h | 2 +- .../src/tinydisplay/tinyOsxGraphicsWindow.mm | 2 +- 11 files changed, 41 insertions(+), 22 deletions(-) diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py index 8b8a0733c2..a25f1df0ae 100644 --- a/direct/src/p3d/Packager.py +++ b/direct/src/p3d/Packager.py @@ -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: diff --git a/direct/src/p3d/ppackage.py b/direct/src/p3d/ppackage.py index f0369ada92..36be497a9f 100755 --- a/direct/src/p3d/ppackage.py +++ b/direct/src/p3d/ppackage.py @@ -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()] diff --git a/direct/src/plugin_installer/make_installer.py b/direct/src/plugin_installer/make_installer.py index 4a4a73ccd1..7767ca425a 100755 --- a/direct/src/plugin_installer/make_installer.py +++ b/direct/src/plugin_installer/make_installer.py @@ -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 "" diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index f5384024c9..28c622a9be 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -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" diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0ef8776e94..628635b679 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -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\"" diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index 4936c03698..fa31624daf 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include using namespace std; diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index eea1101acd..73dac78e0e 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -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 diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index 45122a4e13..1c8d672479 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -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" diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h index 18db9f946e..04900c366c 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h @@ -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 diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h index 660422dbd0..459ed0eee7 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h @@ -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 diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index baf237dab9..876de6450d 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -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 #include