From 6a295cad59534efa8e47d96916e4d57aaa537c0b Mon Sep 17 00:00:00 2001 From: Brandon McGriff Date: Mon, 9 Nov 2020 15:51:00 -0800 Subject: [PATCH] Added Windows batch files for automated packaging of fused Windows packages. They require the tar utility, but that's included in the latest versions of Windows 10. The utility is available for installation on other versions of Windows. I also found out how to get the Discord RPC library to load with all ways of running the game, but that required changing libs/discordRPC.lua. Binary libraries can only be loaded from the filesystem, outside of a .love archive or fused executable. --- .gitignore | 2 ++ clean.bat | 11 +++++++++++ libs/discordRPC.lua | 22 ++++++++++++++++------ package.bat | 2 ++ release.bat | 26 ++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 clean.bat create mode 100644 package.bat create mode 100644 release.bat diff --git a/.gitignore b/.gitignore index 0bdafc3..c716095 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ *.love dist/*.zip dist/**/cambridge.exe +dist/**/libs +dist/**/*.md \ No newline at end of file diff --git a/clean.bat b/clean.bat new file mode 100644 index 0000000..a5c4cc2 --- /dev/null +++ b/clean.bat @@ -0,0 +1,11 @@ +@del cambridge.love +@del dist\windows\cambridge.exe +@del dist\windows\SOURCES.md +@del dist\windows\LICENSE.md +@rmdir /Q /S dist\windows\libs +@del dist\win32\cambridge.exe +@del dist\win32\SOURCES.md +@del dist\win32\LICENSE.md +@rmdir /Q /S dist\win32\libs +@del dist\cambridge-windows.zip +@del dist\cambridge-win32.zip \ No newline at end of file diff --git a/libs/discordRPC.lua b/libs/discordRPC.lua index 1b9f5e4..0d2af4d 100644 --- a/libs/discordRPC.lua +++ b/libs/discordRPC.lua @@ -5,12 +5,22 @@ local ffi = require "ffi" local osname = love.system.getOS() local discordRPClib = nil -if osname == "Linux" then - discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.so") -elseif osname == "OS X" then - discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.dylib") -elseif osname == "Windows" then - discordRPClib = ffi.load(love.filesystem.getSource().."/libs/discord-rpc.dll") +-- FFI requires the libraries really be files just sitting in the filesystem. It +-- can't load libraries from a .love archive, nor a fused executable on Windows. +-- Merely using love.filesystem.getSource() only works when running LOVE with +-- the game unarchived from command line, like "love .". +-- +-- The code here setting "source" will set the directory where the game was run +-- from, so FFI can load discordRPC. We assume that the discordRPC library's +-- libs directory is in the same directory as the .love archive; if it's +-- missing, it just won't load. +local source = love.filesystem.getSource() +if string.sub(source, -5) == ".love" or love.filesystem.isFused() then + source = love.filesystem.getSourceBaseDirectory() +end + +if osname == "Linux" or osname == "OS X" or osname == "Windows" then + discordRPClib = ffi.load(source.."/libs/discord-rpc") else -- Else it crashes later on error(string.format("Discord rpc not supported on platform (%s)", osname)) diff --git a/package.bat b/package.bat new file mode 100644 index 0000000..e79a40e --- /dev/null +++ b/package.bat @@ -0,0 +1,2 @@ +tar -a -c -f cambridge.zip libs/binser.lua libs/classic.lua libs/discordRPC.lua load res scene tetris conf.lua main.lua scene.lua funcs.lua +rename cambridge.zip cambridge.love \ No newline at end of file diff --git a/release.bat b/release.bat new file mode 100644 index 0000000..8366080 --- /dev/null +++ b/release.bat @@ -0,0 +1,26 @@ +call package.bat + +mkdir dist +mkdir dist\windows +mkdir dist\windows\libs +mkdir dist\win32 +mkdir dist\win32\libs + +copy /b dist\windows\love.exe+cambridge.love dist\windows\cambridge.exe +copy /b dist\win32\love.exe+cambridge.love dist\win32\cambridge.exe + +copy libs\discord-rpc.dll dist\windows\libs +copy libs\discord-rpc.dll dist\win32\libs + +copy SOURCES.md dist\windows +copy LICENSE.md dist\windows +copy SOURCES.md dist\win32 +copy LICENSE.md dist\win32 + +cd dist\windows +tar -a -c -f ..\cambridge-windows.zip cambridge.exe *.dll libs *.md +cd ..\.. + +cd dist\win32 +tar -a -c -f ..\cambridge-win32.zip cambridge.exe *.dll libs *.md +cd ..\.. \ No newline at end of file