assemble.bat re-assembles when files change

master
bx 2021-08-30 17:39:04 +01:00
parent ab6e9f43c3
commit ea0423b9b0
1 changed files with 60 additions and 0 deletions

60
assemble.bat 100644
View File

@ -0,0 +1,60 @@
@echo off
:: https://stackoverflow.com/questions/32895172/how-to-detect-change-in-txt-file-using-batch
:: https://stackoverflow.com/questions/6359820/how-to-set-commands-output-as-a-variable-in-a-batch-file
setlocal enableDelayedExpansion
set compmsg=assembling...
del reload-trigger
:do_compile
set "stime=%time: =0%"
set "stime=%stime:~0,-3%"
set "stime=%stime::=%"
set "sdate=%date:~6,4%%date:~3,2%%date:~0,2%"
cls
echo %compmsg%
echo.
:: taskkill /F /IM main.exe
:: taskkill /F /IM Microsoft.Photos.exe
:: taskkill /F /IM Video.UI.exe
echo.
echo assembling
echo.
echo %time%
ruby assembler.rb
echo %time%
if %ERRORLEVEL% GEQ 1 goto compiler_error
:: del *.obj
:: del *.exp
:: del *.lib
echo.
echo.
echo.
:compiler_error
:do_compare_times
for %%f in (*.rb *.h) do (
set compmsg=%%f assembling...
for /f "tokens=*" %%g in ('forfiles /m %%f /c "cmd /c echo @ftime"') do (set ftime=%%g)
set "ftime=!ftime::=!"
for /f "tokens=*" %%g in ('forfiles /m %%f /c "cmd /c echo @fdate"') do (set fdate=%%g)
set "fdate=!fdate:~6,4!!fdate:~3,2!!fdate:~0,2!"
if /i !ftime! gtr !stime! if /i !fdate! geq !sdate! (goto do_compile)
)
REM timeout /t 1 > nul
goto do_compare_times