diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..24785fa5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false + +[*.yml] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..317e19d1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,191 @@ +name: Ninecraft build + +on: + - workflow_dispatch + - push + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + strategy: + fail-fast: false + matrix: + target: [ ubuntu-latest ] + arch: [i686,arm] + include: + - target: windows-latest + arch: i686 + out: portable + runs-on: ${{matrix.target}} + container: ${{ matrix.arch == 'arm' && matrix.target == 'ubuntu-latest' && 'debian:bookworm' || null }} + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + if: matrix.arch != 'arm' || matrix.target != 'ubuntu-latest' + with: + submodules: true + + + + + - name: Set up Python + id: python + if: matrix.target == 'windows-latest' + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install Python dependencies + if: matrix.target == 'windows-latest' + run: | + python -m pip install --upgrade pip + pip install jinja2 + + - name: check python + if: matrix.target == 'windows-latest' + run: | + pip list + pip show jinja2 + python3 -c "import sys; print(sys.path)" + python3 -c "import jinja2" + + - name: Get Debian Architecture + id: debian + if: ${{matrix.target == 'ubuntu-latest'}} + run: | + if [ "${{ matrix.arch }}" = "i686" ]; then + echo arch=i386 >> $GITHUB_OUTPUT + fi + if [ "${{ matrix.arch }}" = "arm" ]; then + echo arch=armhf >> $GITHUB_OUTPUT + fi + + + - name: Get AppImage Architecture + id: appimage + if: ${{matrix.target == 'ubuntu-latest'}} + run: | + if [ "${{ matrix.arch }}" = "i686" ]; then + echo arch=i686 >> $GITHUB_OUTPUT + fi + if [ "${{ matrix.arch }}" = "arm" ]; then + echo arch=armhf >> $GITHUB_OUTPUT + fi + + - name: Setup APT ${{matrix.arch}} + if: matrix.target == 'ubuntu-latest' + run: | + ${{matrix.arch == 'i686' && 'sudo' || ''}} dpkg --add-architecture ${{steps.debian.outputs.arch}} + ${{matrix.arch == 'i686' && 'sudo' || ''}} apt update -y + ${{matrix.arch == 'i686' && 'sudo' || ''}} apt install -y gnupg archlinux-keyring file git pacman-package-manager wget make cmake unzip python3-jinja2 zenity libopenal-dev:${{steps.debian.outputs.arch}} libx11-dev:${{steps.debian.outputs.arch}} libxrandr-dev:${{steps.debian.outputs.arch}} libxinerama-dev:${{steps.debian.outputs.arch}} libxcursor-dev:${{steps.debian.outputs.arch}} libxi-dev:${{steps.debian.outputs.arch}} libgl-dev:${{steps.debian.outputs.arch}} libwayland-dev:${{steps.debian.outputs.arch}} libpulse-dev:${{steps.debian.outputs.arch}} libxkbcommon-dev:${{steps.debian.outputs.arch}} libegl-dev:${{steps.debian.outputs.arch}} + + - name: Install GCC-Multilib + if: ${{matrix.target == 'ubuntu-latest' && matrix.arch == 'i686'}} + run: ${{matrix.arch == 'i686' && 'sudo' || ''}} apt install -y gcc g++ gcc-multilib g++-multilib + + - name: Install GCC-gnueabihf + if: ${{matrix.target == 'ubuntu-latest' && matrix.arch == 'arm'}} + run: ${{matrix.arch == 'i686' && 'sudo' || ''}} apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf + + - name: Setup AppImageTool + if: ${{matrix.target == 'ubuntu-latest' }} + uses: AnimMouse/setup-appimage@v1 + with: + name: appimagetool + url: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage + + + - if: matrix.arch == 'arm' + run: | + git config --global --add safe.directory /__w/Ninecraft/Ninecraft + git clone http://github.com/$GITHUB_REPOSITORY . --recursive + git switch $GITHUB_REF_NAME + + + - name: Build ${{matrix.arch}}-linux + if: matrix.target != 'windows-latest' + run: make build-${{matrix.arch}} + + - name: Build ${{matrix.arch}}-windows + if: matrix.target == 'windows-latest' + run: + | + cmake -B ${{github.workspace}}/build -A Win32 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + + - name: Upload Windows + uses: actions/upload-artifact@v4 + if: ${{ matrix.target == 'windows-latest' }} + with: + name: ninecraft-${{matrix.arch}}-windows + path: build/${{ env.BUILD_TYPE }}/ninecraft/ninecraft.exe + + - name: Upload Linux + uses: actions/upload-artifact@v4 + if: ${{matrix.target != 'windows-latest' }} + with: + name: ninecraft-${{matrix.arch}}-linux + path: build-${{matrix.arch}}/ninecraft/ninecraft + + - name: Build Deb + if: ${{matrix.target == 'ubuntu-latest' }} + run: | + ls -al + mkdir -p pkgs/deb/usr/bin + mkdir -p pkgs/deb/usr/share/applications + ls -al pkgs + ls -al pkgs/deb + cp build-${{matrix.arch}}/ninecraft/ninecraft pkgs/deb/usr/bin + cp tools/extract.sh pkgs/deb/usr/bin/ninecraft-extract + dpkg-deb -b pkgs/deb + + - name: Upload Deb + if: ${{matrix.target == 'ubuntu-latest' }} + uses: actions/upload-artifact@v4 + with: + name: ninecraft-${{matrix.arch}}-linux.deb + path: pkgs/deb.deb + + - name: Build AppImage + if: ${{matrix.target == 'ubuntu-latest' }} + run: | + wget https://archive.org/download/MCPEAlpha/PE-a0.6.1-x86.apk + ./tools/extract.sh ./PE-a0.6.1-x86.apk + mkdir -p pkgs/appimage/usr/bin + cp build-${{matrix.arch}}/ninecraft/ninecraft pkgs/appimage/usr/bin + cp res/drawable/iconx.png pkgs/appimage/ninecraft.png + ARCH=${{steps.appimage.outputs.arch}} appimagetool ./pkgs/appimage/ + + - name: Upload Appimage + if: ${{matrix.target == 'ubuntu-latest' }} + uses: actions/upload-artifact@v4 + with: + name: ninecraft-${{matrix.arch}}-linux.AppImage + path: ./*.AppImage + + + - name: Build Arch pkg + if: ${{matrix.target == 'ubuntu-latest' }} + run: | + ${{matrix.arch == 'i686' && 'sudo' || ''}} sh ./pkgs/setup-pacman.sh + cp build-${{matrix.arch}}/ninecraft/ninecraft pkgs/arch + cd pkgs/arch + ${{matrix.arch == 'i686' && 'sudo' || ''}} pacman -Syy + makepkg -si --nobuild + # - name: Build Arch Linux package + # uses: FFY00/build-arch-package@v1 + # with: + # PKGBUILD: pkgs/arch/PKGBUILD + # OUTDIR: $HOME + + - name: Upload Arch pkg + if: ${{matrix.target == 'ubuntu-latest' }} + uses: actions/upload-artifact@v4 + with: + name: ninecraft-${{matrix.arch}}-linux.pkgs.tar + path: ninecraft.pkg.tar \ No newline at end of file diff --git a/.github/workflows/ninecraft-x86-linux-build.yml b/.github/workflows/ninecraft-x86-linux-build.yml index ce5e4761..15a32d44 100644 --- a/.github/workflows/ninecraft-x86-linux-build.yml +++ b/.github/workflows/ninecraft-x86-linux-build.yml @@ -18,6 +18,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Install Dependencies run: | @@ -25,8 +27,9 @@ jobs: sudo apt update sudo apt install git make cmake unzip python3-jinja2 zenity gcc g++ gcc-multilib g++-multilib libopenal-dev:i386 libx11-dev:i386 libxrandr-dev:i386 libxinerama-dev:i386 libxcursor-dev:i386 libxi-dev:i386 libgl-dev:i386 libwayland-dev:i386 libpulse-dev:i386 libxkbcommon-dev:i386 libegl-dev:i386 - - name: Gather Submodules - run: git submodule update --init + # not needed because the about actions/checkout has that funtionality: https://github.com/actions/checkout?tab=readme-ov-file#usage + # - name: Gather Submodules + # run: git submodule update --init - name: Build run: make build-i686 @@ -36,3 +39,34 @@ jobs: with: name: ninecraft path: build-i686/ninecraft/ninecraft + + - name: Build Deb + run: | + mkdir -p pkgs/ninecraft/usr/bin + cp build-i686/ninecraft/ninecraft pkgs/ninecraft/usr/bin + cp tools/extract.sh pkgs/ninecraft/usr/bin/ninecraft-extract + dpkg-deb -b pkgs/ninecraft + + - name: Upload Deb + uses: actions/upload-artifact@v4 + with: + name: ninecraft.deb + path: pkgs/ninecraft.deb + + + - name: Setup AppImageTool + uses: AnimMouse/setup-appimage@v1 + with: + name: appimagetool + url: https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage + + - name: Build Appimage + run: | + mkdir -p pkgs/Ninecraft.AppDir/usr/bin + cp build-i686/ninecraft/ninecraft pkgs/Ninecraft.AppDir/usr/bin + ARCH=X86_64 appimagetool ./pkgs/Ninecraft.AppDir/ + - name: Upload Appimage + uses: actions/upload-artifact@v4 + with: + name: ninecraft.AppImage + path: ./*.AppImage diff --git a/.gitignore b/.gitignore index 4d0401fb..6a69dd91 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ a.out result/ result result* +*.deb +/pkgs/ninecraft/*/bin +pkgs/Ninecraft.AppDir/.DirIcon diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 00000000..23a59202 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,42 @@ +projectName=ninecraft + +pkgname=$projectName +pkgrel=1 +pkgpsc="A mcpe 0.1 .0 - 0.10 .5 launcher for linux and windows" +arch=("any") +url="" +license=('MIT') +groups=() +depends=('git' + 'make' + 'cmake' + 'gcc' + 'gcc-multilib' + 'lib32-openal' + 'lib32-libx11' + 'lib32-libxrandr' + 'lib32-libxinerama' + 'lib32-libxcursor' + 'lib32-libxi' + 'lib32-libglvnd' + 'zenity' + 'unzip' + 'python-jinja') +optdepends=() +provides=() +conflicts=() +replaces=() +backup=() +options=() +install= +changelog= +source=('project-path') +noextract=() +md5sums=('SKIP') + + +package () { + projectPath=$(cat project-path) +mkdir -p "$pkgdir/usr/"{"bin","share/applications"} +install -Dm755 $projectPath/build-(arch)/ninecraft/ninecraft $pkgdir/usr/bin +} \ No newline at end of file diff --git a/flake.nix b/flake.nix index 67f652df..df819e6c 100644 --- a/flake.nix +++ b/flake.nix @@ -58,9 +58,9 @@ }; }; formatter = pkgs.alejandra; - devShell = pkgs.callPackage ./nix/shell.nix { - inherit (packages) ninecraft ninecraft-nixgl; - }; + devShell = + pkgs.callPackage ./nix/shell.nix { + }; }) // { nixosModule = {pkgs, ...}: { diff --git a/nix/shell.nix b/nix/shell.nix index 11505597..88cad284 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,13 +1,17 @@ -{ - mkShell, - ninecraft, - ninecraft-extract, - ninecraft-nixgl, -}: -mkShell { - packages = [ - ninecraft - ninecraft-extract - ninecraft-nixgl - ]; -} +# compilation shell +with (import {}).pkgsi686Linux; + mkShell { + packages = [ + gnumake + pkg-config + cmake + libgcc + python312Packages.jinja2 + zlib + SDL2 + + # packaging + dpkg + pacman + ]; + } diff --git a/pkgs/appimage/AppRun b/pkgs/appimage/AppRun new file mode 100644 index 00000000..850f71bc --- /dev/null +++ b/pkgs/appimage/AppRun @@ -0,0 +1,2 @@ +HERE="$(dirname "$(readlink -f "${0}")")" +EXEC=$HERE/usr/bin/ninecraft \ No newline at end of file diff --git a/pkgs/appimage/Ninecraft.desktop b/pkgs/appimage/Ninecraft.desktop new file mode 100644 index 00000000..3684a027 --- /dev/null +++ b/pkgs/appimage/Ninecraft.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Ninecraft +Exec=ninecraft --game "~/.local/share/ninecraft" --home "~/.local/share/ninecraft" +Icon=ninecraft +Type=Application +Categories=Game;AdventureGame +Comment=A mcpe 0.1 .0 - 0.10 .5 launcher for linux and windows +GenericName=MCPE Alpha Player +Keywords=mcpe;android;mcpi;pocket;edition diff --git a/pkgs/arch/PKGBUILD b/pkgs/arch/PKGBUILD new file mode 100644 index 00000000..23a391af --- /dev/null +++ b/pkgs/arch/PKGBUILD @@ -0,0 +1,48 @@ +projectName=ninecraft + +pkgname=$projectName +pkgrel=1 +pkgver="1.2.0" +pkgpsc="A mcpe 0.1 .0 - 0.10 .5 launcher for linux and windows" +arch=("any") +url="" +license=('MIT') +groups=() +depends=('git' + 'make' + 'cmake' + 'gcc' + 'gcc-multilib' + 'lib32-openal' + 'lib32-libx11' + 'lib32-libxrandr' + 'lib32-libxinerama' + 'lib32-libxcursor' + 'lib32-libxi' + 'lib32-libglvnd' + 'zenity' + 'unzip' + 'python-jinja') +optdepends=() +provides=() +conflicts=() +replaces=() +backup=() +options=() +install= +changelog= +source=('project-path') +noextract=() +md5sums=('SKIP') + + + +# build() { + +# } + +package () { + projectPath=$(cat project-path) + mkdir -p "$pkgdir/usr/"{"bin","share/applications"} + install -Dm755 $projectPath/ninecraft $pkgdir/usr/bin +} \ No newline at end of file diff --git a/pkgs/deb/DEBIAN/control b/pkgs/deb/DEBIAN/control new file mode 100644 index 00000000..7acd527a --- /dev/null +++ b/pkgs/deb/DEBIAN/control @@ -0,0 +1,5 @@ +Package: ninecraft +Version: 1.2.0 +Architecture: all +Maintainer: MJD-Gaming +Description: Short description of your program diff --git a/pkgs/setup-pacman.sh b/pkgs/setup-pacman.sh new file mode 100644 index 00000000..8bed191f --- /dev/null +++ b/pkgs/setup-pacman.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# 1. Ensure pacman dirs exist +mkdir -p /etc/pacman.d /var/lib/pacman /var/cache/pacman/pkg + +# 2. Create a minimal pacman.conf +tee /etc/pacman.conf > /dev/null <