fix compilation on windows

This commit is contained in:
p2r3
2025-09-13 14:09:13 +03:00
parent 8d75d0a75f
commit 2a9e443a8d
3 changed files with 12 additions and 37 deletions

View File

@@ -17,8 +17,8 @@ For microcontrollers, see the section on **compilation** below.
## Compilation ## 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`. 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 Linux, install `gcc` and run `./build.sh`
- To target Windows, install `gcc` and run `build.bat` - 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. - 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 ## Configuration

View File

@@ -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
)

View File

@@ -1,11 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Check for registries before attempting to compile, prevents confusion
if [ ! -f "include/registries.h" ]; then if [ ! -f "include/registries.h" ]; then
echo "Error: 'include/registries.h' is missing." echo "Error: 'include/registries.h' is missing."
echo "Please follow the 'Compilation' section of the README to generate it." echo "Please follow the 'Compilation' section of the README to generate it."
exit 1 exit 1
fi fi
rm bareiron # Figure out executable suffix (for MSYS compilation)
gcc src/*.c -O3 -Iinclude -o bareiron case "$OSTYPE" in
./bareiron msys*|cygwin*|win32*) exe=".exe" ;;
*) exe="" ;;
esac
rm -f "bareiron$exe"
gcc src/*.c -O3 -Iinclude -o "bareiron$exe"
"./bareiron$exe"