forked from mirrors/principia
It's UCRT64 time
This commit is contained in:
parent
ffa8ce97d1
commit
4c5eae3aa6
7 changed files with 83 additions and 180 deletions
38
.github/workflows/build.yml
vendored
38
.github/workflows/build.yml
vendored
|
|
@ -34,6 +34,7 @@ jobs:
|
|||
cmake .. -G Ninja
|
||||
ninja -j4
|
||||
|
||||
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
|
|
@ -45,23 +46,25 @@ jobs:
|
|||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
msystem: UCRT64
|
||||
install: >-
|
||||
mingw-w64-x86_64-gcc
|
||||
mingw-w64-x86_64-cmake
|
||||
mingw-w64-x86_64-ninja
|
||||
mingw-w64-x86_64-glew
|
||||
mingw-w64-x86_64-zlib
|
||||
mingw-w64-x86_64-gtk3
|
||||
mingw-w64-x86_64-libpng
|
||||
mingw-w64-x86_64-libjpeg-turbo
|
||||
mingw-w64-x86_64-SDL2
|
||||
mingw-w64-x86_64-SDL2_ttf
|
||||
mingw-w64-x86_64-nsis
|
||||
mingw-w64-ucrt-x86_64-gcc
|
||||
mingw-w64-ucrt-x86_64-cmake
|
||||
mingw-w64-ucrt-x86_64-ninja
|
||||
mingw-w64-ucrt-x86_64-glew
|
||||
mingw-w64-ucrt-x86_64-zlib
|
||||
mingw-w64-ucrt-x86_64-gtk3
|
||||
mingw-w64-ucrt-x86_64-libpng
|
||||
mingw-w64-ucrt-x86_64-libjpeg-turbo
|
||||
mingw-w64-ucrt-x86_64-SDL2
|
||||
mingw-w64-ucrt-x86_64-SDL2_ttf
|
||||
mingw-w64-ucrt-x86_64-nsis
|
||||
mingw-w64-ucrt-x86_64-7zip
|
||||
|
||||
# custom built packages with less dependencies than MSYS' counterparts
|
||||
- name: Install external packages
|
||||
run: |
|
||||
wget https://grejer.voxelmanip.se/msys-pkgs/mingw-w64-x86_64-{curl-winssl-8.4.0-3,freetype-2.13.2-1,SDL2_image-2.6.3-2,SDL2_mixer-2.6.3-1}-any.pkg.tar.zst
|
||||
wget https://grejer.voxelmanip.se/msys-pkgs/mingw-w64-ucrt-x86_64-{curl-winssl-8.4.0-3,freetype-2.13.2-1,SDL2_image-2.6.3-2,SDL2_mixer-2.6.3-1}-any.pkg.tar.zst
|
||||
pacman -U --noconfirm *.pkg.tar.zst
|
||||
|
||||
- name: Build
|
||||
|
|
@ -71,10 +74,11 @@ jobs:
|
|||
cmake .. -G Ninja
|
||||
ninja -j4
|
||||
|
||||
- name: Bundle together
|
||||
- name: Bundle together installer and portable
|
||||
run: |
|
||||
cd build
|
||||
bash ../packaging/windows_release.sh
|
||||
../packaging/windows_release.sh
|
||||
../packaging/windows_portable.sh
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
|
|
@ -82,6 +86,12 @@ jobs:
|
|||
name: principia-setup.exe
|
||||
path: build/principia-setup.exe
|
||||
|
||||
- name: Upload output as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: principia-portable.7z
|
||||
path: build/principia-portable.7z
|
||||
|
||||
android:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
|
|
|
|||
20
README.md
20
README.md
|
|
@ -38,9 +38,9 @@ Below are instructions to build Principia on Windows, Linux and Android from sou
|
|||
If you have issues building Principia, then please ask in the `#development` channel on Discord.
|
||||
|
||||
### Windows
|
||||
The game engine behind Principia (TMS) is written in the C99 standard of C. Unfortunately, the Visual Studio C compiler does not support the C99 standard. Principia must therefore be compiled using the MSYS2 MINGW64 toolchain, as described below.
|
||||
The game engine behind Principia (TMS) is written in the C99 standard of C. Unfortunately, the Visual Studio C compiler does not support the C99 standard. Principia must therefore be compiled using MinGW-w64 toolchain.
|
||||
|
||||
Please find the latest version of the 64-bit MSYS2 here: https://www.msys2.org/
|
||||
The following build Windows instructions use MSYS2 which is a development environment for Windows including MinGW and other tools. Please download and install the latest version of the MSYS2 installer here: https://www.msys2.org/
|
||||
|
||||
After installation, a terminal opens. Run the following command to update the environment:
|
||||
|
||||
|
|
@ -48,19 +48,21 @@ After installation, a terminal opens. Run the following command to update the en
|
|||
pacman -Syu
|
||||
```
|
||||
|
||||
The terminal will then ask you to close it when done. Proceed with doing so, and then go to the start menu and run MSYS Mingw32 64-bit. It is important that you run the "MINGW64 64-Bit" version and not the "MSYS2 MSYS" or "MINGW64 32-Bit". Run the commands below to install the necessary dependencies.
|
||||
The terminal will then ask you to shut down the MSYS2 runtime to the finish the update. Proceed with doing so, and then go to the start menu and start the "MSYS2 UCRT64" environment (icon with gold background) again. Run the following command to install the necessary dependencies:
|
||||
|
||||
```bash
|
||||
pacman -S base-devel mingw-w64-x86_64-{toolchain,cmake,ninja,curl,gtk3,glew,gtksourceview4,libpng,libjpeg-turbo,freetype,SDL2,SDL2_image,SDL2_mixer,SDL2_ttf}
|
||||
pacman -S git mingw-w64-ucrt-x86_64-{gcc,cmake,ninja,curl-winssl,gtk3,glew,libpng,libjpeg-turbo,freetype,SDL2,SDL2_image,SDL2_mixer,SDL2_ttf}
|
||||
```
|
||||
|
||||
Then navigate to the folder where you cloned Principia, for example:
|
||||
Navigate somewhere you want to clone the Principia source code to, such as on your desktop:
|
||||
|
||||
```bash
|
||||
cd /c/Users/<username>/Documents/Principia
|
||||
cd /c/Users/$USER/Desktop/
|
||||
git clone https://github.com/Bithack/principia
|
||||
cd principia
|
||||
```
|
||||
|
||||
And start the building process:
|
||||
Then generate the build files using CMake and start the compilation:
|
||||
|
||||
```bash
|
||||
mkdir build; cd build
|
||||
|
|
@ -68,13 +70,13 @@ cmake .. -G Ninja
|
|||
ninja
|
||||
```
|
||||
|
||||
When finished there will be a `principia.exe` file in the build folder. Keep in mind that the built executable can only be run inside of the MINGW terminal, to make a release build see below to build the installer:
|
||||
When finished there will be a `principia.exe` file in the build folder. Keep in mind that the built executable can only be run inside of the MSYS2 terminal, to make a release build see below to build the installer:
|
||||
|
||||
#### Windows installer
|
||||
The Windows installer uses NSIS, which must be installed first before building:
|
||||
|
||||
```bash
|
||||
pacman -S mingw-w64-x86_64-nsis
|
||||
pacman -S mingw-w64-ucrt-x86_64-nsis
|
||||
```
|
||||
|
||||
For making Windows release builds you would run the `packaging/windows_release.sh` script, which will bundle necessary DLLs and other files to make the game run, and builds the installer.
|
||||
|
|
|
|||
21
packaging/bundledlls
Normal file
21
packaging/bundledlls
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
# msys2-bundledlls - Copy DLLs linked against a Windows executable for bundling with a distribution
|
||||
|
||||
if [ "$#" -ne 2 ];
|
||||
then
|
||||
echo "Usage: ./bundledlls <executable> <directory>"
|
||||
exit
|
||||
fi
|
||||
|
||||
mkdir -p $2
|
||||
|
||||
# Get list of dynamic libraries, filter by ones that are found in the current MSYS2 prefix
|
||||
# and strip off everything but the full path. E.g.:
|
||||
# `lua51.dll => /ucrt64/bin/lua51.dll (0xdeadbeef)` => `/ucrt64/bin/lua51.dll`
|
||||
list=$(ldd $1 | grep $MINGW_PREFIX | sed 's/.* => //' | sed 's/ \(.*\)//')
|
||||
|
||||
for dll in $list;
|
||||
do
|
||||
echo $dll
|
||||
cp $dll $2/
|
||||
done
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2015 Martin Preisler
|
||||
#
|
||||
# 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 without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# 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. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
import subprocess
|
||||
import os.path
|
||||
import argparse
|
||||
import shutil
|
||||
|
||||
# The mingw path matches where Fedora 21 installs mingw32; this is the default
|
||||
# fallback if no other search path is specified in $MINGW_BUNDLEDLLS_SEARCH_PATH
|
||||
DEFAULT_PATH_PREFIXES = [
|
||||
"", "/usr/bin", "/usr/i686-w64-mingw32/sys-root/mingw/bin", "/mingw64/bin",
|
||||
"/usr/i686-w64-mingw32/sys-root/mingw/lib",
|
||||
"C:\\msys64\\mingw64\\bin",
|
||||
"D:\\a\\_temp\\msys64\\mingw64\\bin\\" # Github workflow's MSYS2 install
|
||||
]
|
||||
|
||||
env_path_prefixes = os.environ.get('MINGW_BUNDLEDLLS_SEARCH_PATH', None)
|
||||
if env_path_prefixes is not None:
|
||||
path_prefixes = [path for path in env_path_prefixes.split(os.pathsep) if path]
|
||||
else:
|
||||
path_prefixes = DEFAULT_PATH_PREFIXES
|
||||
|
||||
# This blacklist may need extending
|
||||
blacklist = [
|
||||
"advapi32.dll", "kernel32.dll", "msvcrt.dll", "ole32.dll", "user32.dll",
|
||||
"ws2_32.dll", "comdlg32.dll", "gdi32.dll", "imm32.dll", "oleaut32.dll",
|
||||
"shell32.dll", "winmm.dll", "winspool.drv", "wldap32.dll",
|
||||
"ntdll.dll", "d3d9.dll", "mpr.dll", "crypt32.dll", "dnsapi.dll",
|
||||
"shlwapi.dll", "version.dll", "iphlpapi.dll", "msimg32.dll", "setupapi.dll",
|
||||
"opengl32.dll", "dwmapi.dll", "uxtheme.dll", "secur32.dll", "gdiplus.dll",
|
||||
"usp10.dll", "comctl32.dll", "wsock32.dll", "netapi32.dll", "userenv.dll",
|
||||
"avicap32.dll", "avrt.dll", "psapi.dll", "mswsock.dll", "glu32.dll",
|
||||
"bcrypt.dll", "rpcrt4.dll", "hid.dll",
|
||||
# directx 3d 11
|
||||
"d3d11.dll", "dxgi.dll", "dwrite.dll"
|
||||
]
|
||||
|
||||
|
||||
def find_full_path(filename, path_prefixes):
|
||||
for path_prefix in path_prefixes:
|
||||
path = os.path.join(path_prefix, filename)
|
||||
path_low = os.path.join(path_prefix, filename.lower())
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
if os.path.exists(path_low):
|
||||
return path_low
|
||||
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"Can't find " + filename + ". If it is an inbuilt Windows DLL, "
|
||||
"please add it to the blacklist variable in the script and send "
|
||||
"a pull request!"
|
||||
)
|
||||
|
||||
|
||||
def gather_deps(path, path_prefixes, seen):
|
||||
ret = [path]
|
||||
output = subprocess.check_output(["objdump", "-p", path]).decode(
|
||||
"utf-8", "replace").split("\n")
|
||||
for line in output:
|
||||
if not line.startswith("\tDLL Name: "):
|
||||
continue
|
||||
|
||||
dep = line.split("DLL Name: ")[1].strip()
|
||||
ldep = dep.lower()
|
||||
|
||||
if ldep in blacklist:
|
||||
continue
|
||||
|
||||
if ldep in seen:
|
||||
continue
|
||||
|
||||
dep_path = find_full_path(dep, path_prefixes)
|
||||
seen.add(ldep)
|
||||
subdeps = gather_deps(dep_path, path_prefixes, seen)
|
||||
ret.extend(subdeps)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"exe_file",
|
||||
help="EXE or DLL file that you need to bundle dependencies for"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--copy",
|
||||
action="store_true",
|
||||
help="In addition to printing out the dependencies, also copy them next to the exe_file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--upx",
|
||||
action="store_true",
|
||||
help="Only valid if --copy is provided. Run UPX on all the DLLs and EXE."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.upx and not args.copy:
|
||||
raise RuntimeError("Can't run UPX if --copy hasn't been provided.")
|
||||
|
||||
all_deps = set(gather_deps(args.exe_file, path_prefixes, set()))
|
||||
all_deps.remove(args.exe_file)
|
||||
|
||||
print("\n".join(all_deps))
|
||||
|
||||
if args.copy:
|
||||
print("Copying enabled, will now copy all dependencies next to the exe_file.\n")
|
||||
|
||||
parent_dir = os.path.dirname(os.path.abspath(args.exe_file))
|
||||
|
||||
for dep in all_deps:
|
||||
target = os.path.join(parent_dir, os.path.basename(dep))
|
||||
|
||||
try:
|
||||
print("Copying '%s' to '%s'" % (dep, target))
|
||||
shutil.copy(dep, parent_dir)
|
||||
|
||||
except shutil.SameFileError:
|
||||
print("Dependency '%s' was already in target directory, "
|
||||
"skipping..." % (dep))
|
||||
|
||||
if args.upx:
|
||||
subprocess.call(["upx", target])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
SetCompressor lzma
|
||||
|
||||
!include "MUI2.nsh"
|
||||
|
||||
!define MUI_ICON "..\packaging\icon.ico"
|
||||
|
|
|
|||
19
packaging/windows_portable.sh
Normal file
19
packaging/windows_portable.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script relies on windows_release.sh being run to prepare the release/ directory
|
||||
|
||||
touch release/portable.txt
|
||||
|
||||
cp ../packaging/play_community_level.bat release/
|
||||
|
||||
cp -r ../data-{pc,shared}/ release/
|
||||
|
||||
# juggling time
|
||||
mv principia.exe principia_exe.exe
|
||||
mv release/ Principia/
|
||||
|
||||
7z a principia-portable.7z Principia/
|
||||
|
||||
# switch it back
|
||||
mv Principia/ release/
|
||||
mv principia_exe.exe principia.exe
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Commented out because I prefer doing the compilation mzself
|
||||
#./go --clean --release
|
||||
# This script assumes you already have built the executable
|
||||
|
||||
rm -rf release
|
||||
mkdir -p release
|
||||
|
|
@ -11,16 +11,16 @@ cd release
|
|||
# collect up GTK3 junk to make it work
|
||||
PIXBUF_DIR="lib/gdk-pixbuf-2.0/2.10.0"
|
||||
mkdir -p $PIXBUF_DIR/loaders/
|
||||
cp /mingw64/$PIXBUF_DIR/loaders.cache $PIXBUF_DIR/
|
||||
cp /mingw64/$PIXBUF_DIR/loaders/libpixbufloader-{jpeg,png}.dll $PIXBUF_DIR/loaders/
|
||||
cp $MINGW_PREFIX/$PIXBUF_DIR/loaders.cache $PIXBUF_DIR/
|
||||
cp $MINGW_PREFIX/$PIXBUF_DIR/loaders/libpixbufloader-{jpeg,png}.dll $PIXBUF_DIR/loaders/
|
||||
|
||||
SCHEMAS_DIR="share/glib-2.0/schemas"
|
||||
mkdir -p $SCHEMAS_DIR
|
||||
cp /mingw64/$SCHEMAS_DIR/{gschema.dtd,gschemas.compiled} $SCHEMAS_DIR/
|
||||
cp $MINGW_PREFIX/$SCHEMAS_DIR/{gschema.dtd,gschemas.compiled} $SCHEMAS_DIR/
|
||||
|
||||
cd ..
|
||||
|
||||
../packaging/mingw-bundledlls release/principia.exe --copy
|
||||
../packaging/bundledlls release/principia.exe release/
|
||||
|
||||
cp ../packaging/principia_install.nsi .
|
||||
cp -r ../packaging/installer/ .
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue