mirror of
				https://github.com/Zelda64Recomp/Zelda64Recomp.git
				synced 2025-10-30 08:03:03 +00:00 
			
		
		
		
	Flatpak support. (#569)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				validate-internal / build (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	validate-internal / build (push) Has been cancelled
				
			* Add flatpak support. * Add gamepad to supported controls list in flatpak metainfo --------- Co-authored-by: Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									c27300e6c8
								
							
						
					
					
						commit
						14f92c41ab
					
				
					 9 changed files with 185 additions and 7 deletions
				
			
		
							
								
								
									
										54
									
								
								.github/workflows/validate.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								.github/workflows/validate.yml
									
										
									
									
										vendored
									
									
								
							|  | @ -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: | ||||
|  |  | |||
							
								
								
									
										4
									
								
								flatpak/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								flatpak/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | |||
| .flatpak-builder | ||||
| builddir | ||||
| repo | ||||
| *.flatpak | ||||
							
								
								
									
										15
									
								
								flatpak/README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								flatpak/README.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||
| ``` | ||||
| 
 | ||||
							
								
								
									
										8
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.desktop
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.desktop
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||
							
								
								
									
										63
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -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" | ||||
|         ] | ||||
|       } | ||||
|     } | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										29
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								flatpak/io.github.zelda64recomp.zelda64recomp.metainfo.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <component type="desktop-application"> | ||||
|   <id>io.github.zelda64recomp.zelda64recomp</id> | ||||
|    | ||||
|   <name>Zelda 64: Recompiled</name> | ||||
|   <summary>Static recompilation of Majora's Mask (and soon Ocarina of Time) for PC.</summary> | ||||
|    | ||||
|   <metadata_license>CC0-1.0</metadata_license> | ||||
|   <project_license>GPL-3.0+</project_license> | ||||
|    | ||||
|   <supports> | ||||
|     <control>pointing</control> | ||||
|     <control>keyboard</control> | ||||
|     <control>touch</control> | ||||
|     <control>gamepad</control> | ||||
|   </supports> | ||||
|    | ||||
|   <description> | ||||
|     <p> | ||||
|       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 | ||||
|     </p> | ||||
|   </description> | ||||
|    | ||||
|   <launchable type="desktop-id">io.github.zelda64recomp.zelda64recomp.desktop</launchable> | ||||
| </component> | ||||
|  | @ -8,6 +8,7 @@ | |||
| #include <list> | ||||
| 
 | ||||
| namespace zelda64 { | ||||
|     std::filesystem::path get_program_path(); | ||||
|     std::filesystem::path get_asset_path(const char* asset); | ||||
|     void open_file_dialog(std::function<void(bool success, const std::filesystem::path& path)> callback); | ||||
|     void open_file_dialog_multiple(std::function<void(bool success, const std::list<std::filesystem::path>& paths)> callback); | ||||
|  |  | |||
|  | @ -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<const char *>(controller_db_path.c_str())) < 0) { | ||||
|         fprintf(stderr, "Failed to load controller mappings: %s\n", SDL_GetError()); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<void(bool success, const std::filesystem::path& path)> callback) { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Darío
						Darío