diff --git a/.github/workflows/build-doxygen.yml b/.github/workflows/build-doxygen.yml index 132588614..150c4a9f4 100644 --- a/.github/workflows/build-doxygen.yml +++ b/.github/workflows/build-doxygen.yml @@ -9,6 +9,8 @@ on: - "minecraft/**" - "docs/**" + workflow_dispatch: + jobs: build: permissions: diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 7fae0d7c4..7a87948c9 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -19,6 +19,8 @@ on: pull_request: paths: *workflow_paths + workflow_dispatch: + jobs: build-linux: runs-on: ubuntu-latest @@ -41,43 +43,31 @@ jobs: sudo apt-get install -y libc++-20-dev libc++abi-20-dev - name: Restore ccache - uses: actions/cache@v4 + uses: actions/cache@v5 with: - path: ~/.ccache + path: ${{ runner.temp }}/ccache key: ${{ runner.os }}-ccache-${{ hashFiles('**/meson.build') }} - - - name: Restore meson cache - uses: actions/cache@v4 - with: - path: ~/.cache/meson - key: ${{ runner.os }}-meson-${{ hashFiles('**/meson.build') }} + restore-keys: ${{ runner.os }}-ccache- - name: Configure Meson env: CC: "ccache clang" CXX: "ccache clang++" - CCACHE_DIR: ${{ runner.temp }}/ccache + CC_LD: lld + CXX_LD: lld run: | - mkdir -p "$CCACHE_DIR" - export CCACHE_DIR="$CCACHE_DIR" - meson setup build --wipe --native-file=./scripts/llvm_native.txt + meson setup build --wipe - name: Build with Meson env: - CC: "ccache clang" - CXX: "ccache clang++" CCACHE_DIR: ${{ runner.temp }}/ccache run: | - export CCACHE_DIR="${{ runner.temp }}/ccache" # Use all available cores for faster parallel builds meson compile -C build -j $(nproc) -v Minecraft.Client - - name: Install patchelf - run: sudo apt-get install -y patchelf - - name: Upload artifact uses: actions/upload-artifact@v4 with: name: minecraft-client-linux-${{ github.sha }} path: build/targets/app/Minecraft.Client - retention-days: 7 \ No newline at end of file + retention-days: 7 diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 84820ad88..b9e7f8c0b 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -19,6 +19,8 @@ on: pull_request: paths: *workflow_paths + workflow_dispatch: + jobs: clang-format: runs-on: ubuntu-latest diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml new file mode 100644 index 000000000..a44c987e6 --- /dev/null +++ b/.github/workflows/release-linux.yml @@ -0,0 +1,87 @@ +name: Nightly (Linux, x86-64) + +on: + push: + paths: &workflow_paths + - '**.cpp' + - '**.h' + - '**.c' + - '**.cc' + - '**.cxx' + - '**.hh' + - '**.hpp' + - '**.hxx' + - '**.inl' + - "**meson.build" + - "flake.nix" + - '.github/workflows/build-linux.yml' + workflow_dispatch: + +jobs: + build-linux: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential ccache python3 python3-pip ninja-build libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev libglm-dev + python -m pip install meson + ccache -M 5G || true + + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-${{ hashFiles('**/meson.build') }} + + - name: Restore meson cache + uses: actions/cache@v4 + with: + path: ~/.cache/meson + key: ${{ runner.os }}-meson-${{ hashFiles('**/meson.build') }} + + - name: Configure Meson + env: + CC: "ccache clang" + CXX: "ccache clang++" + CCACHE_DIR: ${{ runner.temp }}/ccache + run: | + mkdir -p "$CCACHE_DIR" + export CCACHE_DIR="$CCACHE_DIR" + meson setup build --wipe --native-file=./scripts/llvm_native.txt + + - name: Build with Meson + env: + CC: "ccache clang" + CXX: "ccache clang++" + CCACHE_DIR: ${{ runner.temp }}/ccache + run: | + export CCACHE_DIR="${{ runner.temp }}/ccache" + meson compile -C build -j $(nproc) + + - name: Install patchelf + run: sudo apt-get install -y patchelf + + - name: Package artifact + run: | + cd build + zip -r ../minecraft-client-linux.zip Minecraft.Client --exclude "Minecraft.Client/Minecraft.Client.p/*" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: minecraft-client-linux-${{ github.sha }} + path: minecraft-client-linux.zip + retention-days: 7 + + - name: Create nightly release + uses: softprops/action-gh-release@v2 + with: + tag_name: nightly + name: Nightly + prerelease: true + files: minecraft-client-linux.zip diff --git a/README.md b/README.md index 065d71a50..b5c6be697 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ At the moment, we're aiming to support the following platforms: Please note that these percentages are **estimates** and do not necessarily reflect the final playability of the game on each platform. -- Linux (~85%) +- Linux (~90%) - Emscripten (~10%) [[Check the Emscripten Branch](https://github.com/4jcraft/4jcraft/tree/feat/emscripten)] - macOS (not started) [No official support but people have been able to run the game on MacOS] - iOS (not started) -- Android (~5%) +- Android (~35%) > [!WARNING] > There is NO Windows support, for that, go to [smartcmd/MinecraftConsoles](https://github.com/smartcmd/MinecraftConsoles/). diff --git a/flake.nix b/flake.nix index 05ceb4fef..699f7a74c 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,7 @@ flake = false; }; + # patches only get applied if they follow -patch naming miniaudio-patch = { url = "https://wrapdb.mesonbuild.com/v2/miniaudio_0.11.22-2/get_patch"; flake = false; @@ -37,16 +38,51 @@ }; outputs = - { - self, - nixpkgs, - flake-utils, - ... - }@inputs: + { self, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; }; + lib = pkgs.lib; + + subprojectNames = [ + "shiggy" + "4jlibs" + "stb" + "simdutf" + "miniaudio" + ]; + + # helper: copy all subproject sources + copySubprojects = '' + mkdir -p $sourceRoot/subprojects + ${lib.concatMapStringsSep "\n" (name: "cp -r ${inputs.${name}} $sourceRoot/subprojects/${name}") subprojectNames} + chmod -R u+w $sourceRoot/subprojects + ''; + + # helper: copy packagefiles + copyPackagefiles = '' + for proj in ${builtins.toString subprojectNames}; do + if [ -d "subprojects/packagefiles/$proj" ]; then + cp -r subprojects/packagefiles/$proj/* subprojects/$proj/ + fi + done + ''; + + # helper: apply patches from '-patch' inputs + applyPatches = lib.concatMapStringsSep "\n" (name: '' + patch_input="${inputs.${name + "-patch"} or ""}" + if [ -n "$patch_input" ]; then + unzip "$patch_input" -d ${name}-patch-tmp + if [ $(ls -1 ${name}-patch-tmp | wc -l) -eq 1 ] && [ -d ${name}-patch-tmp/* ]; then + cp -r ${name}-patch-tmp/*/* subprojects/${name}/ + else + cp -r ${name}-patch-tmp/* subprojects/${name}/ + fi + rm -rf ${name}-patch-tmp + fi + '') subprojectNames; + in { packages.default = pkgs.clangStdenv.mkDerivation { @@ -57,34 +93,18 @@ dontFixup = true; dontUseCmakeConfigure = true; - # 4jcraft - Meson expects this subprojects structure postUnpack = '' - mkdir -p $sourceRoot/subprojects - - cp -r ${inputs.shiggy} $sourceRoot/subprojects/shiggy - cp -r ${inputs."4jlibs"} $sourceRoot/subprojects/4jlibs - cp -r ${inputs.stb} $sourceRoot/subprojects/stb - cp -r ${inputs.simdutf} $sourceRoot/subprojects/simdutf - cp -r ${inputs.miniaudio} $sourceRoot/subprojects/miniaudio - - chmod -R u+w $sourceRoot/subprojects + ${copySubprojects} ''; - # 4jcraft - `stb` and `simdutf` patches postPatch = '' - cp subprojects/packagefiles/stb/meson.build subprojects/stb/meson.build - cp subprojects/packagefiles/simdutf/meson.build subprojects/simdutf/meson.build - cp subprojects/packagefiles/simdutf/meson.options subprojects/simdutf/meson.options + # Remove wrap files so Meson doesn't try to download them + for proj in ${builtins.toString subprojectNames}; do + rm -f subprojects/$proj.wrap + done - unzip ${inputs.miniaudio-patch} -d miniaudio-patch-tmp - cp -r miniaudio-patch-tmp/*/. subprojects/miniaudio/ - - cat > subprojects/miniaudio.wrap <