diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9236ae9..b9c8c97 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -34,7 +34,7 @@ jobs: matrix: type: [ Debug, Release ] os: [ ubuntu-22.04 ] - name: ubuntu-18.04 (x64, ${{ matrix.type }}) + name: ubuntu-18.04 (x64, ${{ matrix.type }}, Native, AppImage) steps: - name: Copy the Node20 binary run: | @@ -113,7 +113,7 @@ jobs: matrix: type: [ Debug, Release ] os: [ ubuntu-22.04 ] - name: ${{ matrix.os }} (arm64, ${{ matrix.type }}) + name: ${{ matrix.os }} (arm64, ${{ matrix.type }}, Native, AppImage) steps: - name: Checkout uses: actions/checkout@v4 @@ -195,6 +195,56 @@ jobs: with: name: Zelda64Recompiled-AppImage-ARM64-${{ matrix.type }} path: Zelda64Recompiled-*.AppImage + build-linux-flatpak: + runs-on: ubuntu-latest + env: + FLATPAK_ID: io.github.zelda64recomp.zelda64recomp + FREEDESKTOP_VERSION: 23.08 + LLVM_VERSION: 18 + strategy: + matrix: + type: [ Debug, Release ] + os: [ ubuntu-latest ] + name: ${{ matrix.os }} (x64, ${{ matrix.type }}, Flatpak) + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + submodules: recursive + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.os }}-z64re-ccache-${{ matrix.type }}-x64-${{ inputs.N64RECOMP_COMMIT }} + - name: Install Linux Dependencies + run: | + sudo apt-get update + sudo apt-get install -y flatpak-builder ccache lld + + - name: Prepare Build + run: |- + git clone ${{ secrets.ZRE_REPO_WITH_PAT }} + ./zre/process.sh + + - name: Prepare Flatpak + run: | + flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + flatpak --user install -y flathub org.freedesktop.Sdk//${{ env.FREEDESKTOP_VERSION }} + flatpak --user install -y flathub org.freedesktop.Sdk.Extension.llvm${{ env.LLVM_VERSION }}//${{ env.FREEDESKTOP_VERSION }} + + - name: Build ZeldaRecomp + run: |- + export CCACHE_DIR=/tmp/ccache + git config --global protocol.file.allow always + make -C patches CC=clang LD=ld.lld + flatpak-builder --user --force-clean --install-deps-from=flathub --repo=repo --ccache builddir ./flatpak/${{ env.FLATPAK_ID }}.json + flatpak build-bundle repo ./${{ env.FLATPAK_ID }}.flatpak ${{ env.FLATPAK_ID }} --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: Zelda64Recompiled-Flatpak-X64-${{ matrix.type }} + path: ./${{ env.FLATPAK_ID }}.flatpak build-windows: runs-on: windows-latest strategy: diff --git a/flatpak/.gitignore b/flatpak/.gitignore new file mode 100644 index 0000000..9edbe83 --- /dev/null +++ b/flatpak/.gitignore @@ -0,0 +1,4 @@ +.flatpak-builder +builddir +repo +*.flatpak diff --git a/flatpak/README.md b/flatpak/README.md new file mode 100644 index 0000000..6f78704 --- /dev/null +++ b/flatpak/README.md @@ -0,0 +1,15 @@ +Before building the Flatpak, you must build the patches on the root directory first. **The LLVM Extension for freedesktop does not include the MIPS compiler and will fail to build the patches inside the flatpak**. +```sh +make -C patches CC=clang LD=ld.lld +``` + +Build +```sh +flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir io.github.zelda64recomp.zelda64recomp.json +``` + +Bundle +```sh +flatpak build-bundle repo io.github.zelda64recomp.zelda64recomp.flatpak io.github.zelda64recomp.zelda64recomp --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo +``` + diff --git a/flatpak/io.github.zelda64recomp.zelda64recomp.desktop b/flatpak/io.github.zelda64recomp.zelda64recomp.desktop new file mode 100644 index 0000000..b36b13a --- /dev/null +++ b/flatpak/io.github.zelda64recomp.zelda64recomp.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Zelda 64: Recompiled +Exec=/app/bin/Zelda64Recompiled +Type=Application +Icon=io.github.zelda64recomp.zelda64recomp +Categories=Game; +Comment=Static recompilation of Majora's Mask (and soon Ocarina of Time) for PC. +MimeType=x-scheme-handler/zelda64recomp diff --git a/flatpak/io.github.zelda64recomp.zelda64recomp.json b/flatpak/io.github.zelda64recomp.zelda64recomp.json new file mode 100644 index 0000000..8430401 --- /dev/null +++ b/flatpak/io.github.zelda64recomp.zelda64recomp.json @@ -0,0 +1,63 @@ +{ + "id": "io.github.zelda64recomp.zelda64recomp", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "sdk-extensions" : [ "org.freedesktop.Sdk.Extension.llvm18" ], + "finish-args": [ + "--share=network", + "--socket=wayland", + "--socket=fallback-x11", + "--socket=pulseaudio", + "--device=all", + "--filesystem=host", + "--filesystem=/media", + "--filesystem=/run/media", + "--filesystem=/mnt" + ], + "modules": [ + { + "name": "Zelda64Recompiled", + "buildsystem": "simple", + "build-commands": [ + "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S lib/N64Recomp -B lib/N64Recomp/cmake-build", + "cmake --build lib/N64Recomp/cmake-build --config Release --target N64Recomp --parallel", + "cmake --build lib/N64Recomp/cmake-build --config Release --target RSPRecomp --parallel", + "cp lib/N64Recomp/cmake-build/N64Recomp N64Recomp", + "cp lib/N64Recomp/cmake-build/RSPRecomp RSPRecomp", + "./N64Recomp us.rev1.toml", + "./RSPRecomp aspMain.us.rev1.toml", + "./RSPRecomp njpgdspMain.us.rev1.toml", + "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_MAKE_PROGRAM=ninja -DPATCHES_C_COMPILER=clang -DPATCHES_LD=ld.lld -G Ninja -S . -B cmake-build", + "cmake --build cmake-build --config Release --target Zelda64Recompiled --parallel", + "rm -rf assets/scss", + "mkdir -p /app/bin", + "cp cmake-build/Zelda64Recompiled /app/bin/Zelda64Recompiled", + "cp recompcontrollerdb.txt /app/bin/recompcontrollerdb.txt", + "cp -R assets /app/bin/assets", + "install -Dm644 icons/512.png /app/share/icons/hicolor/512x512/apps/${FLATPAK_ID}.png", + "install -Dm644 flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml", + "install -Dm644 flatpak/io.github.zelda64recomp.zelda64recomp.desktop /app/share/applications/${FLATPAK_ID}.desktop" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/N64Recomp/N64Recomp.git", + "commit": "989a86b36912403cd323de884bf834f2605ea770", + "dest": "lib/N64Recomp" + }, + { + "type": "dir", + "path": "../" + } + ], + "build-options": { + "append-path": "/usr/lib/sdk/llvm18/bin", + "prepend-ld-library-path": "/usr/lib/sdk/llvm18/lib", + "build-args": [ + "--share=network" + ] + } + } + ] +} diff --git a/flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml b/flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml new file mode 100644 index 0000000..8d2a11e --- /dev/null +++ b/flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml @@ -0,0 +1,29 @@ + + + io.github.zelda64recomp.zelda64recomp + + Zelda 64: Recompiled + Static recompilation of Majora's Mask (and soon Ocarina of Time) for PC. + + CC0-1.0 + GPL-3.0+ + + + pointing + keyboard + touch + gamepad + + + +

