@echo off setlocal enabledelayedexpansion cd /D "%~dp0" :: ------------------------------------------------------------- :: Parse Arguments :: ------------------------------------------------------------- set MODE=debug set ACTION=build set COMPILER=cl :parse_args if "%~1"=="" goto done_args if /I "%~1"=="debug" (set MODE=debug) if /I "%~1"=="release" (set MODE=release) if /I "%~1"=="run" (set ACTION=run) if /I "%~1"=="clean" (set ACTION=clean) if /I "%~1"=="clang" (set COMPILER=clang-cl) if /I "%~1"=="msvc" (set COMPILER=cl) shift goto parse_args :done_args if "%ACTION%"=="clean" ( echo [clean] Removing build directory... if exist build rmdir /s /q build if exist *.obj del /f /q *.obj if exist *.exp del /f /q *.exp if exist vc*.pdb del /f /q vc*.pdb echo [clean] Done. exit /b 0 ) :: ------------------------------------------------------------- :: Setup MSVC Environment if needed :: ------------------------------------------------------------- where %COMPILER% >nul 2>nul if %errorlevel% neq 0 ( echo [setup] Looking for Visual Studio installation... set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" if exist "!VSWHERE!" ( for /f "usebackq tokens=*" %%i in (`"!VSWHERE!" -latest -property installationPath`) do ( set "VS_PATH=%%i" ) if exist "!VS_PATH!\VC\Auxiliary\Build\vcvars64.bat" ( echo [setup] Initializing x64 MSVC environment... call "!VS_PATH!\VC\Auxiliary\Build\vcvars64.bat" >nul ) else ( echo [error] Could not find vcvars64.bat in "!VS_PATH!" exit /b 1 ) ) else ( echo [error] Visual Studio not detected. Please run from a Developer Command Prompt. exit /b 1 ) ) :: ------------------------------------------------------------- :: Ensure output directory exists :: ------------------------------------------------------------- if not exist build mkdir build :: ------------------------------------------------------------- :: Compiler and Linker Flags :: ------------------------------------------------------------- set INCLUDES=/I src /I vendor\raylib\include /I vendor\imgui /I vendor\rlImGui /I vendor\llvm\include set DEFINES=/D_CRT_SECURE_NO_WARNINGS /DIMGUI_DEFINE_MATH_OPERATORS /DNOMINMAX if "%MODE%"=="debug" ( set COPTS=/nologo /MD /std:c++17 /EHsc /Od /Zi /Fd:build\ /W3 %INCLUDES% %DEFINES% set LOPTS=/link /DEBUG /PDB:build\code_inspector.pdb /LIBPATH:vendor\raylib\lib /LIBPATH:vendor\llvm\lib raylib.lib libclang.lib winmm.lib gdi32.lib user32.lib shell32.lib ) else ( set COPTS=/nologo /MD /std:c++17 /EHsc /O2 /Oi /W3 %INCLUDES% %DEFINES% set LOPTS=/link /LIBPATH:vendor\raylib\lib /LIBPATH:vendor\llvm\lib raylib.lib libclang.lib winmm.lib gdi32.lib user32.lib shell32.lib ) :: Ensure libclang.dll is present in build directory if not exist build\libclang.dll ( if exist "C:\Program Files\LLVM\bin\libclang.dll" ( echo [setup] Copying libclang.dll to build directory... copy "C:\Program Files\LLVM\bin\libclang.dll" build\libclang.dll >nul ) ) :: ------------------------------------------------------------- :: Build Vendor Object (if not already built) :: ------------------------------------------------------------- if not exist build\vendor_imgui.obj ( echo [build] Compiling Dear ImGui... %COMPILER% %COPTS% /c vendor\imgui\vendor_imgui.cpp /Fo:build\vendor_imgui.obj /Fd:build\ if !errorlevel! neq 0 exit /b !errorlevel! ) if not exist build\rlImGui.obj ( echo [build] Compiling rlImGui... %COMPILER% %COPTS% /c vendor\rlImGui\rlImGui.cpp /Fo:build\rlImGui.obj /Fd:build\ if !errorlevel! neq 0 exit /b !errorlevel! ) :: ------------------------------------------------------------- :: Build Main Application (Unity build) :: ------------------------------------------------------------- echo [build] Compiling CodeInspector (%MODE%)... %COMPILER% %COPTS% src\main.cpp build\vendor_imgui.obj build\rlImGui.obj /Fo:build\ /Fd:build\ /Fe:build\code_inspector.exe %LOPTS% if %errorlevel% neq 0 ( echo [error] Build failed! exit /b %errorlevel% ) echo [build] Success: build\code_inspector.exe if "%ACTION%"=="run" ( echo [run] Launching build\code_inspector.exe... start "" build\code_inspector.exe )