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