diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index eb0be0c03..86a791961 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -10,14 +10,24 @@ jobs: fail-fast: false matrix: include: - - name: SDL 2 (OGL) + - name: x86_64 SDL 2 (OGL) flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL' packages: 'libsdl2-dev' - - name: SDL 2 (OGL + Shaders) + runner: ubuntu-24.04 + - name: x86_64 SDL 2 (OGL + Shaders) flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL_SHADERS' packages: 'libsdl2-dev' + runner: ubuntu-24.04 + - name: aarch64 SDL 2 (OGL) + flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL' + packages: 'libsdl2-dev' + runner: ubuntu-24.04-arm + - name: aarch64 SDL 2 (OGL + Shaders) + flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL_SHADERS' + packages: 'libsdl2-dev' + runner: ubuntu-24.04-arm name: Linux (${{ matrix.name }}) - runs-on: ubuntu-24.04 + runs-on: ${{ matrix.runner }} steps: - name: Get Time id: get-time @@ -63,6 +73,65 @@ jobs: - name: Pack cache run: cd ~ && tar cJf ccache.tar.xz .cache/ccache + # flatpak: + # strategy: + # fail-fast: false + # matrix: + # include: + # - name: x86_64 SDL 2 (OGL) + # gfx-api: OGL + # arch: x86_64 + # runner: ubuntu-24.04 + # - name: x86_64 SDL 2 (OGL + Shaders) + # gfx-api: OGL_SHADERS + # arch: x86_64 + # runner: ubuntu-24.04 + # - name: aarch64 SDL 2 (OGL) + # gfx-api: OGL + # arch: aarch64 + # runner: ubuntu-24.04-arm + # - name: aarch64 SDL 2 (OGL + Shaders) + # gfx-api: OGL_SHADERS + # arch: aarch64 + # runner: ubuntu-24.04-arm + # name: Flatpak (${{ matrix.name }}) + # runs-on: ${{ matrix.runner }} + # steps: + # - name: Get Time + # id: get-time + # run: echo "time=$(date -u '+%Y-%m-%d-%H:%M:%S')" >> $GITHUB_OUTPUT + # - uses: actions/cache@v5 + # with: + # path: ~/ccache.tar.xz + # key: flatpak-artifact-${{ matrix.name }}-${{ steps.get-time.outputs.time }} + # restore-keys: flatpak-artifact-${{ matrix.name }}- + # - name: Unpack cache + # run: cd ~ && [ -f ccache.tar.xz ] && tar xf ccache.tar.xz || true + # - name: Checkout Repository + # uses: actions/checkout@v6 + # with: + # submodules: true + # - name: Install Dependencies + # run: | + # sudo apt-get update + # sudo apt-get install --no-install-recommends -y flatpak + # flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo + # flatpak --user install -y \ + # org.freedesktop.Platform/${{ matrix.arch }}/25.08 \ + # org.freedesktop.Sdk/${{ matrix.arch }}/25.08 + # - name: Build + # run: ./platforms/linux/build-flatpak.sh + # env: + # NOSTRIP: 1 + # ARCH: ${{ matrix.arch }} + # REMCPE_GFX_API: ${{ matrix.gfx }} + # - uses: actions/upload-artifact@v6 + # with: + # name: Flatpak (${{ matrix.name }}) + # path: platforms/linux/build-flatpak/ReMCPE-${{ matrix.arch }}.flatpak + # - name: Pack cache + # run: cd ~ && tar cJf ccache.tar.xz .cache/ccache + # linux32: # strategy: # fail-fast: false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7d948726..11be0162e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,11 +10,18 @@ jobs: fail-fast: false matrix: include: - - name: SDL 2 + - name: x86_64 SDL 2 + flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL' + packages: 'libsdl2-dev' + runner: ubuntu-24.04 + arch: x86_64 + - name: aarch64 SDL 2 flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL' packages: 'libsdl2-dev' + runner: ubuntu-24.04-arm + arch: aarch64 name: Linux (${{ matrix.name }}) - runs-on: ubuntu-24.04 + runs-on: ${{ matrix.runner }} steps: - name: Checkout Repository uses: actions/checkout@v6 @@ -43,12 +50,51 @@ jobs: run: | mkdir ReMCPE mv game/assets build/reminecraftpe ReMCPE - tar -czf ReMCPE-Linux-x86_64.tar.gz ReMCPE + tar -czf ReMCPE-Linux-${{ matrix.arch }}.tar.gz ReMCPE - uses: alexellis/upload-assets@0.4.1 env: GITHUB_TOKEN: ${{ github.token }} with: - asset_paths: '["ReMCPE-Linux-x86_64.tar.gz"]' + asset_paths: '["ReMCPE-Linux-${{ matrix.arch }}.tar.gz"]' + + # flatpak: + # strategy: + # fail-fast: false + # matrix: + # include: + # - name: x86_64 SDL 2 + # gfx: OGL + # arch: x86_64 + # runner: ubuntu-24.04 + # - name: aarch64 SDL 2 + # gfx: OGL + # arch: aarch64 + # runner: ubuntu-24.04-arm + # name: Flatpak (${{ matrix.name }}) + # runs-on: ${{ matrix.runner }} + # steps: + # - name: Checkout Repository + # uses: actions/checkout@v6 + # with: + # submodules: true + # - name: Install Dependencies + # run: | + # sudo apt-get update + # sudo apt-get install --no-install-recommends -y flatpak + # flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo + # flatpak --user install -y \ + # org.freedesktop.Platform/${{ matrix.arch }}/25.08 \ + # org.freedesktop.Sdk/${{ matrix.arch }}/25.08 + # - name: Build + # run: ./platforms/linux/build-flatpak.sh + # env: + # ARCH: ${{ matrix.arch }} + # REMCPE_GFX_API: ${{ matrix.gfx }} + # - uses: alexellis/upload-assets@0.4.1 + # env: + # GITHUB_TOKEN: ${{ github.token }} + # with: + # asset_paths: '["platforms/linux/build-flatpak/ReMCPE-Linux-${{ matrix.arch }}.flatpak"]' # linux32: # strategy: diff --git a/game/assets/app/icons/mipmap/icon_128x128.png b/game/assets/app/icons/mipmap/icon_128x128.png new file mode 100644 index 000000000..747afe9ec Binary files /dev/null and b/game/assets/app/icons/mipmap/icon_128x128.png differ diff --git a/game/assets/app/icons/mipmap/icon_256x256.png b/game/assets/app/icons/mipmap/icon_256x256.png new file mode 100644 index 000000000..6072252e0 Binary files /dev/null and b/game/assets/app/icons/mipmap/icon_256x256.png differ diff --git a/game/assets/mob/cow.png b/game/assets/mob/cow.png old mode 100755 new mode 100644 diff --git a/game/assets/resource_packs/minecraft/.gitignore b/game/assets/resource_packs/minecraft/.gitignore old mode 100755 new mode 100644 diff --git a/game/assets/resource_packs/minecraft/pack.txt b/game/assets/resource_packs/minecraft/pack.txt old mode 100755 new mode 100644 diff --git a/platforms/ios/build.sh b/platforms/ios/build.sh index 5b5e8e7c0..25fd4655c 100755 --- a/platforms/ios/build.sh +++ b/platforms/ios/build.sh @@ -2,6 +2,7 @@ # shellcheck disable=2086 set -e +# cd to the directory this script is in [ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" cd "$scriptroot" @@ -191,7 +192,7 @@ for target in $targets; do -DCMAKE_C_FLAGS="$cflags" \ -DCMAKE_CXX_FLAGS="$cflags" \ -DWERROR="${WERROR:-OFF}" - make -j"$ncpus" + cmake --build . --parallel "$ncpus" cd .. done diff --git a/platforms/linux/.gitignore b/platforms/linux/.gitignore new file mode 100644 index 000000000..b7be2f2a7 --- /dev/null +++ b/platforms/linux/.gitignore @@ -0,0 +1 @@ +/build-flatpak diff --git a/platforms/linux/build-flatpak.sh b/platforms/linux/build-flatpak.sh new file mode 100755 index 000000000..b38934880 --- /dev/null +++ b/platforms/linux/build-flatpak.sh @@ -0,0 +1,128 @@ +#!/bin/sh +set -e + +# cd to the directory this script is in +[ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" +cd "$scriptroot" + +arch="${ARCH:-x86_64}" +# Must be kept in sync with the cmake executable name +bin='reminecraftpe' + +bundleid='io.github.reminecraftpe' + +platformdir=$PWD + +workdir="$PWD/build-flatpak/work" + +if command -v nproc >/dev/null; then + ncpus="$(nproc)" +else + ncpus="$(sysctl -n hw.ncpu)" +fi + +if [ -n "$DEBUG" ]; then + build=Debug +else + build=Release +fi + +rm -rf build-flatpak/output build-flatpak/work/build +mkdir -p build-flatpak/work/build +cd build-flatpak + +runtime="${FLATPAK_RUNTIME_VERSION:-25.08}" +[ "$ARCH" = 'i386' ] && runtime='1.6' + +flatpak build-init output "$bundleid" "org.freedesktop.Sdk/$arch" "org.freedesktop.Platform/$arch" "$runtime" + +cd work + +fpbuild() { + flatpak build ../../output "$@" +} + +cmake=cmake +set -- -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON + +toolchainver=2 +if [ "$ARCH" = 'i386' ]; then + if [ "$(cat toolchain/toolchainver 2>/dev/null)" != "$toolchainver" ]; then + printf '\nBuilding i386 toolchain...\n\n' + + cmake_version='4.2.3' + wget -O- "https://github.com/Kitware/CMake/archive/refs/tags/v$cmake_version.tar.gz" | tar -xz + cd "CMake-$cmake_version" + fpbuild ./bootstrap \ + --prefix="$workdir/toolchain" \ + --parallel="$ncpus" \ + --enable-ccache \ + --system-zlib \ + --system-bzip2 \ + --system-curl \ + --system-expat \ + --system-liblzma + fpbuild make -j"$ncpus" + fpbuild make install/strip -j"$ncpus" + cd .. + rm -rf "CMake-$cmake_version" + + rm -rf toolchain/doc share/emacs share/vim share/bash-completion + + printf '%s' "$toolchainver" > toolchain/toolchainver + fi + + set -- \ + -DREMCPE_VENDORED_SDL2=ON \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ + + cmake="$workdir/toolchain/bin/cmake" +fi + +cd build +fpbuild "$cmake" "$platformdir/../.." \ + -DCMAKE_BUILD_TYPE="$build" \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DREMCPE_PLATFORM="${REMCPE_PLATFORM:-sdl2}" \ + -DREMCPE_GFX_API="${REMCPE_GFX_API:-OGL}" \ + "$@" +fpbuild "$cmake" --build . --parallel "$ncpus" +fpbuild mkdir -p /app/bin /app/libexec /app/share/applications +[ -z "$DEBUG" ] && [ -z "$NOSTRIP" ] && + fpbuild strip "$bin" +fpbuild cp "$bin" /app/libexec +fpbuild cp -a "$(readlink assets)" /app +# rungame.sh is just a script that does a cd to the directory with the assets +fpbuild cp "$platformdir/rungame.sh" /app/bin +fpbuild cp "$platformdir/$bundleid.desktop" /app/share/applications +for size in 48 64 72 96 128 192 256; do + fpbuild install -Dm644 "assets/app/icons/mipmap/icon_${size}x${size}.png" \ + "/app/share/icons/hicolor/${size}x${size}/apps/$bundleid.png" +done + +cd ../.. + +# permissions given (in order of specification): +# X11 (when wayland is unavailable) +# Wayland +# Audio (both input and output) +# Device access (USB, game controllers, GPU, etc)* +# Network access +# +# *: Flatpak has --device=dri for GPU access, and --device=input for +# input devices (controllers), which would be enough for us, but it was +# added relatively recently, and older flatpak versions don't understand +# it, so we just do --device=all to make everything work on old systems. +flatpak build-finish output \ + --share=ipc \ + --socket=fallback-x11 \ + --socket=wayland \ + --socket=pulseaudio \ + --device=all \ + --share=network \ + --command=rungame.sh + +flatpak build-export repo output +flatpak build-bundle --arch "$arch" repo "ReMCPE-$arch.flatpak" "$bundleid" diff --git a/platforms/linux/io.github.reminecraftpe.desktop b/platforms/linux/io.github.reminecraftpe.desktop new file mode 100644 index 000000000..0a6ce3d99 --- /dev/null +++ b/platforms/linux/io.github.reminecraftpe.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=ReMinecraftPE +GenericName=ReMinecraftPE +Comment=A custom experience based on Minecraft PE as of 2011 +Exec=rungame.sh +Icon=io.github.reminecraftpe +Terminal=false +Type=Application +Categories=Game;Simulation; +Keywords=sandbox;world;mining;crafting;blocks;minecraft;mcpe; diff --git a/platforms/linux/rungame.sh b/platforms/linux/rungame.sh new file mode 100755 index 000000000..75441a6f1 --- /dev/null +++ b/platforms/linux/rungame.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd /app || exit 1 +exec ./libexec/reminecraftpe diff --git a/platforms/macos/build.sh b/platforms/macos/build.sh index fcd3bfd1f..4ecc53350 100755 --- a/platforms/macos/build.sh +++ b/platforms/macos/build.sh @@ -2,6 +2,7 @@ # shellcheck disable=2086 set -e +# cd to the directory this script is in [ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" cd "$scriptroot" @@ -52,7 +53,7 @@ if ! [ -d "$x86_64_sdk" ] || ! [ -d "$arm64_sdk" ] || ! [ -d "$old_sdk" ] || [ " mv MacOSX10.5.sdk "$old_sdk" # patch the sdk to fix a bug cd "$old_sdk" - patch -p1 < "$platformdir/leopard-sdk-fix.patch" + patch -fNp1 < "$platformdir/leopard-sdk-fix.patch" ) wait rm ./*.tar.bz2 ./*.tar.xz @@ -268,6 +269,7 @@ if [ "$(cat toolchain-ppc/toolchainver 2>/dev/null)" != "$ppctoolchainver" ]; th cd ../.. rm -rf "gcc-$gcc_version" + rm -rf toolchain-ppc/share printf '%s' "$ppctoolchainver" > toolchain-ppc/toolchainver outdated_ppc_toolchain=1 fi @@ -405,7 +407,7 @@ for target in $targets; do -DCMAKE_CXX_FLAGS="$target_cflags" \ -DWERROR="${WERROR:-OFF}" \ "$@" - make -j"$ncpus" + cmake --build . --parallel "$ncpus" cd .. done diff --git a/platforms/sdl/sdl2/CMakeLists.txt b/platforms/sdl/sdl2/CMakeLists.txt index f575bacfa..86bdb241c 100644 --- a/platforms/sdl/sdl2/CMakeLists.txt +++ b/platforms/sdl/sdl2/CMakeLists.txt @@ -39,7 +39,7 @@ if(ANDROID OR REMCPE_WIN32) set_target_properties(SDL2 PROPERTIES CXX_STANDARD 11) target_link_libraries(SDL INTERFACE SDL2::SDL2) target_compile_options(SDL2 PRIVATE -w) -elseif(APPLE) +elseif(APPLE OR REMCPE_VENDORED_SDL2) # Use Vendored SDL2 (explicitly static) add_subdirectory(../../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) set_target_properties(SDL2-static PROPERTIES CXX_STANDARD 11)