From 8076ad6df75cc3b9c627f64a85f0511fb55f9a95 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 21 Jul 2013 14:43:36 -0700 Subject: [PATCH] Added iOS simulator configuration. --- include/bx/debug.h | 13 +++++++++++++ include/bx/macros.h | 11 +++++++++-- include/bx/readerwriter.h | 2 +- premake/toolchain.lua | 37 +++++++++++++++++++++++++++++++++---- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/include/bx/debug.h b/include/bx/debug.h index cb4d4b2..9f15854 100644 --- a/include/bx/debug.h +++ b/include/bx/debug.h @@ -12,6 +12,13 @@ # include #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); +#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX +# if defined(__OBJC__) +# import +# else +# include +extern "C" void NSLog(CFStringRef _format, ...); +# endif // defined(__OBJC__) #else # include #endif // BX_PLATFORM_WINDOWS @@ -40,6 +47,12 @@ namespace bx __android_log_write(ANDROID_LOG_DEBUG, "", _out); #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 OutputDebugStringA(_out); +#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX +# if defined(__OBJC__) + NSLog(@"%s", _out); +# else + NSLog(__CFStringMakeConstantString("%s"), _out); +# endif // defined(__OBJC__) #else fputs(_out, stderr); fflush(stderr); diff --git a/include/bx/macros.h b/include/bx/macros.h index 237b7e0..76f150e 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -41,7 +41,7 @@ # define BX_OVERRIDE # define BX_PRINTF_ARGS(_format, _args) __attribute__ ( (format(__printf__, _format, _args) ) ) # define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, __VA_ARGS__) -# if BX_COMPILER_CLANG +# if BX_COMPILER_CLANG || BX_PLATFORM_IOS # define BX_THREAD /* not supported right now */ # else # define BX_THREAD __thread @@ -103,7 +103,14 @@ #endif // BX_CONFIG_SPSCQUEUE_USE_MUTEX #ifndef BX_CONFIG_CRT_FILE_READER_WRITER -# define BX_CONFIG_CRT_FILE_READER_WRITER (BX_PLATFORM_ANDROID|BX_PLATFORM_LINUX|BX_PLATFORM_OSX|BX_PLATFORM_QNX|BX_PLATFORM_WINDOWS) +# define BX_CONFIG_CRT_FILE_READER_WRITER (0 \ + |BX_PLATFORM_ANDROID \ + |BX_PLATFORM_IOS \ + |BX_PLATFORM_LINUX \ + |BX_PLATFORM_OSX \ + |BX_PLATFORM_QNX \ + |BX_PLATFORM_WINDOWS \ + ) #endif // BX_CONFIG_CRT_FILE_READER_WRITER #ifndef BX_CONFIG_SEMAPHORE_PTHREAD diff --git a/include/bx/readerwriter.h b/include/bx/readerwriter.h index 532387f..fd75a1b 100644 --- a/include/bx/readerwriter.h +++ b/include/bx/readerwriter.h @@ -15,7 +15,7 @@ #if BX_COMPILER_MSVC # define fseeko64 _fseeki64 # define ftello64 _ftelli64 -#elif BX_PLATFORM_ANDROID|BX_PLATFORM_OSX|BX_PLATFORM_QNX +#elif BX_PLATFORM_ANDROID|BX_PLATFORM_IOS|BX_PLATFORM_OSX|BX_PLATFORM_QNX # define fseeko64 fseeko # define ftello64 ftello #endif // BX_ diff --git a/premake/toolchain.lua b/premake/toolchain.lua index a89aa75..60545e9 100755 --- a/premake/toolchain.lua +++ b/premake/toolchain.lua @@ -20,7 +20,8 @@ function toolchain(_buildDir, _libDir) { "nacl-arm", "Native Client - ARM" }, { "pnacl", "Native Client - PNaCl" }, { "osx", "OSX" }, - { "ios", "iOS" }, + { "ios-arm", "iOS - ARM" }, + { "ios-simulator", "iOS - Simulator" }, { "qnx-arm", "QNX/Blackberry - ARM" }, } } @@ -120,11 +121,18 @@ function toolchain(_buildDir, _libDir) location (_buildDir .. "projects/" .. _ACTION .. "-osx") end - if "ios" == _OPTIONS["gcc"] then + if "ios-arm" == _OPTIONS["gcc"] then premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2" premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2" premake.gcc.ar = "ar" - location (_buildDir .. "projects/" .. _ACTION .. "-ios") + location (_buildDir .. "projects/" .. _ACTION .. "-ios-arm") + end + + if "ios-simulator" == _OPTIONS["gcc"] then + premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/i686-apple-darwin11-llvm-gcc-4.2" + premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/i686-apple-darwin11-llvm-g++-4.2" + premake.gcc.ar = "ar" + location (_buildDir .. "projects/" .. _ACTION .. "-ios-simulator") end if "qnx-arm" == _OPTIONS["gcc"] then @@ -428,7 +436,7 @@ function toolchain(_buildDir, _libDir) } includedirs { bxDir .. "include/compat/osx" } - configuration { "ios" } + configuration { "ios-arm" } targetdir (_buildDir .. "ios-arm" .. "/bin") objdir (_buildDir .. "ios-arm" .. "/obj") libdirs { _libDir .. "lib/ios-arm" } @@ -451,6 +459,27 @@ function toolchain(_buildDir, _libDir) } includedirs { bxDir .. "include/compat/osx" } + configuration { "ios-simulator" } + targetdir (_buildDir .. "ios-simulator" .. "/bin") + objdir (_buildDir .. "ios-simulator" .. "/obj") + libdirs { _libDir .. "lib/ios-simulator" } + linkoptions { + "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk", + "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/usr/lib/system", + "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks", + "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/PrivateFrameworks", + } + buildoptions { + "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk", + "-miphoneos-version-min=3.0.0", + "-fobjc-abi-version=2", + "-fobjc-legacy-dispatch", + "-U__STRICT_ANSI__", + "-Wfatal-errors", + "-Wunused-value", + } + includedirs { bxDir .. "include/compat/osx" } + configuration { "qnx-arm" } targetdir (_buildDir .. "qnx-arm" .. "/bin") objdir (_buildDir .. "qnx-arm" .. "/obj")