Browse Source

Merge branch 'main' into 12.0-development

Sasha Szpakowski 1 year ago
parent
commit
8951635abc

+ 34 - 13
CMakeLists.txt

@@ -41,7 +41,13 @@ if(APPLE)
 	message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.")
 	message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.")
 endif()
 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)
 	set(LOVE_CONSOLE_EXE_NAME lovec)
 endif()
 endif()
 
 
@@ -178,7 +184,7 @@ Please see https://github.com/love2d/megasource
 	find_package(ModPlug REQUIRED)
 	find_package(ModPlug REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenGL 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(Theora REQUIRED)
 	find_package(Vorbis REQUIRED)
 	find_package(Vorbis REQUIRED)
 	find_package(ZLIB REQUIRED)
 	find_package(ZLIB REQUIRED)
@@ -188,7 +194,7 @@ Please see https://github.com/love2d/megasource
 	add_definitions(-D HAS_SOCKLEN_T)
 	add_definitions(-D HAS_SOCKLEN_T)
 
 
 	set(LOVE_INCLUDE_DIRS
 	set(LOVE_INCLUDE_DIRS
-		${SDL2_INCLUDE_DIR}
+		${SDL2_INCLUDE_DIRS}
 		${FREETYPE_INCLUDE_DIRS}
 		${FREETYPE_INCLUDE_DIRS}
 		${HARFBUZZ_INCLUDE_DIR}
 		${HARFBUZZ_INCLUDE_DIR}
 		${VORBIS_INCLUDE_DIR}
 		${VORBIS_INCLUDE_DIR}
@@ -201,7 +207,7 @@ Please see https://github.com/love2d/megasource
 
 
 	set(LOVE_LINK_LIBRARIES
 	set(LOVE_LINK_LIBRARIES
 		${OPENGL_gl_LIBRARY}
 		${OPENGL_gl_LIBRARY}
-		${SDL2_LIBRARY}
+		${SDL2_LIBRARIES}
 		${FREETYPE_LIBRARY}
 		${FREETYPE_LIBRARY}
 		${HARFBUZZ_LIBRARY}
 		${HARFBUZZ_LIBRARY}
 		${OPENAL_LIBRARY}
 		${OPENAL_LIBRARY}
@@ -1298,6 +1304,9 @@ set(LOVE_SRC_3P_ENET
 add_library(love_3p_enet ${LOVE_SRC_3P_ENET})
 add_library(love_3p_enet ${LOVE_SRC_3P_ENET})
 target_link_libraries(love_3p_enet ${LOVE_LUA_LIBRARY})
 target_link_libraries(love_3p_enet ${LOVE_LUA_LIBRARY})
 target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include)
 target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include)
+if(MINGW)
+	target_link_libraries(love_3p_enet winmm.a)
+endif()
 
 
 #
 #
 # GLAD
 # GLAD
@@ -1393,7 +1402,7 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
 	src/libraries/glslang/glslang/OSDependent/osinclude.h
 	src/libraries/glslang/glslang/OSDependent/osinclude.h
 )
 )
 
 
-if(MSVC)
+if(MSVC OR MINGW)
 	set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
 	set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
 		${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT}
 		${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT}
 		src/libraries/glslang/glslang/OSDependent/Windows/main.cpp
 		src/libraries/glslang/glslang/OSDependent/Windows/main.cpp
@@ -1530,7 +1539,13 @@ set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
 
 
 set(LOVE_LINK_L3P_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
 	set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
 		${LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET}
 		${LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET}
 		src/libraries/luasocket/libluasocket/wsocket.c
 		src/libraries/luasocket/libluasocket/wsocket.c
@@ -1539,7 +1554,7 @@ if(MSVC)
 
 
 	set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET
 	set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET
 		${LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET}
 		${LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET}
-		ws2_32.lib
+		ws2_32${WIN32_LIB_EXT}
 	)
 	)
 else()
 else()
 	set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
 	set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
@@ -1950,17 +1965,23 @@ link_directories(${LOVE_LINK_DIRS})
 
 
 set(LOVE_RC)
 set(LOVE_RC)
 
 
-if(MSVC)
+if(MSVC OR MINGW)
 	set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES}
 	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
 	set(LOVE_RC
 		extra/windows/love.rc
 		extra/windows/love.rc
 		extra/windows/love.ico
 		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()
 endif()
 
 
 if(ANDROID)
 if(ANDROID)
@@ -1992,7 +2013,7 @@ if(NOT ANDROID)
 	target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME})
 	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)
 	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})
 		add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC})
 		target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME})
 		target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME})
 	endif()
 	endif()
