bld.bat 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. :: Needed so we can find stdint.h from msinttypes.
  2. set LIB=%LIBRARY_LIB%;%LIB%
  3. set LIBPATH=%LIBRARY_LIB%;%LIBPATH%
  4. set INCLUDE=%LIBRARY_INC%;%INCLUDE%
  5. :: VS2008 doesn't have stdbool.h so copy in our own
  6. :: to 'lib' where the other headers are so it gets picked up.
  7. if "%VS_MAJOR%" == "9" (
  8. if "%ARCH%" == "64" (
  9. :: The Windows 6.0A SDK does not provide the bcrypt.lib for 64-bit:
  10. :: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64
  11. :: .. yet does for 32-bit, oh well, this may disable password protected zip support.
  12. :: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/673cc344-430c-4510-96e8-80b0bb42ae11/can-not-link-bcryptlib-to-an-64bit-build?forum=windowssdk
  13. set ENABLE_CNG=NO
  14. ) else (
  15. set ENABLE_CNG=YES
  16. :: Have decided to standardise on *not* using bcrypt instead. If we update to the Windows Server 2008 SDK we could revisit this
  17. set ENABLE_CNG=NO
  18. )
  19. )
  20. if "%vc%" NEQ "9" goto not_vc9
  21. :: This does not work yet:
  22. :: usage: cl [ option... ] filename... [ /link linkoption... ]
  23. set USE_C99_WRAP=no
  24. copy %LIBRARY_INC%\inttypes.h src\common\inttypes.h
  25. copy %LIBRARY_INC%\stdint.h src\common\stdint.h
  26. goto endit
  27. :not_vc9
  28. set USE_C99_WRAP=no
  29. :endit
  30. if exist CMakeCache.txt goto build
  31. if "%USE_C99_WRAP%" NEQ "yes" goto skip_c99_wrap
  32. set COMPILER=-DCMAKE_C_COMPILER=c99-to-c89-cmake-nmake-wrap.bat
  33. set C99_TO_C89_WRAP_DEBUG_LEVEL=1
  34. set C99_TO_C89_WRAP_SAVE_TEMPS=1
  35. set C99_TO_C89_WRAP_NO_LINE_DIRECTIVES=1
  36. set C99_TO_C89_CONV_DEBUG_LEVEL=1
  37. :skip_c99_wrap
  38. :: set cflags because NDEBUG is set in Release configuration, which errors out in test suite due to no assert
  39. :: cmd
  40. echo "Building %PKG_NAME%."
  41. :: Generate the build files.
  42. echo "Generating the build files..."
  43. cmake -G "Ninja" ^
  44. -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
  45. %COMPILER% ^
  46. -DCMAKE_BUILD_TYPE=Release ^
  47. -DENABLE_LZO=FALSE ^
  48. -DENABLE_ZLIB=TRUE ^
  49. -DCMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS:BOOL=FALSE ^
  50. -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
  51. -DCMAKE_C_FLAGS_RELEASE="%CFLAGS%" ^
  52. -DENABLE_CNG=%ENABLE_CNG% ^
  53. -DENABLE_BZIP2=TRUE ^
  54. -DBZIP2_ROOT=%PREFIX%/lib ^
  55. .
  56. if errorlevel 1 exit /b 1
  57. :build
  58. :: Build.
  59. echo "Building..."
  60. ninja -j%CPU_COUNT% -v
  61. if errorlevel 1 exit /b 1
  62. :: Install.
  63. echo "Installing..."
  64. ninja install
  65. if errorlevel 1 exit /b 1
  66. :: Perform tests.
  67. ::echo "Testing..."
  68. ::ctest -VV --output-on-failure
  69. :: if errorlevel 1 exit /b 1 there are failed tests
  70. echo Trying to run %LIBRARY_BIN%\bsdcat.exe --version
  71. %LIBRARY_BIN%\bsdcat.exe --version
  72. if errorlevel 1 exit 1
  73. echo Trying to run %LIBRARY_BIN%\bsdcpio.exe --version
  74. %LIBRARY_BIN%\bsdcpio.exe --version
  75. if errorlevel 1 exit 1
  76. :: Error free exit.
  77. echo "Error free exit!"
  78. exit 0