ampler/compile-ampler.bat

65 lines
1.4 KiB
Batchfile

@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=compiling...
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 compiling main.c
echo.
echo %time%
:: cl main.c /O2 /MP /nologo /I include /link lib/avcodec.lib lib/avformat.lib lib/swscale.lib lib/avutil.lib lib/SDL2.lib lib/swresample.lib
tcc\tcc ampler.c -o ampler.dll -shared -lsdl2 -lws2_32 -g -rdynamic
echo %time%
if %ERRORLEVEL% GEQ 1 goto compiler_error
:: del *.obj
:: del *.exp
:: del *.lib
del ampler.def
echo.
echo creating reload-trigger
echo.
echo > reload-trigger
echo.
:compiler_error
:do_compare_times
for %%f in (*.c *.h) do (
set compmsg=%%f compiling...
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