Fix various Mac OS X bugs and build issues

This commit is contained in:
rdb 2015-03-25 19:43:21 +01:00
parent ea7144e87d
commit f624cdcac0
9 changed files with 66 additions and 26 deletions

View File

@ -60,7 +60,7 @@ extern char **environ;
#include <sys/sysctl.h>
#endif
#if defined(IS_LINUX) || defined(IS_OSX) || defined(IS_FREEBSD)
#if defined(IS_LINUX) || defined(IS_FREEBSD)
// For link_map and dlinfo.
#include <link.h>
#include <dlfcn.h>

View File

@ -139,8 +139,8 @@ def usage(problem):
print(" --outputdir X (use the specified directory instead of 'built')")
print(" --host URL (set the host url (runtime build only))")
print(" --threads N (use the multithreaded build system. see manual)")
print(" --osxtarget N (the OSX version number to build for (OSX only))")
print(" --universal (build universal binaries (OSX only))")
print(" --osxtarget N (the OS X version number to build for (OS X only))")
print(" --universal (build universal binaries (OS X only))")
print(" --override \"O=V\" (override dtool_config/prc option value)")
print(" --static (builds libraries for static linking)")
print(" --target X (experimental cross-compilation (android only))")
@ -261,6 +261,13 @@ def parseopts(args):
OSXTARGET = "10.%d" % (int(OSXTARGET[-1]))
except:
usage("Invalid setting for OSXTARGET")
if UNIVERSAL:
if not OSXTARGET:
exit("--universal requires --osxtarget")
if target_arch:
exit("--universal is incompatible with --arch")
try:
SetOptimize(int(optimize))
assert GetOptimize() in [1, 2, 3, 4]
@ -670,7 +677,7 @@ if (COMPILER=="GCC"):
elif (RTDIST or RUNTIME):
# We don't support Cocoa in the runtime yet.
PkgDisable("COCOA")
elif (not UNIVERSAL and GetTargetArch() == 'x86_64'):
elif (UNIVERSAL or GetTargetArch() == 'x86_64'):
# 64-bits OS X doesn't have Carbon.
PkgDisable("CARBON")
@ -1084,10 +1091,15 @@ def CompileCxx(obj,src,opts):
if (OSXTARGET != None):
cmd += " -isysroot " + SDK["MACOSX"]
cmd += " -mmacosx-version-min=" + OSXTARGET
if UNIVERSAL:
cmd += " -arch i386"
if ("NOPPC" not in opts):
cmd += " -arch ppc"
if OSXTARGET:
osxver = int(OSXTARGET[-1])
if "NOPPC" not in opts and int(OSXTARGET[-1]) < 6:
cmd += " -arch ppc"
if int(OSXTARGET[-1]) >= 5:
cmd += " -arch x86_64"
elif HasTargetArch():
cmd += " -arch %s" % (GetTargetArch())
@ -1539,10 +1551,15 @@ def CompileLink(dll, obj, opts):
if OSXTARGET != None:
cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"]
cmd += " -mmacosx-version-min=" + OSXTARGET
if UNIVERSAL:
cmd += " -arch i386"
if ("NOPPC" not in opts):
cmd += " -arch ppc"
if OSXTARGET:
osxver = int(OSXTARGET[-1])
if "NOPPC" not in opts and int(OSXTARGET[-1]) < 6:
cmd += " -arch ppc"
if int(OSXTARGET[-1]) >= 5:
cmd += " -arch x86_64"
elif HasTargetArch():
cmd += " -arch %s" % (GetTargetArch())
@ -6621,10 +6638,15 @@ def MakeInstallerOSX():
if not os.path.isdir("dstroot/" + pkg):
os.makedirs("dstroot/" + pkg)
if OSXTARGET:
target = '--target %s' % (OSXTARGET)
else:
target = ''
if os.path.exists("/Developer/usr/bin/packagemaker"):
cmd = '/Developer/usr/bin/packagemaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target 10.4 --domain system --root dstroot/' + pkg + '/ --no-relocate'
cmd = '/Developer/usr/bin/packagemaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate'
elif os.path.exists("/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"):
cmd = '/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target 10.4 --domain system --root dstroot/' + pkg + '/ --no-relocate'
cmd = '/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate'
elif os.path.exists("/Developer/Tools/packagemaker"):
cmd = '/Developer/Tools/packagemaker -build -f dstroot/' + pkg + '/ -p dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg -i /tmp/Info_plist'
else:

