@echo off REM Runs one Cargo command with one synchronized HCIE build-number increment (Windows) REM Usage: scripts\cargo-with-build-id.bat [arguments...] setlocal enabledelayedexpansion set ROOT_DIR=%~dp0..\ set LOCK_DIR=%ROOT_DIR%.build-id.lock set COUNTER_FILE=%ROOT_DIR%build.id if "%~1"=="" ( echo usage: scripts\cargo-with-build-id.bat ^ [arguments...] exit /b 2 ) REM Acquire lock (Windows-friendly using a temp file) :acquire_lock 2>nul ( >>"%LOCK_DIR%\lock.tmp" echo(%DATE% %TIME% ) || ( REM Lock exists; wait and retry timeout /t 1 /nobreak >nul goto :acquire_lock ) del "%LOCK_DIR%\lock.tmp" 2>nul REM Read current build ID if exist "%COUNTER_FILE%" ( set /p current=<"%COUNTER_FILE%" ) else ( set current=0 ) REM Validate it's a number echo %current%| findstr /r "^[0-9][0-9]*$" >nul if errorlevel 1 ( echo build.id must contain one unsigned integer, found: %current% exit /b 1 ) set /a next=current+1 REM Write counter files echo %next%>"%COUNTER_FILE%" echo %next%>"%ROOT_DIR%hcie-egui-app\build.id" echo %next%>"%ROOT_DIR%hcie-egui-app\crates\hcie-gui-egui\build.id" set HCIE_BUILD_ID_OVERRIDE=%next% echo HCIE build %next%: cargo %* cd /d "%ROOT_DIR%" cargo %* exit /b %ERRORLEVEL%