@@ -2021,7 +2042,7 @@ if(NOT ANDROID)
 	endif()
 	endif()
 endif()
 endif()
 
 
-if (NOT MSVC)
+if (NOT MSVC OR MINGW)
 	return()
 	return()
 endif()
 endif()
 
 

+ 17 - 0
changes.txt

@@ -147,11 +147,28 @@ LOVE 11.5 [Mysterious Mysteries]
 
 
 Released: N/A
 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 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 a race condition when a Thread is destroyed immediately after Thread:start.
 * Fixed unexpectedly slow first frames on macOS.
 * 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 time drift in Source:tell after a Source loops.
 * Fixed audio not always pausing when the app is minimized on Android.
 * 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 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 some cases of framerate hitches in Windows when vsync is enabled in windowed mode.
 * Fixed colors appearing over-saturated on P3 displays in macOS.
 * Fixed colors appearing over-saturated on P3 displays in macOS.

+ 0 - 57
platform/xcode/ios/luajit-iOS.sh

@@ -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

+ 3 - 4
src/common/android.cpp

@@ -867,10 +867,9 @@ void *getIOFromFD(int fd)
 
 
 const char *getArg0()
 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;
 	return (const char *) &androidInit;
 }
 }
 
 

+ 3 - 1
src/common/config.h

@@ -102,7 +102,7 @@
 #endif
 #endif
 
 
 // DLL-stuff.
 // DLL-stuff.
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW32__)
 #	define LOVE_EXPORT __declspec(dllexport)
 #	define LOVE_EXPORT __declspec(dllexport)
 #elif defined(__GNUC__) || defined(__clang__)
 #elif defined(__GNUC__) || defined(__clang__)
 #	define LOVE_EXPORT __attribute__((visibility("default")))
 #	define LOVE_EXPORT __attribute__((visibility("default")))
@@ -114,8 +114,10 @@
 #ifndef LOVE_WINDOWS_UWP
 #ifndef LOVE_WINDOWS_UWP
 #	define LOVE_LEGENDARY_CONSOLE_IO_HACK
 #	define LOVE_LEGENDARY_CONSOLE_IO_HACK
 #endif // LOVE_WINDOWS_UWP
 #endif // LOVE_WINDOWS_UWP
+#ifndef __MINGW32__
 #	define NOMINMAX
 #	define NOMINMAX
 #endif
 #endif
+#endif
 
 
 #if defined(LOVE_MACOS) || defined(LOVE_IOS)
 #if defined(LOVE_MACOS) || defined(LOVE_IOS)
 #	define LOVE_LEGENDARY_APP_ARGV_HACK
 #	define LOVE_LEGENDARY_APP_ARGV_HACK

+ 2 - 0
src/common/ios.mm

@@ -149,6 +149,8 @@ static NSArray *getLovesInDocuments()
 			[paths addObject:path.stringByDeletingLastPathComponent];
 			[paths addObject:path.stringByDeletingLastPathComponent];
 	}
 	}
 
 
+	[paths sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
+
 	return paths;
 	return paths;
 }
 }
 
 

+ 1 - 1
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
 	// LuaJIT-specific setup needs to be done as early as possible - before
 	// get_app_arguments because that loads external library code. This is also
 	// 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");
 	love_preload(L, luaopen_love_jitsetup, "love.jitsetup");
 	lua_getglobal(L, "require");
 	lua_getglobal(L, "require");
 	lua_pushstring(L, "love.jitsetup");
 	lua_pushstring(L, "love.jitsetup");

