travis_linux_script.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/bash
  2. set -ev
  3. if [ $ANALYZE = "true" ]; then
  4. echo "=== Running static code analysis ==="
  5. if [ "$CC" = "clang" ]; then
  6. mkdir -p build
  7. cd build
  8. scan-build cmake -G "Unix Makefiles" -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON ..
  9. scan-build -enable-checker security.FloatLoopCounter \
  10. -enable-checker security.insecureAPI.UncheckedReturn \
  11. --status-bugs -v \
  12. make -j 8
  13. cd .. && rm build -rf
  14. mkdir -p build
  15. cd build
  16. scan-build cmake -G "Unix Makefiles" -DUA_ENABLE_AMALGAMATION=ON ..
  17. scan-build -enable-checker security.FloatLoopCounter \
  18. -enable-checker security.insecureAPI.UncheckedReturn \
  19. --status-bugs -v \
  20. make -j 8
  21. cd .. && rm build -rf
  22. else
  23. cppcheck --template "{file}({line}): {severity} ({id}): {message}" \
  24. --enable=style --force --std=c++11 -j 8 \
  25. --suppress=duplicateBranch \
  26. --suppress=incorrectStringBooleanError \
  27. --suppress=invalidscanf --inline-suppr \
  28. -I include src plugins 2> cppcheck.txt
  29. if [ -s cppcheck.txt ]; then
  30. echo "====== CPPCHECK Static Analysis Errors ======"
  31. cat cppcheck.txt
  32. exit 1
  33. fi
  34. fi
  35. else
  36. echo "=== Building ==="
  37. echo "Documentation and certificate build"
  38. mkdir -p build
  39. cd build
  40. cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
  41. make doc
  42. make doc_pdf
  43. make selfsigned
  44. cp -r doc ../../
  45. cp -r doc_latex ../../
  46. cp ./examples/server_cert.der ../../
  47. cd .. && rm build -rf
  48. echo "Full Namespace 0 Generation"
  49. mkdir -p build
  50. cd build
  51. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON ..
  52. make -j8
  53. cd .. && rm build -rf
  54. # cross compilation only with gcc
  55. if [ "$CC" = "gcc" ]; then
  56. echo "Cross compile release build for MinGW 32 bit"
  57. mkdir -p build && cd build
  58. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  59. make -j8
  60. zip -r open62541-win32.zip ../../doc ../../doc_latex/open62541.pdf ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
  61. cp open62541-win32.zip ..
  62. cd .. && rm build -rf
  63. echo "Cross compile release build for MinGW 64 bit"
  64. mkdir -p build && cd build
  65. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  66. make -j8
  67. zip -r open62541-win64.zip ../../doc ../../doc_latex/open62541.pdf ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
  68. cp open62541-win64.zip ..
  69. cd .. && rm build -rf
  70. echo "Cross compile release build for 32-bit linux"
  71. mkdir -p build && cd build
  72. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  73. make -j8
  74. tar -pczf open62541-linux32.tar.gz ../../doc ../../doc_latex/open62541.pdf ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
  75. cp open62541-linux32.tar.gz ..
  76. cd .. && rm build -rf
  77. fi
  78. echo "Compile release build for 64-bit linux"
  79. mkdir -p build && cd build
  80. cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
  81. make -j8
  82. tar -pczf open62541-linux64.tar.gz ../../doc ../../doc_latex/open62541.pdf ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
  83. cp open62541-linux64.tar.gz ..
  84. cp open62541.h ../.. # copy single file-release
  85. cp open62541.c ../.. # copy single file-release
  86. cd .. && rm build -rf
  87. echo "Building the C++ example"
  88. mkdir -p build && cd build
  89. cp ../../open62541.* .
  90. gcc -std=c99 -c open62541.c
  91. g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  92. cd .. && rm build -rf
  93. echo "Compile multithreaded version"
  94. mkdir -p build && cd build
  95. cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLES=ON ..
  96. make -j8
  97. cd .. && rm build -rf
  98. echo "Debug build and unit tests (64 bit)"
  99. mkdir -p build && cd build
  100. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
  101. make -j8 && make test ARGS="-V"
  102. (valgrind --leak-check=yes --error-exitcode=3 ./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
  103. # without valgrind
  104. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON ..
  105. make -j8 && make test ARGS="-V"
  106. (./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
  107. # only run coveralls on main repo, otherwise it fails uploading the files
  108. echo "-> Current repo: ${TRAVIS_REPO_SLUG}"
  109. if [ "$CC" = "gcc" ] && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  110. echo " Building coveralls for ${TRAVIS_REPO_SLUG}"
  111. coveralls -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../ || true # ignore result since coveralls is unreachable from time to time
  112. else
  113. echo " Skipping coveralls since not gcc and/or ${TRAVIS_REPO_SLUG} is not the main repo"
  114. fi
  115. cd .. && rm build -rf
  116. fi