Simplify OpenCL compile-time detection on OS X.

Turn wiiuse io_osx.m into Objective-C++.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6398 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-11-13 20:02:01 +00:00
parent a913295d70
commit 02edf66b49
15 changed files with 32 additions and 95 deletions

View File

@ -285,7 +285,6 @@ if(NOT APPLE)
include_directories(Externals/CLRun/include)
add_subdirectory(Externals/CLRun)
add_definitions(-DUSE_CLRUN)
add_definitions(-DHAVE_OPENCL=1)
endif(NOT APPLE)
set(DISABLE_WX FALSE CACHE BOOL "Disable wxWidgets (use CLI interface)")

View File

@ -122,8 +122,11 @@ rev = utils.GenerateRevFile(env['flavor'], '.', None)
if sys.platform == 'darwin':
ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5']
ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk']
system = '/System/Library/Frameworks'
env['CCFLAGS'] += ccld
env['CCFLAGS'] += ['-msse3']
env['CCFLAGS'] += ['-iframework/Developer/SDKs/MacOSX10.5.sdk' + system]
env['CCFLAGS'] += ['-iframework/Developer/SDKs/MacOSX10.6.sdk' + system]
env['CC'] = "gcc-4.2 -ObjC"
env['CXX'] = "g++-4.2 -ObjC++"
env['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices']
@ -132,19 +135,10 @@ if sys.platform == 'darwin':
env['LIBPATH'] += ['/usr/lib']
env['LIBS'] = ['iconv', 'SDL']
env['LINKFLAGS'] += ccld
env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z']
env['LINKFLAGS'] += ['-F/System/Library/Frameworks']
env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z', '-F' + system]
if platform.mac_ver()[0] < '10.6.0':
env['HAVE_OPENCL'] = 0
else:
if platform.mac_ver()[0] >= '10.6.0':
env['CCFLAGS'] += ['-Wextra-tokens', '-Wnewline-eof']
env['CCFLAGS'] += ['-iframework' +
'/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks']
env['CCFLAGS'] += ['-iframework' +
'/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks']
env['CPPDEFINES'] += [('HAVE_OPENCL', 1)]
env['HAVE_OPENCL'] = 1
env['FRAMEWORKSFLAGS'] = ['-weak_framework', 'OpenCL']
if env['nowx']:
@ -187,14 +181,15 @@ elif sys.platform == 'win32':
pass
else:
env['CCFLAGS'] += ['-fPIC', '-msse2']
env['CCFLAGS'] += ['-fPIC', '-msse2', '-pthread']
env['CPPDEFINES'] += ['HAVE_CONFIG_H']
env['CPPPATH'].insert(0, '#') # Make sure we pick up our own config.h
env['LINKFLAGS'] += ['-pthread']
env['RPATH'] = []
if sys.platform == 'linux2':
env['CPPDEFINES'] += [('_FILE_OFFSET_BITS', 64), '_LARGEFILE_SOURCE']
env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX <hash_map>
env['LINKFLAGS'] += ['-pthread', '-ldl']
env['RPATH'] = []
env['LIBS'] += ['dl']
conf = env.Configure(config_h = "#config.h", custom_tests = {
'CheckPKG' : utils.CheckPKG,

View File

@ -26,10 +26,17 @@
#define HAVE_OPENCL 1
#endif
// We detect the presence of the 10.6 SDK, which has the OpenCL headers,
// by looking for the new blocks feature in the 10.6 version of gcc.
// This allows us to have the 10.5 SDK first in the search path.
#if defined __APPLE__ && defined __BLOCKS__
#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE
#define HAVE_OPENCL 1
#endif
#if defined(HAVE_OPENCL) && HAVE_OPENCL
#ifdef __APPLE__
#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>

View File

@ -33,7 +33,7 @@
#include "Frame.h"
#include "HotkeyDlg.h"
#include "../../Common/Src/OpenCL.h"
#include "OpenCL.h"
#ifdef __APPLE__
#include <ApplicationServices/ApplicationServices.h>

View File

@ -211,7 +211,7 @@ void Init(std::vector<ControllerInterface::Device*>& devices)
// Wait while current devices are initialized
while (CFRunLoopRunInMode(OurRunLoop, 0, TRUE) ==
kCFRunLoopRunHandledSource);
kCFRunLoopRunHandledSource) {};
// Things should be configured now
// Disable hotplugging and other scheduling

View File

@ -31,11 +31,8 @@ set(SRCS Src/BPMemory.cpp
Src/VideoState.cpp
Src/XFBConvert.cpp
Src/XFMemory.cpp
Src/XFStructs.cpp)
if(NOT APPLE)
set(SRCS ${SRCS} Src/OpenCL/OCLTextureDecoder.cpp)
endif(NOT APPLE)
Src/XFStructs.cpp
Src/OpenCL/OCLTextureDecoder.cpp)
add_library(videocommon STATIC ${SRCS})
if(UNIX)

