travis_linux_script.sh 6.5 KB

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