diff --git a/CMakeLists.txt b/CMakeLists.txt index 550d20fef..52390b865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,13 @@ if(APPLE) message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.") endif() -if(MSVC) +if(MINGW) + message(WARNING "MinGW is not an officially supported build system for love.") + message(WARNING "Use megasource with Visual Studio instead.") + message(WARNING "Please see https://github.com/love2d/megasource") +endif() + +if(MSVC OR MINGW) set(LOVE_CONSOLE_EXE_NAME lovec) endif() @@ -178,7 +184,7 @@ Please see https://github.com/love2d/megasource find_package(ModPlug REQUIRED) find_package(OpenAL REQUIRED) find_package(OpenGL REQUIRED) - find_package(SDL2 2.0.9 REQUIRED) + find_package(SDL2 2.0.9 REQUIRED CONFIG COMPONENTS SDL2main) find_package(Theora REQUIRED) find_package(Vorbis REQUIRED) find_package(ZLIB REQUIRED) @@ -188,7 +194,7 @@ Please see https://github.com/love2d/megasource add_definitions(-D HAS_SOCKLEN_T) set(LOVE_INCLUDE_DIRS - ${SDL2_INCLUDE_DIR} + ${SDL2_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${HARFBUZZ_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} @@ -201,7 +207,7 @@ Please see https://github.com/love2d/megasource set(LOVE_LINK_LIBRARIES ${OPENGL_gl_LIBRARY} - ${SDL2_LIBRARY} + ${SDL2_LIBRARIES} ${FREETYPE_LIBRARY} ${HARFBUZZ_LIBRARY} ${OPENAL_LIBRARY} @@ -1298,6 +1304,9 @@ set(LOVE_SRC_3P_ENET add_library(love_3p_enet ${LOVE_SRC_3P_ENET}) target_link_libraries(love_3p_enet ${LOVE_LUA_LIBRARY}) target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include) +if(MINGW) + target_link_libraries(love_3p_enet winmm.a) +endif() # # GLAD @@ -1393,7 +1402,7 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT src/libraries/glslang/glslang/OSDependent/osinclude.h ) -if(MSVC) +if(MSVC OR MINGW) set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT ${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT} src/libraries/glslang/glslang/OSDependent/Windows/main.cpp @@ -1530,7 +1539,13 @@ set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET) -if(MSVC) +if(MINGW) + set(WIN32_LIB_EXT .a) +else() + set(WIN32_LIB_EXT .lib) +endif() + +if(MSVC OR MINGW) set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET ${LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET} src/libraries/luasocket/libluasocket/wsocket.c @@ -1539,7 +1554,7 @@ if(MSVC) set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET ${LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET} - ws2_32.lib + ws2_32${WIN32_LIB_EXT} ) else() set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET @@ -1950,17 +1965,23 @@ link_directories(${LOVE_LINK_DIRS}) set(LOVE_RC) -if(MSVC) +if(MSVC OR MINGW) set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} - ws2_32.lib - winmm.lib - dwmapi.lib + ws2_32${WIN32_LIB_EXT} + winmm${WIN32_LIB_EXT} + dwmapi${WIN32_LIB_EXT} ) set(LOVE_RC extra/windows/love.rc extra/windows/love.ico ) + + if(MINGW) + # UTF-16 flags passed to windres. windres invokes gcc as preprocessor + # -> gcc outputs utf8, so windres must read-in codepage 65001 (utf8) + set(CMAKE_RC_FLAGS ${CMAKE_RC_FLAGS} "-c 65001 --preprocessor-arg=-finput-charset=UTF-16LE") + endif() endif() if(ANDROID) @@ -1992,7 +2013,7 @@ if(NOT ANDROID) target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME}) set_target_properties(${LOVE_EXE_NAME} PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON) - if(MSVC) + if(MSVC OR MINGW) add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC}) target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME}) endif() @@ -2021,7 +2042,7 @@ if(NOT ANDROID) endif() endif() -if (NOT MSVC) +if (NOT MSVC OR MINGW) return() endif() diff --git a/changes.txt b/changes.txt index d5c49c9c9..2115a1d3f 100644 --- a/changes.txt +++ b/changes.txt @@ -147,11 +147,28 @@ LOVE 11.5 [Mysterious Mysteries] Released: N/A +* Added "LÖVE Loader" launcher on Android for easier loading of .love files. + +* Changed iOS game selector to alphabetically sort the list of .love files. +* Changed JIT compilation on macOS arm64 (Apple Silicon) to be off by default, since performance and available JIT memory isn't reliable. + +* Fixed inconsistent and buggy behaviour of 'pairs' by updating LuaJIT. +* Fixed "unexpected alignment" errors when running love on some 32 bit Linux systems. +* Fixed running fused games on Windows when the executable has been code-signed. +* Fixed undefined behaviour in love.data.hash's implementation. +* Fixed writing files when a symlink exists in the save directory's path. * Fixed love.threaderror not being called if the error message is an empty string. * Fixed a race condition when a Thread is destroyed immediately after Thread:start. * Fixed unexpectedly slow first frames on macOS. +* Fixed love.joystick.setGamepadMapping when replacing an existing mapping. +* Fixed love.joystick.getGamepadMappingString. +* Fixed duplicate platform fields in love.joystick.saveGamepadMappings. +* Fixed DistanceJoint type information. * Fixed time drift in Source:tell after a Source loops. * Fixed audio not always pausing when the app is minimized on Android. +* Fixed RecordingDevice:start to return false instead of hard-crashing on iOS. +* Fixed identical frames in Ogg Theora videos being skipped. +* Fixed love.font.newBMFontRasterizer's single file parameter variant. * Fixed the original window size not always being restored when exiting fullscreen on Linux. * Fixed some cases of framerate hitches in Windows when vsync is enabled in windowed mode. * Fixed colors appearing over-saturated on P3 displays in macOS. diff --git a/platform/xcode/ios/luajit-iOS.sh b/platform/xcode/ios/luajit-iOS.sh deleted file mode 100755 index 0533b4138..000000000 --- a/platform/xcode/ios/luajit-iOS.sh +++ /dev/null @@ -1,57 +0,0 @@ -mkdir -p include/luajit -mkdir -p libraries/luajit - -if [ ! -d luajit-git ]; then - git clone https://github.com/LuaJIT/LuaJIT.git luajit-git -fi -cd luajit-git -git pull --no-rebase -git checkout v2.1 - -export MACOSX_DEPLOYMENT_TARGET=10.7 - -# iOS device binaries -# LuaJIT does not support building for armv7 on modern macOS versions. - -ISDKP=$(xcrun --sdk iphoneos --show-sdk-path) -ICC=$(xcrun --sdk iphoneos --find clang) - -ISDKF="-arch arm64 -isysroot $ISDKP -mios-version-min=8.0" -make clean TARGET_SYS=iOS -make -j8 CC="clang" CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS -cp src/libluajit.a ../libraries/luajit/libluajit_arm64_device.a - - -# iOS simulator binaries - -ISDKP=$(xcrun --sdk iphonesimulator --show-sdk-path) -ICC=$(xcrun --sdk iphonesimulator --find clang) - -ISDKF="-arch x86_64 -isysroot $ISDKP -mios-simulator-version-min=8.0" -make clean TARGET_SYS=iOS -make -j8 CC="clang" CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS -cp src/libluajit.a ../libraries/luajit/libluajit_x86_64_sim.a - -ISDKF="-arch arm64 -isysroot $ISDKP -mios-simulator-version-min=8.0" -make clean TARGET_SYS=iOS -make -j8 CC="clang" CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS -cp src/libluajit.a ../libraries/luajit/libluajit_arm64_sim.a - - -# copy includes -cp src/lua.hpp ../include/luajit - -cp src/lauxlib.h ../include/luajit -cp src/lua.h ../include/luajit -cp src/luaconf.h ../include/luajit -cp src/lualib.h ../include/luajit -cp src/luajit.h ../include/luajit - -# combine lib -cd ../libraries/luajit -lipo -create -output libluajit_device.a libluajit_arm64_device.a -lipo -create -output libluajit_sim.a libluajit_x86_64_sim.a libluajit_arm64_sim.a - -# create xcframework with all platforms -rm -rf Lua.xcframework -xcodebuild -create-xcframework -library libluajit_device.a -headers ../../include/luajit -library libluajit_sim.a -headers ../../include/luajit -output Lua.xcframework diff --git a/src/common/android.cpp b/src/common/android.cpp index 12a669b55..266793594 100644 --- a/src/common/android.cpp +++ b/src/common/android.cpp @@ -867,10 +867,9 @@ void *getIOFromFD(int fd) const char *getArg0() { - static PHYSFS_AndroidInit androidInit = { - SDL_AndroidGetJNIEnv(), - SDL_AndroidGetActivity() - }; + static PHYSFS_AndroidInit androidInit = {nullptr, nullptr}; + androidInit.jnienv = SDL_AndroidGetJNIEnv(); + androidInit.context = SDL_AndroidGetActivity(); return (const char *) &androidInit; } diff --git a/src/common/config.h b/src/common/config.h index 3a50dbcd1..7d9d8a4c9 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -102,7 +102,7 @@ #endif // DLL-stuff. -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) # define LOVE_EXPORT __declspec(dllexport) #elif defined(__GNUC__) || defined(__clang__) # define LOVE_EXPORT __attribute__((visibility("default"))) @@ -114,8 +114,10 @@ #ifndef LOVE_WINDOWS_UWP # define LOVE_LEGENDARY_CONSOLE_IO_HACK #endif // LOVE_WINDOWS_UWP +#ifndef __MINGW32__ # define NOMINMAX #endif +#endif #if defined(LOVE_MACOS) || defined(LOVE_IOS) # define LOVE_LEGENDARY_APP_ARGV_HACK diff --git a/src/common/ios.mm b/src/common/ios.mm index f1fc47908..99639a899 100644 --- a/src/common/ios.mm +++ b/src/common/ios.mm @@ -149,6 +149,8 @@ static NSArray *getLovesInDocuments() [paths addObject:path.stringByDeletingLastPathComponent]; } + [paths sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; + return paths; } diff --git a/src/love.cpp b/src/love.cpp index 10e0b5c3f..abac4d618 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -189,7 +189,7 @@ static DoneAction runlove(int argc, char **argv, int &retval, love::Variant &res // LuaJIT-specific setup needs to be done as early as possible - before // get_app_arguments because that loads external library code. This is also - // loaded inside require("love"). Note that it doesn't use the love table. + // loaded inside love's Lua threads. Note that it doesn't use the love table. love_preload(L, luaopen_love_jitsetup, "love.jitsetup"); lua_getglobal(L, "require"); lua_pushstring(L, "love.jitsetup"); diff --git a/src/modules/love/jitsetup.lua b/src/modules/love/jitsetup.lua index 39e85c18a..296ba6c22 100644 --- a/src/modules/love/jitsetup.lua +++ b/src/modules/love/jitsetup.lua @@ -33,9 +33,9 @@ jit.opt.start("maxtrace=2000", "maxrecord=8000") -- and higher than the default (512) because that's already too low. jit.opt.start("maxmcode=16384") -if jit.arch == "arm64" then +if jit.arch == "arm64" or jit.arch == "arm" then -- https://github.com/LuaJIT/LuaJIT/issues/285 - -- LuaJIT 2.1 on arm64 currently (as of commit b4b2dce) can only use memory + -- LuaJIT 2.1 on arm(64) currently (as of commit b4b2dce) can only use memory -- for JIT compilation within a certain short range. Other libraries such as -- SDL can take all the usable space in that range and cause attempts at JIT -- compilation to both fail and take a long time. @@ -62,6 +62,10 @@ if jit.arch == "arm64" then jit.opt.start("sizemcode=128") for i=1, 100 do end + + -- Actually just turn the whole thing off for arm(64). It's very hard to get + -- reliable performance in non-trivial games even with the above workaround. + jit.off() else -- Somewhat arbitrary value (>= the default). jit.opt.start("sizemcode=128") diff --git a/src/modules/love/love.cpp b/src/modules/love/love.cpp index 7c14d3ea8..defe5541c 100644 --- a/src/modules/love/love.cpp +++ b/src/modules/love/love.cpp @@ -38,10 +38,6 @@ #ifdef LOVE_ANDROID #include -extern "C" -{ -#include "luajit.h" -} #endif // LOVE_ANDROID #ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK @@ -529,11 +525,6 @@ int luaopen_love(lua_State *L) for (int i = 0; modules[i].name != nullptr; i++) love::luax_preload(L, modules[i].func, modules[i].name); - // jitsetup is also loaded in the love executable runlove function. It's - // needed here too for threads. Note that it doesn't use the love table. - love::luax_require(L, "love.jitsetup"); - lua_pop(L, 1); - love::luax_insistpinnedthread(L); love::luax_insistglobal(L, "love"); @@ -553,7 +544,6 @@ int luaopen_love(lua_State *L) lua_setfield(L, -2, "_version_codename"); #ifdef LOVE_ANDROID - luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF); lua_register(L, "print", w_print_sdl_log); #endif diff --git a/src/modules/physics/box2d/DistanceJoint.cpp b/src/modules/physics/box2d/DistanceJoint.cpp index 3e63638c3..ca4bc4fc9 100644 --- a/src/modules/physics/box2d/DistanceJoint.cpp +++ b/src/modules/physics/box2d/DistanceJoint.cpp @@ -32,6 +32,8 @@ namespace physics namespace box2d { +love::Type DistanceJoint::type("DistanceJoint", &Joint::type); + DistanceJoint::DistanceJoint(Body *body1, Body *body2, float x1, float y1, float x2, float y2, bool collideConnected) : Joint(body1, body2) , joint(NULL) diff --git a/src/modules/physics/box2d/DistanceJoint.h b/src/modules/physics/box2d/DistanceJoint.h index fe571b5af..f98a197c2 100644 --- a/src/modules/physics/box2d/DistanceJoint.h +++ b/src/modules/physics/box2d/DistanceJoint.h @@ -39,6 +39,8 @@ class DistanceJoint : public Joint { public: + static love::Type type; + /** * Creates a DistanceJoint connecting body1 to body2. **/ diff --git a/src/modules/thread/LuaThread.cpp b/src/modules/thread/LuaThread.cpp index 14ce40d01..50046c3bc 100644 --- a/src/modules/thread/LuaThread.cpp +++ b/src/modules/thread/LuaThread.cpp @@ -25,6 +25,7 @@ #ifdef LOVE_BUILD_STANDALONE extern "C" int luaopen_love(lua_State * L); +extern "C" int luaopen_love_jitsetup(lua_State * L); #endif // LOVE_BUILD_STANDALONE namespace love @@ -55,6 +56,13 @@ void LuaThread::threadFunction() luaL_openlibs(L); #ifdef LOVE_BUILD_STANDALONE + // Call LuaJIT-specific setup again. While it's quite late to call it at + // this point, it still needed to turn off JIT compilation (if necessary) + // for this thread. + luax_preload(L, luaopen_love_jitsetup, "love.jitsetup"); + luax_require(L, "love.jitsetup"); + lua_pop(L, 1); + luax_preload(L, luaopen_love, "love"); luax_require(L, "love"); lua_pop(L, 1);