+ 6 - 2
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.
 -- and higher than the default (512) because that's already too low.
 jit.opt.start("maxmcode=16384")
 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
 	-- 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
 	-- 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
 	-- SDL can take all the usable space in that range and cause attempts at JIT
 	-- compilation to both fail and take a long time.
 	-- compilation to both fail and take a long time.
@@ -62,6 +62,10 @@ if jit.arch == "arm64" then
 	
 	
 	jit.opt.start("sizemcode=128")
 	jit.opt.start("sizemcode=128")
 	for i=1, 100 do end
 	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
 else
 	-- Somewhat arbitrary value (>= the default).
 	-- Somewhat arbitrary value (>= the default).
 	jit.opt.start("sizemcode=128")
 	jit.opt.start("sizemcode=128")

+ 0 - 10
src/modules/love/love.cpp

@@ -38,10 +38,6 @@
 
 
 #ifdef LOVE_ANDROID
 #ifdef LOVE_ANDROID
 #include <SDL.h>
 #include <SDL.h>
-extern "C"
-{
-#include "luajit.h"
-}
 #endif // LOVE_ANDROID
 #endif // LOVE_ANDROID
 
 
 #ifdef LOVE_LEGENDARY_CONSOLE_IO_HACK
 #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++)
 	for (int i = 0; modules[i].name != nullptr; i++)
 		love::luax_preload(L, modules[i].func, modules[i].name);
 		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_insistpinnedthread(L);
 
 
 	love::luax_insistglobal(L, "love");
 	love::luax_insistglobal(L, "love");
@@ -553,7 +544,6 @@ int luaopen_love(lua_State *L)
 	lua_setfield(L, -2, "_version_codename");
 	lua_setfield(L, -2, "_version_codename");
 
 
 #ifdef LOVE_ANDROID
 #ifdef LOVE_ANDROID
-	luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF);
 	lua_register(L, "print", w_print_sdl_log);
 	lua_register(L, "print", w_print_sdl_log);
 #endif
 #endif
 
 

+ 2 - 0
src/modules/physics/box2d/DistanceJoint.cpp

@@ -32,6 +32,8 @@ namespace physics
 namespace box2d
 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)
 DistanceJoint::DistanceJoint(Body *body1, Body *body2, float x1, float y1, float x2, float y2, bool collideConnected)
 	: Joint(body1, body2)
 	: Joint(body1, body2)
 	, joint(NULL)
 	, joint(NULL)

+ 2 - 0
src/modules/physics/box2d/DistanceJoint.h

@@ -39,6 +39,8 @@ class DistanceJoint : public Joint
 {
 {
 public:
 public:
 
 
+	static love::Type type;
+
 	/**
 	/**
 	 * Creates a DistanceJoint connecting body1 to body2.
 	 * Creates a DistanceJoint connecting body1 to body2.
 	 **/
 	 **/

+ 8 - 0
src/modules/thread/LuaThread.cpp

@@ -25,6 +25,7 @@
 
 
 #ifdef LOVE_BUILD_STANDALONE
 #ifdef LOVE_BUILD_STANDALONE
 extern "C" int luaopen_love(lua_State * L);
 extern "C" int luaopen_love(lua_State * L);
+extern "C" int luaopen_love_jitsetup(lua_State * L);
 #endif // LOVE_BUILD_STANDALONE
 #endif // LOVE_BUILD_STANDALONE
 
 
 namespace love
 namespace love
@@ -55,6 +56,13 @@ void LuaThread::threadFunction()
 	luaL_openlibs(L);
 	luaL_openlibs(L);
 
 
 #ifdef LOVE_BUILD_STANDALONE
 #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_preload(L, luaopen_love, "love");
 	luax_require(L, "love");
 	luax_require(L, "love");
 	lua_pop(L, 1);
 	lua_pop(L, 1);