travis_linux_script.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 selfsigned
  42. cp -r doc ../../
  43. cp ./examples/server_cert.der ../../
  44. cd .. && rm build -rf
  45. # cross compilation only with gcc
  46. if [ "$CC" = "gcc" ]; then
  47. echo "Cross compile release build for MinGW 32 bit"
  48. mkdir -p build && cd build
  49. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  50. make -j8
  51. zip -r open62541-win32.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
  52. cp open62541-win32.zip ..
  53. cd .. && rm build -rf
  54. echo "Cross compile release build for MinGW 64 bit"
  55. mkdir -p build && cd build
  56. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  57. make -j8
  58. zip -r open62541-win64.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
  59. cp open62541-win64.zip ..
  60. cd .. && rm build -rf
  61. echo "Cross compile release build for 32-bit linux"
  62. mkdir -p build && cd build
  63. cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
  64. make -j8
  65. tar -pczf open62541-linux32.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
  66. cp open62541-linux32.tar.gz ..
  67. cd .. && rm build -rf
  68. fi
  69. echo "Compile release build for 64-bit linux"
  70. mkdir -p build && cd build
  71. cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
  72. make -j8
  73. tar -pczf open62541-linux64.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
  74. cp open62541-linux64.tar.gz ..
  75. cp open62541.h .. # copy single file-release
  76. cp open62541.c .. # copy single file-release
  77. cd .. && rm build -rf
  78. if [ "$CC" = "gcc" ]; then
  79. echo "Upgrade to gcc 4.8"
  80. export CXX="g++-4.8" CC="gcc-4.8"
  81. fi
  82. echo "Building the C++ example"
  83. mkdir -p build && cd build
  84. cp ../open62541.* .
  85. gcc-4.8 -std=c99 -c open62541.c
  86. g++-4.8 ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  87. cd .. && rm build -rf
  88. echo "Compile multithreaded version"
  89. mkdir -p build && cd build
  90. cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLES=ON ..
  91. make -j8
  92. cd .. && rm build -rf
  93. #this run inclides full examples and methodcalls
  94. echo "Debug build and unit tests (64 bit)"
  95. mkdir -p build && cd build
  96. cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON ..
  97. make -j8 && make test ARGS="-V"
  98. echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
  99. (valgrind --leak-check=yes --error-exitcode=3 ./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
  100. # only run coveralls on main repo, otherwise it fails uploading the files
  101. echo "-> Current repo: ${TRAVIS_REPO_SLUG}"
  102. if ([ "$CC" = "gcc-4.8" ] || [ "$CC" = "gcc" ]) && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  103. echo " Building coveralls for ${TRAVIS_REPO_SLUG}"
  104. coveralls --gcov /usr/bin/gcov-4.8 -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../
  105. else
  106. echo " Skipping coveralls since not gcc and/or ${TRAVIS_REPO_SLUG} is not the main repo"
  107. fi
  108. cd .. && rm build -rf
  109. fi