View File

@ -343,7 +343,7 @@ make_output(const string &name,
if (!cocoagsg->_supports_framebuffer_object ||
cocoagsg->_glDrawBuffers == NULL) {
return NULL;
} else {
} else if (fb_prop.is_basic()) {
// Early success - if we are sure that this buffer WILL
// meet specs, we can precertify it.
precertify = true;

View File

@ -1592,7 +1592,8 @@ handle_key_event(NSEvent *event) {
if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) {
// Nhm, ascii character perhaps?
str = [str lowercaseString];
button = KeyboardButton::ascii_key([str cStringUsingEncoding: NSASCIIStringEncoding]);
const char *c_str = [str cStringUsingEncoding: NSASCIIStringEncoding];
button = KeyboardButton::ascii_key(c_str[0]);
}
}

View File

@ -17,8 +17,11 @@
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "configVariableBool.h"
NotifyCategoryDecl(cocoadisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
extern ConfigVariableBool gl_support_fbo;
extern EXPCL_PANDAGL void init_libcocoadisplay();

View File

@ -27,6 +27,12 @@ ConfigureFn(config_cocoadisplay) {
init_libcocoadisplay();
}
ConfigVariableBool gl_support_fbo
("gl-support-fbo", true,
PRC_DESC("Configure this false if your GL's implementation of "
"EXT_framebuffer_object is broken. The system might still be "
"able to create buffers using pbuffers or the like."));
////////////////////////////////////////////////////////////////////
// Function: init_libcocoadisplay
// Description: Initializes the library. This must be called at

View File

@ -433,7 +433,7 @@ make_output(const string &name,
if (!posixgsg->_supports_framebuffer_object ||
posixgsg->_glDrawBuffers == NULL) {
return NULL;
} else {
} else if (fb_prop.is_basic()) {
// Early success - if we are sure that this buffer WILL
// meet specs, we can precertify it.
precertify = true;

View File

@ -14,17 +14,6 @@
#include "convert_srgb.h"
#ifdef __GNUC__
#include <cpuid.h>
#endif
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
// Lookup tables for converting from unsigned char formats.
ALIGN_64BYTE const
unsigned char to_srgb8_table[256] = { 0x00, 0x0d, 0x16, 0x1c, 0x22, 0x26, 0x2a,
@ -119,9 +108,20 @@ has_sse2_sRGB_encode() {
return true;
}
#else
#elif defined(__i386__) || defined(_M_IX86)
// SSE2 support not guaranteed. Use a runtime detection mechanism.
#ifdef __GNUC__
#include <cpuid.h>
#endif
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
bool
has_sse2_sRGB_encode() {
#if defined(__GNUC__)
@ -162,4 +162,12 @@ has_sse2_sRGB_encode() {
return has_support;
}
#else
// Other architectures don't support SSE2 at all.
bool
has_sse2_sRGB_encode() {
return false;
}
#endif // __SSE2__

View File

@ -1192,7 +1192,7 @@ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, E
if (keyDown) {
if ((newModifiers & cmdKey) != 0) {
if (button == KeyboardButton::ascii_key("q") || button == KeyboardButton::ascii_key("w")) {
if (button == KeyboardButton::ascii_key('q') || button == KeyboardButton::ascii_key('w')) {
// Command-Q or Command-W: quit the application or close the
// window, respectively. For now, we treat them both the
// same: close the window.