t-noexcept.bat 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. -D_HAS_EXCEPTIONS=0 ^
  22. -Dnsel_CONFIG_NO_SEH=0
  23. :: -Dnsel_CONFIG_NO_EXCEPTIONS=1
  24. set CppCoreCheckInclude=%VCINSTALLDIR%\Auxiliary\VS\include
  25. :: -EHsc
  26. ::cl -kernel -GR- -W3 %std% %unit_select% %unit_config% %msvc_defines% -I"%CppCoreCheckInclude%" -I../include -I. %unit%-noexcept.t.cpp && %unit%-noexcept.t.exe
  27. cl -EHs -GR- -W3 %std% %unit_select% %unit_config% %msvc_defines% -I"%CppCoreCheckInclude%" -Ilest -I../include -I. %unit%-noexcept.t.cpp && %unit%-noexcept.t.exe
  28. endlocal & goto :EOF
  29. :: subroutines:
  30. :CompilerVersion version
  31. @echo off & setlocal enableextensions
  32. set tmpprogram=_getcompilerversion.tmp
  33. set tmpsource=%tmpprogram%.c
  34. echo #include ^<stdio.h^> >%tmpsource%
  35. echo int main(){printf("%%d\n",_MSC_VER);} >>%tmpsource%
  36. cl /nologo %tmpsource% >nul
  37. for /f %%x in ('%tmpprogram%') do set version=%%x
  38. del %tmpprogram%.* >nul
  39. set offset=0
  40. if %version% LSS 1900 set /a offset=1
  41. set /a version="version / 10 - 10 * ( 5 + offset )"
  42. endlocal & set %1=%version%& goto :EOF
  43. :: toupper; makes use of the fact that string
  44. :: replacement (via SET) is not case sensitive
  45. :toupper
  46. 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!
  47. goto :EOF