From 2a9e443a8dc766c291a099d0fa84cd6de0cbb25d Mon Sep 17 00:00:00 2001 From: p2r3 Date: Sat, 13 Sep 2025 14:09:13 +0300 Subject: [PATCH] fix compilation on windows --- README.md | 4 ++-- build.bat | 32 -------------------------------- build.sh | 13 ++++++++++--- 3 files changed, 12 insertions(+), 37 deletions(-) delete mode 100644 build.bat diff --git a/README.md b/README.md index 13a2be4..66933d8 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ For microcontrollers, see the section on **compilation** below. ## Compilation Before compiling, you'll need to dump registry data from a vanilla Minecraft server. On Linux, this can be done automatically using the `extract_registries.sh` script. Otherwise, the manual process is as follows: create a folder called `notchian` here, and put a Minecraft server JAR in it. Then, follow [this guide](https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Data_Generators) to dump all of the registries. Finally, run `build_registries.js` with `node`, `bun`, or `deno`. -- To target Linux, install `gcc` and run `build.sh` -- To target Windows, install `gcc` and run `build.bat` +- To target Linux, install `gcc` and run `./build.sh` +- To target Windows, install [MSYS2](https://www.msys2.org/) (follow _all_ instructions on that page), and open the "MSYS2 MINGW64" shell once installed. From there, navigate to this project's directory and run `./build.sh`. Alternatively, install WSL and use `gcc`. Otherwise, there's no platform-native solution for Windows currently. - To target an ESP variant, set up a PlatformIO project (select the ESP-IDF framework, **not Arduino**) and clone this repository on top of it. See **Configuration** below for further steps. For better performance, consider changing the clock speed and enabling compiler optimizations. If you don't know how to do this, there are plenty of resources online. ## Configuration diff --git a/build.bat b/build.bat deleted file mode 100644 index 766897b..0000000 --- a/build.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -if not exist "include\registries.h" ( - echo Error: 'include/registries.h' is missing. - echo Please follow the 'Compilation' section of the README to generate it. - pause - exit /b 1 -) - -set "files=" -for %%f in (src\*.c) do ( - set "files=!files! %%f" -) - -if "%files%"=="" ( - echo No C source files found in "src". - pause - exit /b 1 -) - -if exist "bareiron.exe" del /q "bareiron.exe" - -gcc src\*.c -O3 -Iinclude -o bareiron.exe -if errorlevel 1 ( - echo Build failed. - pause - exit /b 1 -) else ( - echo Build succeeded: "bareiron.exe" - pause -) \ No newline at end of file diff --git a/build.sh b/build.sh index fb941c1..09ed5c7 100755 --- a/build.sh +++ b/build.sh @@ -1,11 +1,18 @@ #!/usr/bin/env bash +# Check for registries before attempting to compile, prevents confusion if [ ! -f "include/registries.h" ]; then echo "Error: 'include/registries.h' is missing." echo "Please follow the 'Compilation' section of the README to generate it." exit 1 fi -rm bareiron -gcc src/*.c -O3 -Iinclude -o bareiron -./bareiron +# Figure out executable suffix (for MSYS compilation) +case "$OSTYPE" in + msys*|cygwin*|win32*) exe=".exe" ;; + *) exe="" ;; +esac + +rm -f "bareiron$exe" +gcc src/*.c -O3 -Iinclude -o "bareiron$exe" +"./bareiron$exe"