tc-cl.bat 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. @echo off & setlocal enableextensions enabledelayedexpansion
  2. ::
  3. :: tc-cl.bat - compile & run tests (clang-cl).
  4. ::
  5. set unit=expected
  6. set unit_file=%unit%
  7. :: if no std is given, use c++14
  8. set std=c++14
  9. if NOT "%1" == "" set std=%1 & shift
  10. set UCAP=%unit%
  11. call :toupper UCAP
  12. set unit_select=%unit%_%UCAP%_NONSTD
  13. ::set unit_select=%unit%_CONFIG_SELECT_%UCAP%_NONSTD
  14. if NOT "%1" == "" set unit_select=%1 & shift
  15. set args=%1 %2 %3 %4 %5 %6 %7 %8 %9
  16. set clang=clang-cl
  17. call :CompilerVersion version
  18. echo %clang% %version%: %std% %unit_select% %args%
  19. set unit_config=^
  20. -Dlest_FEATURE_AUTO_REGISTER=1 ^
  21. -D%unit%_%UCAP%_HEADER=\"nonstd/%unit%.hpp\" ^
  22. -D%unit%_TEST_NODISCARD=0 ^
  23. -D%unit%_CONFIG_SELECT_%UCAP%=%unit_select%
  24. rem -flto / -fwhole-program
  25. set optflags=-O2
  26. set warnflags=-Wall -Wextra -Wpedantic -Weverything -Wshadow -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-noreturn -Wno-documentation-unknown-command -Wno-documentation-deprecated-sync -Wno-documentation -Wno-weak-vtables -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-exit-time-destructors -Wno-global-constructors -Wno-sign-conversion -Wno-sign-compare -Wno-implicit-int-conversion -Wno-deprecated-declarations -Wno-date-time
  27. "%clang%" -EHsc -std:%std% %optflags% %warnflags% %unit_config% -fms-compatibility-version=19.00 /imsvc lest -I../include -Ics_string -I. -o %unit_file%-main.t.exe %unit_file%-main.t.cpp %unit_file%.t.cpp && %unit_file%-main.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.%%d.%%d\n",__clang_major__,__clang_minor__,__clang_patchlevel__);} >> %tmpsource%
  36. "%clang%" -m32 -o %tmpprogram% %tmpsource% >nul
  37. for /f %%x in ('%tmpprogram%') do set version=%%x
  38. del %tmpprogram%.* >nul
  39. endlocal & set %1=%version%& goto :EOF
  40. :: toupper; makes use of the fact that string
  41. :: replacement (via SET) is not case sensitive
  42. :toupper
  43. 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!
  44. goto :EOF