+ Zelda 64: Recompiled is a project that uses N64: Recompiled to statically recompile Majora's Mask (and soon Ocarina of Time) into a native port with many new features and enhancements. This project uses RT64 as the rendering engine to provide some of these enhancements. + + The original game is required to run this project. + + https://github.com/Zelda64Recomp/Zelda64Recomp +

+
+ + io.github.zelda64recomp.zelda64recomp.desktop +
diff --git a/include/zelda_support.h b/include/zelda_support.h index c35b827..e3e8f47 100644 --- a/include/zelda_support.h +++ b/include/zelda_support.h @@ -8,6 +8,7 @@ #include namespace zelda64 { + std::filesystem::path get_program_path(); std::filesystem::path get_asset_path(const char* asset); void open_file_dialog(std::function callback); void open_file_dialog_multiple(std::function& paths)> callback); diff --git a/src/main/main.cpp b/src/main/main.cpp index f703b0d..f075a6d 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -608,7 +608,8 @@ int main(int argc, char** argv) { reset_audio(48000); // Source controller mappings file - if (SDL_GameControllerAddMappingsFromFile("recompcontrollerdb.txt") < 0) { + std::u8string controller_db_path = (zelda64::get_program_path() / "recompcontrollerdb.txt").u8string(); + if (SDL_GameControllerAddMappingsFromFile(reinterpret_cast(controller_db_path.c_str())) < 0) { fprintf(stderr, "Failed to load controller mappings: %s\n", SDL_GetError()); } diff --git a/src/main/support.cpp b/src/main/support.cpp index 53f00b1..daad4d2 100644 --- a/src/main/support.cpp +++ b/src/main/support.cpp @@ -45,13 +45,20 @@ namespace zelda64 { // MARK: - Public API - std::filesystem::path get_asset_path(const char* asset) { - std::filesystem::path base_path = ""; + std::filesystem::path get_program_path() { #if defined(__APPLE__) - base_path = get_bundle_resource_directory(); + return get_bundle_resource_directory(); +#elif defined(__linux__) + std::error_code ec; + if (std::filesystem::exists("/.flatpak-info", ec)) { + return "/app/bin"; + } #endif + return ""; + } - return base_path / "assets" / asset; + std::filesystem::path get_asset_path(const char* asset) { + return get_program_path() / "assets" / asset; } void open_file_dialog(std::function callback) {