From a6b6103b87091c9528307d2025551c02833fad25 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Sun, 6 Feb 2022 16:38:21 -0500 Subject: [PATCH 1/7] Enable LuaJIT on macOS. --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c59eaa6d..9251797f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,12 +48,16 @@ else() set(LOVE_TARGET_PLATFORM x86) endif() -option(LOVE_JIT "Use LuaJIT" TRUE) +if(APPLE) + option(LOVE_JIT "Use LuaJIT" FALSE) +else() + option(LOVE_JIT "Use LuaJIT" TRUE) +endif() option(LOVE_MPG123 "Use mpg123" TRUE) if(LOVE_JIT) if(APPLE) - message(FATAL_ERROR "JIT not supported yet on Mac. Please use -DLOVE_JIT=0.") + message(WARNING "JIT not supported yet on Mac.") endif() message(STATUS "LuaJIT: Enabled") else() From 440bbeb9b3195000f215e23e2721f5ad3ffad54e Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Sun, 6 Feb 2022 16:38:47 -0500 Subject: [PATCH 2/7] Link to system frameworks. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9251797f8..b461e8ebd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,6 +321,9 @@ if (APPLE) set(LOVE_SRC_COMMON ${LOVE_SRC_COMMON} src/common/macosx.mm ) + set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} objc) + set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework CoreFoundation") + set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework AppKit") endif() source_group("common" FILES ${LOVE_SRC_COMMON}) @@ -1612,6 +1615,7 @@ if(APPLE) set(LOVE_SRC_3P_PHYSFS ${LOVE_SRC_3P_PHYSFS} src/libraries/physfs/physfs_platform_apple.m ) + set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} "-framework IOKit") endif() add_library(love_3p_physfs ${LOVE_SRC_3P_PHYSFS}) From b822b9cbe7807a3cd2f1de842ae0cd4fd1f45caa Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Sun, 6 Feb 2022 17:06:37 -0500 Subject: [PATCH 3/7] Prepend LOVE_INCLUDE_DIRS rather than append. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b461e8ebd..82b1c7883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1735,6 +1735,7 @@ set(LOVE_LIB_SRC ) include_directories( + BEFORE src src/libraries src/modules From 0d744192593a63c9d2d209d83a60111afc4b835f Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 13 Feb 2022 16:11:58 -0400 Subject: [PATCH 4/7] cmake: add warning about use on macOS --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82b1c7883..a4ccb5409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) set (CMAKE_CXX_STANDARD 11) +if(APPLE) + message(WARNING "CMake is not an officially supported build system for love on Apple platforms.") + message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.") +endif() + if(MSVC) set(LOVE_CONSOLE_EXE_NAME lovec) endif() From 09725dd3b94d0eb12deabbdd2b65c099dcebd602 Mon Sep 17 00:00:00 2001 From: Yan Date: Sun, 13 Mar 2022 00:26:04 +0800 Subject: [PATCH 5/7] Windows: Fix compile error: cast from 'HINSTANCE' to 'int' loses precision --- src/modules/system/System.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/system/System.cpp b/src/modules/system/System.cpp index 981dcff41..e1de16d5d 100644 --- a/src/modules/system/System.cpp +++ b/src/modules/system/System.cpp @@ -164,7 +164,7 @@ bool System::openURL(const std::string &url) const #endif - return (int) result > 32; + return (ptrdiff_t) result > 32; #endif } From e512eff37b3e7bdf5a6444a4fc10b6f591a5edce Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 15 Apr 2022 23:31:57 -0300 Subject: [PATCH 6/7] Fix love.threaderror when the error message is empty. Fixes #1775 --- src/modules/thread/LuaThread.cpp | 19 +++++++++++++++---- src/modules/thread/LuaThread.h | 2 ++ src/modules/thread/wrap_LuaThread.cpp | 7 +++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/modules/thread/LuaThread.cpp b/src/modules/thread/LuaThread.cpp index 05e6c2770..d052d31c5 100644 --- a/src/modules/thread/LuaThread.cpp +++ b/src/modules/thread/LuaThread.cpp @@ -36,6 +36,7 @@ love::Type LuaThread::type("Thread", &Threadable::type); LuaThread::LuaThread(const std::string &name, love::Data *code) : code(code) , name(name) + , haserror(false) { threadName = name; } @@ -47,6 +48,7 @@ LuaThread::~LuaThread() void LuaThread::threadFunction() { error.clear(); + haserror = false; lua_State *L = luaL_newstate(); luaL_openlibs(L); @@ -70,7 +72,10 @@ void LuaThread::threadFunction() int tracebackidx = lua_gettop(L); if (luaL_loadbuffer(L, (const char *) code->getData(), code->getSize(), name.c_str()) != 0) + { error = luax_tostring(L, -1); + haserror = true; + } else { int pushedargs = (int) args.size(); @@ -81,18 +86,27 @@ void LuaThread::threadFunction() args.clear(); if (lua_pcall(L, pushedargs, 0, tracebackidx) != 0) + { error = luax_tostring(L, -1); + haserror = true; + } } lua_close(L); - if (!error.empty()) + if (haserror) onError(); } bool LuaThread::start(const std::vector &args) { + if (isRunning()) + return false; + this->args = args; + error.clear(); + haserror = false; + return Threadable::start(); } @@ -103,9 +117,6 @@ const std::string &LuaThread::getError() const void LuaThread::onError() { - if (error.empty()) - return; - auto eventmodule = Module::getInstance(Module::M_EVENT); if (!eventmodule) return; diff --git a/src/modules/thread/LuaThread.h b/src/modules/thread/LuaThread.h index e8d625cb7..9e707b784 100644 --- a/src/modules/thread/LuaThread.h +++ b/src/modules/thread/LuaThread.h @@ -46,6 +46,7 @@ public: virtual ~LuaThread(); void threadFunction(); const std::string &getError() const; + bool hasError() const { return haserror; } bool start(const std::vector &args); @@ -56,6 +57,7 @@ private: StrongRef code; std::string name; std::string error; + bool haserror; std::vector args; diff --git a/src/modules/thread/wrap_LuaThread.cpp b/src/modules/thread/wrap_LuaThread.cpp index db71f9ca1..5d569710d 100644 --- a/src/modules/thread/wrap_LuaThread.cpp +++ b/src/modules/thread/wrap_LuaThread.cpp @@ -63,11 +63,10 @@ int w_Thread_wait(lua_State *L) int w_Thread_getError(lua_State *L) { LuaThread *t = luax_checkthread(L, 1); - std::string err = t->getError(); - if (err.empty()) - lua_pushnil(L); + if (t->hasError()) + luax_pushstring(L, t->getError()); else - luax_pushstring(L, err); + lua_pushnil(L); return 1; } From b3b1317f6184b2fb6c7d78cb7338f9c83ebb4abd Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 15 Apr 2022 23:43:30 -0300 Subject: [PATCH 7/7] linux: fix issues if certain codepaths are hit while signal handlers are temporarily off. --- src/modules/audio/openal/Audio.cpp | 38 ++++++++++++++---------------- src/modules/thread/sdl/Thread.cpp | 5 +--- src/modules/thread/threads.h | 6 +++++ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/modules/audio/openal/Audio.cpp b/src/modules/audio/openal/Audio.cpp index 3f8193f2c..68645e351 100644 --- a/src/modules/audio/openal/Audio.cpp +++ b/src/modules/audio/openal/Audio.cpp @@ -100,11 +100,6 @@ Audio::Audio() , poolThread(nullptr) , distanceModel(DISTANCE_INVERSE_CLAMPED) { -#if defined(LOVE_LINUX) - // Temporarly block signals, as the thread inherits this mask - love::thread::disableSignals(); -#endif - // Before opening new device, check if recording // is requested. if (getRequestRecordingPermission()) @@ -114,29 +109,32 @@ Audio::Audio() requestRecordingPermission(); } - // Passing null for default device. - device = alcOpenDevice(nullptr); + { +#if defined(LOVE_LINUX) + // Temporarly block signals, as the thread inherits this mask + love::thread::ScopedDisableSignals disableSignals; +#endif - if (device == nullptr) - throw love::Exception("Could not open device."); + // Passing null for default device. + device = alcOpenDevice(nullptr); + + if (device == nullptr) + throw love::Exception("Could not open device."); #ifdef ALC_EXT_EFX - ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 }; + ALint attribs[4] = { ALC_MAX_AUXILIARY_SENDS, MAX_SOURCE_EFFECTS, 0, 0 }; #else - ALint *attribs = nullptr; + ALint *attribs = nullptr; #endif - context = alcCreateContext(device, attribs); + context = alcCreateContext(device, attribs); - if (context == nullptr) - throw love::Exception("Could not create context."); + if (context == nullptr) + throw love::Exception("Could not create context."); - if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR) - throw love::Exception("Could not make context current."); - -#if defined(LOVE_LINUX) - love::thread::reenableSignals(); -#endif + if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR) + throw love::Exception("Could not make context current."); + } #ifdef ALC_EXT_EFX initializeEFX(); diff --git a/src/modules/thread/sdl/Thread.cpp b/src/modules/thread/sdl/Thread.cpp index cfc63e31f..71f28e4ac 100644 --- a/src/modules/thread/sdl/Thread.cpp +++ b/src/modules/thread/sdl/Thread.cpp @@ -44,7 +44,7 @@ bool Thread::start() { #if defined(LOVE_LINUX) // Temporarly block signals, as the thread inherits this mask - love::thread::disableSignals(); + love::thread::ScopedDisableSignals disableSignals; #endif Lock l(mutex); @@ -55,9 +55,6 @@ bool Thread::start() thread = SDL_CreateThread(thread_runner, t->getThreadName(), this); running = (thread != nullptr); -#if defined(LOVE_LINUX) - love::thread::reenableSignals(); -#endif return running; } diff --git a/src/modules/thread/threads.h b/src/modules/thread/threads.h index 5f607bade..827ca8586 100644 --- a/src/modules/thread/threads.h +++ b/src/modules/thread/threads.h @@ -132,6 +132,12 @@ Thread *newThread(Threadable *t); #if defined(LOVE_LINUX) void disableSignals(); void reenableSignals(); + +struct ScopedDisableSignals +{ + ScopedDisableSignals() { disableSignals(); } + ~ScopedDisableSignals() { reenableSignals(); } +}; #endif } // thread