From 7206dd1b11e87867cf70d71b60d8a231608fa2e6 Mon Sep 17 00:00:00 2001 From: Anmol Date: Fri, 12 Sep 2025 21:11:01 +0530 Subject: [PATCH] create windows build script * Create build.bat * Update build.bat * added error handling * changed error to match build.sh * update readme to mention windows build script --------- Co-authored-by: zyriu1 Co-authored-by: p2r3 <41925384+p2r3@users.noreply.github.com> --- README.md | 2 +- build.bat | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 build.bat diff --git a/README.md b/README.md index 76a1eea..4d877ad 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ For microcontrollers, see the section on **compilation** below. Before compiling, you'll need to dump registry data from a vanilla Minecraft server. 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 an ESP variant, set up a PlatformIO project and clone this repository on top of it. See **Configuration** below for further steps. -- There's currently no streamlined build process for Windows. Contributions in this area are welcome! ## Configuration Configuring the server requires compiling it from its source code as described in the section above. diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..92c6135 --- /dev/null +++ b/build.bat @@ -0,0 +1,28 @@ +@echo off +setlocal enabledelayedexpansion +if not exist "%~dp0src\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 "delims=" %%f in ('dir /b "%~dp0src\*.c" 2^>nul') do ( + set "files=!files! "%~dp0src%%f"" +) +if "%files%"=="" ( + echo No C source files found in "%~dp0src". + echo Add .c files to the src folder and try again. + pause + exit /b 1 +) +if exist "%~dp0bareiron.exe" del /q "%~dp0bareiron.exe" +gcc %files% -o "%~dp0bareiron.exe" +if errorlevel 1 ( + echo Build failed. + pause + exit /b 1 +) else ( + echo Build succeeded: "%~dp0bareiron.exe" + pause +) \ No newline at end of file