Mac fixes (#1776)
* macOS build fixes (#1773) * macOS build fixes Add missing headers Threads_Pthreads: do not call pthread_setname_np() on macOS as it does not do the same as on Linux DebugStr() -> os_log() * Make the project build with Makefiles on macOS * Fix getting modifier key state on Mac (#1774) We really need to clean up all Carbon calls here (many will go away when the project switches to SDL2 for all platforms) * Fix Xcode build; bump minimum version of macOS (#1775) * Build fixes for the "Unix Makefiles" generator Pass CMAKE_BUILD_TYPE to the external projects * Fix indent
This commit is contained in:
@@ -183,6 +183,7 @@ if(WIN32)
|
||||
)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -stdlib=libc++ -DMACOSX")
|
||||
set_target_properties("${SM_EXE_NAME}" PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${SM_ROOT_DIR}"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${SM_ROOT_DIR}"
|
||||
@@ -430,6 +431,14 @@ elseif(APPLE)
|
||||
"pcre"
|
||||
)
|
||||
|
||||
if (HAS_OGG)
|
||||
list(APPEND SMDATA_LINK_LIB
|
||||
"${SM_OGG_ROOT}/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>/libogg.a"
|
||||
"${SM_VORBIS_ROOT}/lib/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>/libvorbis.a"
|
||||
"${SM_VORBIS_ROOT}/lib/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>/libvorbisfile.a"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HAS_FFMPEG)
|
||||
list(APPEND SMDATA_LINK_LIB
|
||||
"${SM_FFMPEG_ROOT}/libavformat/libavformat.a"
|
||||
@@ -518,6 +527,11 @@ else() # Unix / Linux
|
||||
list(APPEND SMDATA_LINK_LIB ${X11_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(SDL2_FOUND)
|
||||
list(APPEND SMDATA_LINK_LIB ${SDL2_LIBRARY})
|
||||
sm_add_compile_definition("${SM_EXE_NAME}" HAVE_SDL)
|
||||
endif()
|
||||
|
||||
if(PCRE_FOUND)
|
||||
list(APPEND SMDATA_LINK_LIB ${PCRE_LIBRARY})
|
||||
endif()
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifndef RAGE_FILE_BASIC_H
|
||||
#define RAGE_FILE_BASIC_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
/* This is a simple file I/O interface. Although most of these operations
|
||||
* are straightforward, there are several of them; most of the time, you'll
|
||||
* only want to implement RageFileObj. */
|
||||
|
||||
@@ -450,7 +450,9 @@ wchar_t InputHandler_MacOSX_HID::DeviceButtonToChar( DeviceButton button, bool b
|
||||
UInt8 iMacVirtualKey;
|
||||
if( KeyboardDevice::DeviceButtonToMacVirtualKey( button, iMacVirtualKey ) )
|
||||
{
|
||||
UInt32 nModifiers = bUseCurrentKeyModifiers ? GetCurrentKeyModifiers() : 0;
|
||||
CGEventRef event = CGEventCreate(NULL);
|
||||
CGEventFlags mods = CGEventGetFlags(event);
|
||||
UInt32 nModifiers = bUseCurrentKeyModifiers ? (UInt32)mods : 0;
|
||||
wchar_t sCharCode = KeyCodeToChar( iMacVirtualKey, nModifiers );
|
||||
if( sCharCode != 0 )
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef LOADING_WINDOW_H
|
||||
#define LOADING_WINDOW_H
|
||||
|
||||
#include <string>
|
||||
|
||||
struct RageSurface;
|
||||
/** @brief Opens and displays the loading banner. */
|
||||
class LoadingWindow
|
||||
|
||||
@@ -89,6 +89,39 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
thread->m_StartFinishedSem->Wait();
|
||||
delete thread->m_StartFinishedSem;
|
||||
|
||||
// Copy the thread name.
|
||||
const char *rawname = RageThread::GetThreadNameByID( *piThreadID );
|
||||
const size_t maxNameLen = sizeof( thread->name );
|
||||
if (strlen(rawname) < maxNameLen) {
|
||||
// If it fits, I sits^H^H^H^Hcopy.
|
||||
strncpy( thread->name, rawname, maxNameLen );
|
||||
} else {
|
||||
if ( strstr( rawname, "Worker thread" ) && strchr( rawname, '(' ) ) {
|
||||
// Special case for RageUtil_WorkerThread.cpp
|
||||
// "Worker thread (name)", e.g.
|
||||
// "Worker thread (/@mc1int/)" => "(/@mc1int/)".
|
||||
const char *workername = strchr( rawname, '(' );
|
||||
strncpy( thread->name, workername, maxNameLen );
|
||||
} else {
|
||||
// Abbreviate the name by taking the first 6, last 7
|
||||
// characters and adding '..' in the middle.
|
||||
LOG->Trace( "Truncated thread name due to size limit of %d: %s",
|
||||
maxNameLen, rawname );
|
||||
snprintf( thread->name, maxNameLen, "%.6s..%s",
|
||||
rawname, &rawname[strlen(rawname) - 7] );
|
||||
}
|
||||
}
|
||||
// Ensure there is always a terminating NUL character.
|
||||
thread->name[maxNameLen - 1] = '\0';
|
||||
|
||||
#ifndef MACOSX
|
||||
// macOS/BSD can only set the name of the calling thread
|
||||
ret = pthread_setname_np(thread->thread, thread->name);
|
||||
if (ret != 0 && LOG) {
|
||||
LOG->Trace("pthead_setname_np: %s", strerror(ret));
|
||||
}
|
||||
#endif
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
@@ -127,7 +160,7 @@ bool MutexImpl_Pthreads::Lock()
|
||||
|
||||
while( tries-- )
|
||||
{
|
||||
/* Wait for ten seconds. If it takes longer than that, we're
|
||||
/* Wait for ten seconds. If it takes longer than that, we're
|
||||
* probably deadlocked. */
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
@@ -208,11 +241,6 @@ MutexImpl *MakeMutex( RageMutex *pParent )
|
||||
#if defined(UNIX)
|
||||
#include <dlfcn.h>
|
||||
#include "arch/ArchHooks/ArchHooks_Unix.h"
|
||||
// commented out to allow comilation on macOS 10.12. -dguzek
|
||||
//#elif defined(MACOSX)
|
||||
//typedef int clockid_t;
|
||||
//static const clockid_t CLOCK_REALTIME = 0;
|
||||
//static const clockid_t CLOCK_MONOTONIC = 1;
|
||||
#endif // On MinGW clockid_t is defined in pthread.h
|
||||
namespace
|
||||
{
|
||||
@@ -288,7 +316,7 @@ EventImpl_Pthreads::EventImpl_Pthreads( MutexImpl_Pthreads *pParent )
|
||||
m_pParent = pParent;
|
||||
|
||||
InitMonotonic();
|
||||
|
||||
|
||||
pthread_condattr_t condattr;
|
||||
pthread_condattr_init( &condattr );
|
||||
|
||||
@@ -420,7 +448,7 @@ bool SemaImpl_Pthreads::TryWait()
|
||||
int ret = sem_trywait( &sem );
|
||||
if( ret == -1 && errno == EAGAIN )
|
||||
return false;
|
||||
|
||||
|
||||
ASSERT_M( ret == 0, ssprintf("TryWait: sem_trywait failed: %s", strerror(errno)) );
|
||||
|
||||
return true;
|
||||
@@ -433,7 +461,7 @@ SemaImpl_Pthreads::SemaImpl_Pthreads( int iInitialValue )
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_cond_init: %s", strerror(errno)) );
|
||||
ret = pthread_mutex_init( &m_Mutex, NULL );
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_mutex_init: %s", strerror(errno)) );
|
||||
|
||||
|
||||
m_iValue = iInitialValue;
|
||||
}
|
||||
|
||||
@@ -542,7 +570,7 @@ SemaImpl *MakeSemaphore( int iInitialValue )
|
||||
/*
|
||||
* (c) 2001-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -552,7 +580,7 @@ SemaImpl *MakeSemaphore( int iInitialValue )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ProductInfo.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <os/log.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
@@ -97,13 +98,13 @@ bool CrashHandler::IsDebuggerPresent()
|
||||
|
||||
void CrashHandler::DebugBreak()
|
||||
{
|
||||
DebugStr( "\pDebugBreak()" );
|
||||
os_log(OS_LOG_DEFAULT, "DebugBreak()");
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2006 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include <mach/thread_act.h>
|
||||
#include <mach/mach_init.h>
|
||||
#include <mach/mach_error.h>
|
||||
#include "Backtrace.h"
|
||||
#include "global.h"
|
||||
#include "Backtrace.hpp"
|
||||
|
||||
bool SuspendThread( uint64_t threadHandle )
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "ProductInfo.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include "StepMania.h"
|
||||
|
||||
@interface NSApplication (PrivateShutUpWarning)
|
||||
- (void) setAppleMenu:(NSMenu *)menu;
|
||||
|
||||
Reference in New Issue
Block a user