travis_linux_script.sh 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/bin/bash
  2. set -ev
  3. if [ $ANALYZE = "true" ]; then
  4. echo "=== Running static code analysis ===" && echo -en 'travis_fold:start:script.analyze\\r'
  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. echo -en 'travis_fold:end:script.analyze\\r'
  42. else
  43. echo -en "\r\n=== Building ===\r\n"
  44. echo -e "\r\n== Documentation and certificate build ==" && echo -en 'travis_fold:start:script.build.doc\\r'
  45. mkdir -p build
  46. cd build
  47. cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
  48. make doc
  49. make doc_pdf
  50. make selfsigned
  51. cp -r doc ../../
  52. cp -r doc_latex ../../
  53. cp ./examples/server_cert.der ../../
  54. cd .. && rm build -rf
  55. echo -en 'travis_fold:end:script.build.doc\\r'
  56. echo -e "\r\n== Full Namespace 0 Generation ==" && echo -en 'travis_fold:start:script.build.ns0\\r'
  57. mkdir -p build
  58. cd build
  59. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON ..
  60. make -j
  61. cd .. && rm build -rf
  62. echo -en 'travis_fold:end:script.build.ns0\\r'
  63. # cross compilation only with gcc
  64. if [ "$CC" = "gcc" ]; then
  65. echo -e "\r\n== Cross compile release build for MinGW 32 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw32\\r'
  66. mkdir -p build && cd build
  67. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  68. make -j
  69. 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
  70. cp open62541-win32.zip ..
  71. cd .. && rm build -rf
  72. echo -en 'travis_fold:end:script.build.cross_mingw32\\r'
  73. echo -e "\r\n== Cross compile release build for MinGW 64 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw64\\r'
  74. mkdir -p build && cd build
  75. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  76. make -j
  77. 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
  78. cp open62541-win64.zip ..
  79. cd .. && rm build -rf
  80. echo -en 'travis_fold:end:script.build.cross_mingw64\\r'
  81. echo -e "\r\n== Cross compile release build for 32-bit linux ==" && echo -en 'travis_fold:start:script.build.cross_linux\\r'
  82. mkdir -p build && cd build
  83. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  84. make -j
  85. 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
  86. cp open62541-linux32.tar.gz ..
  87. cd .. && rm build -rf
  88. echo -en 'travis_fold:end:script.build.cross_linux\\r'
  89. echo -e "\r\n== Cross compile release build for RaspberryPi ==" && echo -en 'travis_fold:start:script.build.cross_raspi\\r'
  90. mkdir -p build && cd build
  91. git clone https://github.com/raspberrypi/tools
  92. export PATH=$PATH:./tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
  93. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-rpi64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  94. make -j
  95. 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
  96. cp open62541-raspberrypi.tar.gz ..
  97. cd .. && rm build -rf
  98. echo -en 'travis_fold:end:script.build.cross_raspi\\r'
  99. fi
  100. echo -e "\r\n== Compile release build for 64-bit linux ==" && echo -en 'travis_fold:start:script.build.linux_64\\r'
  101. mkdir -p build && cd build
  102. cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
  103. make -j
  104. 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
  105. cp open62541-linux64.tar.gz ..
  106. cp open62541.h ../.. # copy single file-release
  107. cp open62541.c ../.. # copy single file-release
  108. cd .. && rm build -rf
  109. echo -en 'travis_fold:end:script.build.linux_64\\r'
  110. echo -e "\r\n== Building the C++ example ==" && echo -en 'travis_fold:start:script.build.example\\r'
  111. mkdir -p build && cd build
  112. cp ../../open62541.* .
  113. gcc -std=c99 -c open62541.c
  114. g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  115. cd .. && rm build -rf
  116. echo -en 'travis_fold:end:script.build.example\\r'
  117. echo -e "\r\n== Compile multithreaded version ==" && echo -en 'travis_fold:start:script.build.multithread\\r'
  118. mkdir -p build && cd build
  119. cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLES=ON ..
  120. make -j
  121. cd .. && rm build -rf
  122. echo -en 'travis_fold:end:script.build.multithread\\r'
  123. echo -e "\r\n== Compile without discovery version ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind\\r'
  124. mkdir -p build && cd build
  125. cmake -DUA_ENABLE_DISCOVERY=OFF -DUA_ENABLE_DISCOVERY_MULTICAST=OFF -DUA_BUILD_EXAMPLES=ON ..
  126. make -j
  127. cd .. && rm build -rf
  128. echo -e "\r\n== Compile discovery without multicast version =="
  129. mkdir -p build && cd build
  130. cmake -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=OFF -DUA_BUILD_EXAMPLES=ON ..
  131. make -j
  132. cd .. && rm build -rf
  133. echo -e "\r\n== Compile multithreaded version with discovery =="
  134. mkdir -p build && cd build
  135. cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_EXAMPLES=ON ..
  136. make -j
  137. cd .. && rm build -rf
  138. echo -en 'travis_fold:end:script.build.multithread\\r'
  139. echo -e "\r\n== Debug build and unit tests (64 bit) ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind\\r'
  140. mkdir -p build && cd build
  141. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
  142. make -j && make test ARGS="-V"
  143. echo -en 'travis_fold:end:script.build.unit_test_valgrind\\r'
  144. # without valgrind
  145. # echo -e "\r\n== Debug build and unit tests without valgrind ==" && echo -en 'travis_fold:start:script.build.unit_test\\r'
  146. # cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=OFF ..
  147. # make -j && make test ARGS="-V"
  148. # (./bin/examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
  149. # echo -en 'travis_fold:end:script.build.unit_test\\r'
  150. # only run coveralls on main repo, otherwise it fails uploading the files
  151. echo -e "\r\n== -> Current repo: ${TRAVIS_REPO_SLUG} =="
  152. if [ "$CC" = "gcc" ] && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  153. echo -en "\r\n== Building coveralls for ${TRAVIS_REPO_SLUG} ==" && echo -en 'travis_fold:start:script.build.coveralls\\r'
  154. coveralls -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../ || true # ignore result since coveralls is unreachable from time to time
  155. echo -en 'travis_fold:end:script.build.coveralls\\r'
  156. fi
  157. cd .. && rm build -rf
  158. fi