From 2d8a778840c029f556ea8d0b43e5b2f0a0ea68b0 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 10 Oct 2019 00:11:33 +0100 Subject: [PATCH] RetroFW / OpenDingux build configurations (#264) --- CMakeLists.txt | 11 +++- Packaging/OpenDingux/.editorconfig | 6 +++ Packaging/OpenDingux/.gitignore | 1 + Packaging/OpenDingux/README.md | 3 ++ Packaging/OpenDingux/build-opendingux-sdl1.sh | 54 +++++++++++++++++++ Packaging/OpenDingux/build-retrofw.sh | 54 +++++++++++++++++++ .../buildroot_opendingux_musl_defconfig | 9 ++++ .../OpenDingux/buildroot_retrofw_defconfig | 9 ++++ Packaging/OpenDingux/control | 10 ++++ Packaging/OpenDingux/devilutionx.man.txt | 5 ++ Packaging/OpenDingux/diablo.ini | 3 ++ Packaging/OpenDingux/package.sh | 54 +++++++++++++++++++ README.md | 30 +++++++++++ 13 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 Packaging/OpenDingux/.editorconfig create mode 100644 Packaging/OpenDingux/.gitignore create mode 100644 Packaging/OpenDingux/README.md create mode 100755 Packaging/OpenDingux/build-opendingux-sdl1.sh create mode 100755 Packaging/OpenDingux/build-retrofw.sh create mode 100644 Packaging/OpenDingux/buildroot_opendingux_musl_defconfig create mode 100644 Packaging/OpenDingux/buildroot_retrofw_defconfig create mode 100644 Packaging/OpenDingux/control create mode 100644 Packaging/OpenDingux/devilutionx.man.txt create mode 100644 Packaging/OpenDingux/diablo.ini create mode 100755 Packaging/OpenDingux/package.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 11b4563ea..e41b4265e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ if(HAIKU) set(ASAN OFF) endif() -if(DIST) +if(DIST OR DINGUX) set(sodium_USE_STATIC_LIBS ON) endif() @@ -308,10 +308,15 @@ foreach(target devilution devilutionx) target_compile_options(${target} PUBLIC -fsanitize=address -fsanitize-recover=address) target_link_libraries(${target} PUBLIC -fsanitize=address -fsanitize-recover=address) endif() + if(UBSAN) target_compile_options(${target} PUBLIC -fsanitize=undefined) target_link_libraries(${target} PUBLIC -fsanitize=undefined) endif() + + if(DINGUX) + target_compile_definitions(${target} PRIVATE DINGUX) + endif() endforeach(target devilution devilutionx) if(DIST AND CMAKE_CXX_COMPILER_ID MATCHES "GCC") @@ -399,3 +404,7 @@ if(APPLE) include(CPack) endif() + +if(DINGUX) + set_target_properties(devilutionx PROPERTIES OUTPUT_NAME "devilutionx.dge") +endif() diff --git a/Packaging/OpenDingux/.editorconfig b/Packaging/OpenDingux/.editorconfig new file mode 100644 index 000000000..1455edc1f --- /dev/null +++ b/Packaging/OpenDingux/.editorconfig @@ -0,0 +1,6 @@ +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/Packaging/OpenDingux/.gitignore b/Packaging/OpenDingux/.gitignore new file mode 100644 index 000000000..82520ca12 --- /dev/null +++ b/Packaging/OpenDingux/.gitignore @@ -0,0 +1 @@ +/tmp/ diff --git a/Packaging/OpenDingux/README.md b/Packaging/OpenDingux/README.md new file mode 100644 index 000000000..f8f2464e5 --- /dev/null +++ b/Packaging/OpenDingux/README.md @@ -0,0 +1,3 @@ +# DevilutionX OpenDingux Port + +See README.md in the root directory for build instructions. diff --git a/Packaging/OpenDingux/build-opendingux-sdl1.sh b/Packaging/OpenDingux/build-opendingux-sdl1.sh new file mode 100755 index 000000000..b2febf0b0 --- /dev/null +++ b/Packaging/OpenDingux/build-opendingux-sdl1.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -euo pipefail + +declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" +cd "$DIR" +declare -r ABSDIR="$(pwd)" + +declare -r BUILDROOT_VER=buildroot-2018.02.9 +BUILDROOT="${BUILDROOT:-$HOME/${BUILDROOT_VER}-opendingux-musl}" + +declare -r BUILDROOT_ARCHIVE="$HOME/${BUILDROOT_VER}.tar.gz" + +set -x + +main() { + set -x + prepare_buildroot + build + package +} + +prepare_buildroot() { + if [[ -d $BUILDROOT ]]; then + return + fi + if [[ ! -f $BUILDROOT_ARCHIVE ]]; then + \curl https://buildroot.org/downloads/${BUILDROOT_VER}.tar.gz -o "$BUILDROOT_ARCHIVE" + fi + + tar xf "$BUILDROOT_ARCHIVE" -C "$(dirname "$BUILDROOT_ARCHIVE")" + mv "${BUILDROOT_ARCHIVE%.tar.gz}" "$BUILDROOT" + cp buildroot_opendingux_musl_defconfig "$BUILDROOT/configs/opendingux_musl_defconfig" + cd "$BUILDROOT" + echo 'LIBSODIUM_CONF_OPTS += --enable-static' >> package/libsodium/libsodium.mk + make opendingux_musl_defconfig + BR2_JLEVEL=0 make toolchain libsodium libzip sdl sdl_mixer sdl_ttf + cd - +} + +build() { + mkdir -p ../../build + cd ../../build + rm -f CMakeCache.txt + cmake .. -DDINGUX=ON -DUSE_SDL1=ON -DBINARY_RELEASE=ON \ + -DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/share/buildroot/toolchainfile.cmake" + cd - +} + +package() { + ./package.sh ../../build/devilutionx-opendingux-musl-sdl1.ipk +} + +main diff --git a/Packaging/OpenDingux/build-retrofw.sh b/Packaging/OpenDingux/build-retrofw.sh new file mode 100755 index 000000000..2b4c19eb9 --- /dev/null +++ b/Packaging/OpenDingux/build-retrofw.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -euo pipefail + +declare -r DIR="$(dirname "${BASH_SOURCE[0]}")" +cd "$DIR" +declare -r ABSDIR="$(pwd)" + +declare -r BUILDROOT_VER=buildroot-2018.02.9 +BUILDROOT="${BUILDROOT:-$HOME/${BUILDROOT_VER}-retrofw}" + +declare -r BUILDROOT_ARCHIVE="$HOME/${BUILDROOT_VER}.tar.gz" + +set -x + +main() { + set -x + prepare_buildroot + build + package +} + +prepare_buildroot() { + if [[ -d $BUILDROOT ]]; then + return + fi + if [[ ! -f $BUILDROOT_ARCHIVE ]]; then + \curl https://buildroot.org/downloads/${BUILDROOT_VER}.tar.gz -o "$BUILDROOT_ARCHIVE" + fi + + tar xf "$BUILDROOT_ARCHIVE" -C "$(dirname "$BUILDROOT_ARCHIVE")" + mv "${BUILDROOT_ARCHIVE%.tar.gz}" "$BUILDROOT" + cp buildroot_retrofw_defconfig "$BUILDROOT/configs/retrofw_defconfig" + cd "$BUILDROOT" + echo 'LIBSODIUM_CONF_OPTS += --enable-static' >> package/libsodium/libsodium.mk + make retrofw_defconfig + BR2_JLEVEL=0 make toolchain libsodium libzip sdl sdl_mixer sdl_ttf + cd - +} + +build() { + mkdir -p ../../build + cd ../../build + rm -f CMakeCache.txt + cmake .. -DDINGUX=ON -DUSE_SDL1=ON -DBINARY_RELEASE=ON \ + -DCMAKE_TOOLCHAIN_FILE="$BUILDROOT/output/host/share/buildroot/toolchainfile.cmake" + cd - +} + +package() { + ./package.sh ../../build/devilutionx-retrofw-uclibc-sdl1.ipk +} + +main diff --git a/Packaging/OpenDingux/buildroot_opendingux_musl_defconfig b/Packaging/OpenDingux/buildroot_opendingux_musl_defconfig new file mode 100644 index 000000000..361c67c16 --- /dev/null +++ b/Packaging/OpenDingux/buildroot_opendingux_musl_defconfig @@ -0,0 +1,9 @@ +BR2_mipsel=y +# BR2_MIPS_SOFT_FLOAT is not set +BR2_TOOLCHAIN_BUILDROOT_MUSL=y +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_PACKAGE_SDL=y +BR2_PACKAGE_SDL_MIXER=y +BR2_PACKAGE_SDL_TTF=y +BR2_PACKAGE_LIBZIP=y +BR2_PACKAGE_LIBSODIUM=y diff --git a/Packaging/OpenDingux/buildroot_retrofw_defconfig b/Packaging/OpenDingux/buildroot_retrofw_defconfig new file mode 100644 index 000000000..5c27fefd6 --- /dev/null +++ b/Packaging/OpenDingux/buildroot_retrofw_defconfig @@ -0,0 +1,9 @@ +BR2_mipsel=y +# BR2_MIPS_SOFT_FLOAT is not set +BR2_TOOLCHAIN_BUILDROOT_WCHAR=y +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_PACKAGE_SDL=y +BR2_PACKAGE_SDL_MIXER=y +BR2_PACKAGE_SDL_TTF=y +BR2_PACKAGE_LIBZIP=y +BR2_PACKAGE_LIBSODIUM=y diff --git a/Packaging/OpenDingux/control b/Packaging/OpenDingux/control new file mode 100644 index 000000000..365371a8e --- /dev/null +++ b/Packaging/OpenDingux/control @@ -0,0 +1,10 @@ +Package: devilutionx +Version: 0.0.1 +Architecture: mipsel +Section: games +Maintainer: glex.spb@gmail.com +Description: A port of DevilutionX for OpenDingux / RetroFW. +Priority: optional +Homepage: https://github.com/diasurgical/devilutionX +Depends: +Source: https://github.com/diasurgical/devilutionX diff --git a/Packaging/OpenDingux/devilutionx.man.txt b/Packaging/OpenDingux/devilutionx.man.txt new file mode 100644 index 000000000..af2ac678b --- /dev/null +++ b/Packaging/OpenDingux/devilutionx.man.txt @@ -0,0 +1,5 @@ +Copy diabdat.mpq from your CD, or GoG install folder to: +/home/retrofw/games/devilutionx/diabdat.mpq + +Game saves and diablo.ini are located at: +/home/retrofw/.local/share/diasurgical/devilution diff --git a/Packaging/OpenDingux/diablo.ini b/Packaging/OpenDingux/diablo.ini new file mode 100644 index 000000000..1c89f0ce9 --- /dev/null +++ b/Packaging/OpenDingux/diablo.ini @@ -0,0 +1,3 @@ +[devilutionx] +upscale=0 +fullscreen=0 diff --git a/Packaging/OpenDingux/package.sh b/Packaging/OpenDingux/package.sh new file mode 100755 index 000000000..b0b9e7500 --- /dev/null +++ b/Packaging/OpenDingux/package.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +readonly OUT="${1:-../../build/devilutionx.ipk}" +readonly IN="${2:-../../build/devilutionx.dge}" + +readonly PKG_TARGET=devilutionx +readonly TMP="tmp/${PKG_TARGET}" + +pkg_control_get() { + sed -n control -e 's/^.*'"$1"': //p' +} + +readonly PKG_SECTION="$(pkg_control_get Section)" +readonly PKG_INSTALL_DIR="home/retrofw/${PKG_SECTION}/${PKG_TARGET}" +readonly PKG_LOCAL_DIR="home/retrofw/.local/share/diasurgical/devilution" +readonly PKG_MENU_LNK_OUT="home/retrofw/apps/gmenu2x/sections/${PKG_SECTION}/${PKG_TARGET}.lnk" + +echo 1>&2 Packaging ${OUT} from ${TMP}... + +set -x +rm -rf "${TMP}" +mkdir -p "${TMP}" + +# data.tar.gz +mkdir -p "${TMP}/root/${PKG_INSTALL_DIR}" "${TMP}/root/${PKG_LOCAL_DIR}" +cp "$IN" "${TMP}/root/${PKG_INSTALL_DIR}/${PKG_TARGET}.dge" +cp ../resources/Diablo_32.png "${TMP}/root/${PKG_INSTALL_DIR}/devilutionx.png" +cp devilutionx.man.txt ../resources/CharisSILB.ttf ../resources/LICENSE.CharisSILB.txt "${TMP}/root/${PKG_INSTALL_DIR}" +cp diablo.ini "${TMP}/root/${PKG_LOCAL_DIR}/diablo.ini" +mkdir -p "${TMP}/root/$(dirname "$PKG_MENU_LNK_OUT")" +printf "%s\n" \ + "title=DevilutionX" \ + "description=$(pkg_control_get Description)" \ + "exec=/${PKG_INSTALL_DIR}/${PKG_TARGET}.dge" \ + > "${TMP}/root/${PKG_MENU_LNK_OUT}" +tar --owner=0 --group=0 -czvf "${TMP}/data.tar.gz" -C "${TMP}/root/" . + +# control.tar.gz +sed -e "s/^Version:.*/Version: $(date +%Y%m%d)/" control > "${TMP}/control" +printf "%s\n" \ + "/$PKG_MENU_LNK_OUT" \ + "/${PKG_LOCAL_DIR}/diablo.ini" \ + >> ${TMP}/conffiles +tar --owner=0 --group=0 -czvf "${TMP}/control.tar.gz" -C "${TMP}/" control conffiles + +printf '2.0\n' > "${TMP}/debian-binary" +ar r "$OUT" \ + "${TMP}/control.tar.gz" \ + "${TMP}/data.tar.gz" \ + "${TMP}/debian-binary" diff --git a/README.md b/README.md index 53ca99331..918e15e87 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,36 @@ cmake --build . -j $(nproc) ``` +
OpenDingux / RetroFW + +DevilutionX uses buildroot to build packages for OpenDingux and RetroFW. + +The build script does the following: + +1. Downloads and configures the buildroot if necessary. +2. Builds the executable (using CMake). +3. Packages the executable and all related resources into an `.ipk` package. + +The buildroot uses ~4 GiB of disk space and can take almost an hour to build. + +### OpenDingux + +The OpenDingux build uses the buildroot at `$HOME/buildroot-2018.02.9-opendingux-musl`. + +~~~ bash +Packaging/OpenDingux/build-opendingux-sdl1.sh +~~~ + +### RetroFW + +The OpenDingux build uses the buildroot at `$HOME/buildroot-2018.02.9-retrofw`. + +~~~ bash +Packaging/OpenDingux/build-retrofw.sh +~~~ + +
+ ## CMake arguments ### General The default build type is `Debug`. This can be changed with `-DBINARY_RELEASE=ON`. Independently of this, the debug mode of the Diablo engine is always enabled by default. It can be disabled with `-DDEBUG=OFF`. Finally, in debug builds the address sanitizer is enabled by default. This can be disabled with `-DASAN=OFF`.