t.bat 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. @echo off & setlocal enableextensions enabledelayedexpansion
  2. ::
  3. :: t.bat - compile & run tests (MSVC).
  4. ::
  5. set unit=expected
  6. :: if no std is given, use compiler default
  7. set std=%1
  8. if not "%std%"=="" set std=-std:%std%
  9. call :CompilerVersion version
  10. echo VC%version%: %args%
  11. set UCAP=%unit%
  12. call :toupper UCAP
  13. set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_DEFAULT
  14. ::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_NONSTD
  15. ::set unit_select=-D%unit%_CONFIG_SELECT_%UCAP%=%unit%_%UCAP%_STD
  16. set unit_config=
  17. set msvc_defines=^
  18. -Dlest_FEATURE_AUTO_REGISTER=1 ^
  19. -D_CRT_SECURE_NO_WARNINGS ^
  20. -D_SCL_SECURE_NO_WARNINGS
  21. set CppCoreCheckInclude=%VCINSTALLDIR%\Auxiliary\VS\include
  22. cl -nologo -W3 -EHsc %std% %unit_select% %unit_config% %msvc_defines% -I"%CppCoreCheckInclude%" -Ilest -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\n",_MSC_VER);} >>%tmpsource%
  31. cl /nologo %tmpsource% >nul
  32. for /f %%x in ('%tmpprogram%') do set version=%%x
  33. del %tmpprogram%.* >nul
  34. set offset=0
  35. if %version% LSS 1900 set /a offset=1
  36. set /a version="version / 10 - 10 * ( 5 + offset )"
  37. endlocal & set %1=%version%& goto :EOF
  38. :: toupper; makes use of the fact that string
  39. :: replacement (via SET) is not case sensitive
  40. :toupper
  41. 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!
  42. goto :EOF