View File

@ -38,11 +38,7 @@ files = [
'OnScreenDisplay.cpp',
'HiresTextures.cpp',
'DLCache.cpp',
'OpenCL/OCLTextureDecoder.cpp',
]
if env['HAVE_OPENCL']:
files += [
'OpenCL/OCLTextureDecoder.cpp',
]
env.StaticLibrary(env['local_libs'] + "videocommon", files)

View File

@ -9,7 +9,7 @@ files = [
]
if sys.platform == 'darwin':
files += [ "io_osx.m" ]
files += [ "io_osx.mm" ]
elif sys.platform == 'linux2' and env['HAVE_BLUEZ']:
files += [ "io_nix.cpp" ]
elif sys.platform == 'win32':
@ -18,4 +18,3 @@ else:
files += [ "io_dummy.cpp" ]
env.StaticLibrary(env['local_libs'] + "wiiuse", files)
env['CPPPATH'] += ['#Source/Core/wiiuse/Src']

View File

@ -1,53 +0,0 @@
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* This file is part of wiiuse.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief General definitions.
*/
#ifndef DEFINITIONS_H_INCLUDED
#define DEFINITIONS_H_INCLUDED
#include <Common.h>
#ifndef _WIN32
#include <arpa/inet.h> /* htons() */
#else
/* disable warnings I don't care about */
#pragma warning(disable:4244) /* possible loss of data conversion */
#pragma warning(disable:4273) /* inconsistent dll linkage */
#pragma warning(disable:4217)
#endif // _WIN32
/* Convert to big endian */
#define BIG_ENDIAN_LONG(i) (htonl(i))
#define BIG_ENDIAN_SHORT(i) (htons(i))
#endif // DEFINITIONS_H_INCLUDED

View File

@ -1,4 +1,4 @@
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout)

View File

@ -39,7 +39,7 @@
#include <bluetooth/hci_lib.h>
#include <bluetooth/l2cap.h>
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
static int wiiuse_connect_single(struct wiimote_t* wm, char* address);

View File

@ -32,14 +32,14 @@
*/
#import <CoreServices/CoreServices.h>
extern OSErr UpdateSystemActivity(UInt8 activity);
extern "C" OSErr UpdateSystemActivity(UInt8 activity);
#define BLUETOOTH_VERSION_USE_CURRENT
#import <IOBluetooth/objc/IOBluetoothDevice.h>
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
#import <IOBluetooth/objc/IOBluetoothHostController.h>
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h>
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
static int wiiuse_connect_single(struct wiimote_t *wm, char *address);
@ -49,7 +49,7 @@ IOBluetoothL2CAPChannel *ichan;
IOBluetoothL2CAPChannel *cchan;
#define QUEUE_SIZE 64
volatile struct buffer {
struct buffer {
char data[MAX_PAYLOAD];
int len;
} queue[QUEUE_SIZE];

View File

@ -40,11 +40,9 @@
#include <dbt.h>
#include <setupapi.h>
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
#include <Common.h>
typedef struct _HIDD_ATTRIBUTES {
ULONG Size;
USHORT VendorID;

View File

@ -38,7 +38,7 @@
#include <unistd.h>
#endif
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
static int get_ir_sens(struct wiimote_t* wm, const char** block1, const char** block2);

View File

@ -45,10 +45,9 @@
#include <Winsock2.h>
#endif
#include "definitions.h"
#include "Common.h"
#include "wiiuse_internal.h"
static int g_banner = 1;
/**
@ -301,7 +300,7 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte
#endif
/* the offset is in big endian */
*(int*)(buf) = BIG_ENDIAN_LONG(addr);
*(int*)(buf) = Common::swap32(addr); /* XXX only if little-endian */
/* length */
*(byte*)(buf + 4) = len;