travis_linux_script.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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=incorrectStringBooleanError \
  26. --suppress=invalidscanf --inline-suppr \
  27. -I include src plugins 2> cppcheck.txt
  28. if [ -s cppcheck.txt ]; then
  29. echo "====== CPPCHECK Static Analysis Errors ======"
  30. cat cppcheck.txt
  31. exit 1
  32. fi
  33. fi
  34. else
  35. echo "=== Building ==="
  36. echo "Documentation and certificate build"
  37. mkdir -p build
  38. cd build
  39. cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
  40. make doc
  41. make doc_pdf
  42. make selfsigned
  43. cp -r doc ../../
  44. cp -r doc_latex ../../
  45. cp ./examples/server_cert.der ../../
  46. cd .. && rm build -rf
  47. echo "Full Namespace 0 Generation"
  48. mkdir -p build
  49. cd build
  50. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON ..
  51. make -j8
  52. cd .. && rm build -rf
  53. # cross compilation only with gcc
  54. if [ "$CC" = "gcc" ]; then
  55. echo "Cross compile release build for MinGW 32 bit"
  56. mkdir -p build && cd build
  57. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  58. make -j8
  59. 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
  60. cp open62541-win32.zip ..
  61. cd .. && rm build -rf
  62. echo "Cross compile release build for MinGW 64 bit"
  63. mkdir -p build && cd build
  64. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  65. make -j8
  66. 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
  67. cp open62541-win64.zip ..
  68. cd .. && rm build -rf
  69. echo "Cross compile release build for 32-bit linux"
  70. mkdir -p build && cd build
  71. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  72. make -j8
  73. 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
  74. cp open62541-linux32.tar.gz ..
  75. cd .. && rm build -rf
  76. fi
  77. echo "Compile release build for 64-bit linux"
  78. mkdir -p build && cd build
  79. cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
  80. make -j8
  81. 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
  82. cp open62541-linux64.tar.gz ..
  83. cp open62541.h .. # copy single file-release
  84. cp open62541.c .. # copy single file-release
  85. cd .. && rm build -rf
  86. if [ "$CC" = "gcc" ]; then
  87. echo "Upgrade to gcc 4.8"
  88. export CXX="g++-4.8" CC="gcc-4.8"
  89. fi
  90. echo "Building the C++ example"
  91. mkdir -p build && cd build
  92. cp ../open62541.* .
  93. gcc-4.8 -std=c99 -c open62541.c
  94. g++-4.8 ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  95. cd .. && rm build -rf
  96. echo "Compile multithreaded version"
  97. mkdir -p build && cd build
  98. cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLES=ON ..
  99. make -j8
  100. cd .. && rm build -rf
  101. #this run inclides full examples and methodcalls
  102. echo "Debug build and unit tests (64 bit)"
  103. mkdir -p build && cd build
  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. echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
  107. (valgrind --leak-check=yes --error-exitcode=3 ./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
  108. # only run coveralls on main repo, otherwise it fails uploading the files
  109. echo "-> Current repo: ${TRAVIS_REPO_SLUG}"
  110. if ([ "$CC" = "gcc-4.8" ] || [ "$CC" = "gcc" ]) && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  111. echo " Building coveralls for ${TRAVIS_REPO_SLUG}"
  112. coveralls --gcov /usr/bin/gcov-4.8 -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../ || true # ignore result
  113. else
  114. echo " Skipping coveralls since not gcc and/or ${TRAVIS_REPO_SLUG} is not the main repo"
  115. fi
  116. cd .. && rm build -rf
  117. fi