tg.bat 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. @echo off & setlocal enableextensions enabledelayedexpansion
  2. ::
  3. :: tg.bat - compile & run tests (GNUC).
  4. ::
  5. set unit=expected
  6. :: if no std is given, use c++11
  7. set std=%1
  8. set args=%2 %3 %4 %5 %6 %7 %8 %9
  9. if "%1" == "" set std=c++11
  10. set gpp=g++
  11. call :CompilerVersion version
  12. echo %gpp% %version%: %std% %args%
  13. set UCAP=%unit%
  14. call :toupper UCAP
  15. set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT
  16. ::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD
  17. ::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD
  18. set unit_config=
  19. rem -flto / -fwhole-program
  20. set optflags=-O2
  21. set warnflags=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wno-padded -Wno-missing-noreturn
  22. %gpp% -std=%std% %optflags% %warnflags% %unit_select% %unit_config% -o %unit%-main.t.exe -Dlest_FEATURE_AUTO_REGISTER=1 -isystem lest -I../include -I. %unit%-main.t.cpp %unit%.t.cpp && %unit%-main.t.exe
  23. endlocal & goto :EOF
  24. :: subroutines:
  25. :CompilerVersion version
  26. echo off & setlocal enableextensions
  27. set tmpprogram=_getcompilerversion.tmp
  28. set tmpsource=%tmpprogram%.c
  29. echo #include ^<stdio.h^> > %tmpsource%
  30. echo int main(){printf("%%d.%%d.%%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);} >> %tmpsource%
  31. %gpp% -o %tmpprogram% %tmpsource% >nul
  32. for /f %%x in ('%tmpprogram%') do set version=%%x
  33. del %tmpprogram%.* >nul
  34. endlocal & set %1=%version%& goto :EOF
  35. :: toupper; makes use of the fact that string
  36. :: replacement (via SET) is not case sensitive
  37. :toupper
  38. for %%L IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET %1=!%1:%%L=%%L!
  39. goto :EOF