build.ps1 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. $ErrorActionPreference = "Stop"
  2. cd $env:APPVEYOR_BUILD_FOLDER
  3. $make_cmd = "& $env:MAKE"
  4. # Collect files for .zip packing
  5. New-Item -ItemType directory -Path pack
  6. Copy-Item LICENSE pack
  7. Copy-Item AUTHORS pack
  8. Copy-Item README.md pack
  9. Write-Host -ForegroundColor Green "`n###################################################################"
  10. Write-Host -ForegroundColor Green "`n##### Building Documentation on $env:CC_NAME #####`n"
  11. New-Item -ItemType directory -Path build
  12. cd build
  13. & cmake -DMIKTEX_BINARY_PATH=c:\miktex\texmfs\install\miktex\bin -DCMAKE_BUILD_TYPE=Release -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DUA_BUILD_EXAMPLES:BOOL=OFF -G"$env:CC_NAME" ..
  14. & cmake --build . --target doc_latex
  15. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  16. Write-Host -ForegroundColor Red "`n`n*** Make doc_latex. Exiting ... ***"
  17. exit $LASTEXITCODE
  18. }
  19. & cmake --build . --target doc_pdf
  20. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  21. Write-Host -ForegroundColor Red "`n`n*** Make doc_pdf. Exiting ... ***"
  22. exit $LASTEXITCODE
  23. }
  24. cd ..
  25. Move-Item -Path "build\doc_latex\open62541.pdf" -Destination pack\
  26. Remove-Item -Path build -Recurse -Force
  27. Write-Host -ForegroundColor Green "`n###################################################################"
  28. Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME #####`n"
  29. New-Item -ItemType directory -Path "build"
  30. cd build
  31. & cmake -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
  32. Invoke-Expression $make_cmd
  33. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  34. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  35. exit $LASTEXITCODE
  36. }
  37. cd ..
  38. Remove-Item -Path build -Recurse -Force
  39. Write-Host -ForegroundColor Green "`n###################################################################"
  40. Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with full NS0 #####`n"
  41. New-Item -ItemType directory -Path "build"
  42. cd build
  43. & cmake -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_FULL_NS0:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
  44. Invoke-Expression $make_cmd
  45. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  46. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  47. exit $LASTEXITCODE
  48. }
  49. cd ..
  50. Remove-Item -Path build -Recurse -Force
  51. Write-Host -ForegroundColor Green "`n###################################################################"
  52. Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation #####`n"
  53. New-Item -ItemType directory -Path "build"
  54. cd build
  55. & cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=OFF -G"$env:CC_NAME" ..
  56. Invoke-Expression $make_cmd
  57. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  58. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  59. exit $LASTEXITCODE
  60. }
  61. cd ..
  62. New-Item -ItemType directory -Path pack_tmp
  63. Move-Item -Path "build\open62541.c" -Destination pack_tmp\
  64. Move-Item -Path "build\open62541.h" -Destination pack_tmp\
  65. Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
  66. Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
  67. if ($env:CC_SHORTNAME -eq "mingw") {
  68. Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.a" -Destination pack_tmp\
  69. } else {
  70. Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.lib" -Destination pack_tmp\
  71. }
  72. & 7z a -tzip open62541-$env:CC_SHORTNAME-static.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
  73. Remove-Item -Path pack_tmp -Recurse -Force
  74. Remove-Item -Path build -Recurse -Force
  75. Write-Host -ForegroundColor Green "`n###################################################################"
  76. Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation and .dll #####`n"
  77. New-Item -ItemType directory -Path "build"
  78. cd build
  79. & cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_BUILD_EXAMPLES:BOOL=ON -DUA_ENABLE_AMALGAMATION:BOOL=ON -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -DBUILD_SHARED_LIBS:BOOL=ON -G"$env:CC_NAME" ..
  80. Invoke-Expression $make_cmd
  81. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  82. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  83. exit $LASTEXITCODE
  84. }
  85. cd ..
  86. New-Item -ItemType directory -Path pack_tmp
  87. Move-Item -Path "build\open62541.c" -Destination pack_tmp\
  88. Move-Item -Path "build\open62541.h" -Destination pack_tmp\
  89. Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\server.exe" -Destination pack_tmp\
  90. Move-Item -Path "build\$env:OUT_DIR_EXAMPLES\client.exe" -Destination pack_tmp\
  91. if ($env:CC_SHORTNAME -eq "mingw") {
  92. Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll" -Destination pack_tmp\
  93. Move-Item -Path "build\$env:OUT_DIR_LIB\libopen62541.dll.a" -Destination pack_tmp\
  94. } else {
  95. Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.dll" -Destination pack_tmp\
  96. Move-Item -Path "build\$env:OUT_DIR_LIB\open62541.pdb" -Destination pack_tmp\
  97. }
  98. & 7z a -tzip open62541-$env:CC_SHORTNAME-dynamic.zip "$env:APPVEYOR_BUILD_FOLDER\pack\*" "$env:APPVEYOR_BUILD_FOLDER\pack_tmp\*"
  99. Remove-Item -Path pack_tmp -Recurse -Force
  100. Remove-Item -Path build -Recurse -Force
  101. # Only execute unit tests on vs2015 to save compilation time
  102. if ($env:CC_SHORTNAME -eq "vs2015") {
  103. Write-Host -ForegroundColor Green "`n###################################################################"
  104. Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with unit tests #####`n"
  105. New-Item -ItemType directory -Path "build"
  106. cd build
  107. & cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=OFF -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON -DCMAKE_LIBRARY_PATH=c:\check\lib -DCMAKE_INCLUDE_PATH=c:\check\include -DUA_COMPILE_AS_CXX:BOOL=$env:FORCE_CXX -G"$env:CC_NAME" ..
  108. Invoke-Expression $make_cmd
  109. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  110. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  111. exit $LASTEXITCODE
  112. }
  113. & cmake --build . --target test-verbose --config debug
  114. if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
  115. Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***"
  116. exit $LASTEXITCODE
  117. }
  118. }
  119. # do not cache log
  120. Remove-Item -Path c:\miktex\texmfs\data\miktex\log -Recurse -Force