travis_linux_script.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. #!/bin/bash
  2. set -e
  3. # Sonar code quality
  4. if ! [ -z ${SONAR+x} ]; then
  5. if ([ "${TRAVIS_REPO_SLUG}" != "open62541/open62541" ] ||
  6. [ "${TRAVIS_PULL_REQUEST}" != "false" ] ||
  7. [ "${TRAVIS_BRANCH}" != "master" ]); then
  8. echo "Skipping Sonarcloud on forks"
  9. # Skip on forks
  10. exit 0;
  11. fi
  12. git fetch --unshallow
  13. mkdir -p build && cd build
  14. build-wrapper-linux-x86-64 --out-dir ../bw-output cmake \
  15. -DCMAKE_BUILD_TYPE=Debug \
  16. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  17. -DUA_BUILD_EXAMPLES=ON \
  18. -DUA_ENABLE_DISCOVERY=ON \
  19. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  20. -DUA_ENABLE_ENCRYPTION .. \
  21. && make -j
  22. cd ..
  23. sonar-scanner
  24. exit 0
  25. fi
  26. # Docker build test
  27. if ! [ -z ${DOCKER+x} ]; then
  28. docker build -t open62541 .
  29. docker run -d -p 127.0.0.1:80:80 --name open62541 open62541 /bin/sh
  30. docker ps | grep -q open62541
  31. # disabled since it randomly fails
  32. # docker ps | grep -q open62541
  33. exit 0
  34. fi
  35. # Cpplint checking
  36. if ! [ -z ${LINT+x} ]; then
  37. mkdir -p build
  38. cd build
  39. cmake ..
  40. make cpplint
  41. if [ $? -ne 0 ] ; then exit 1 ; fi
  42. exit 0
  43. fi
  44. # Fuzzer build test
  45. if ! [ -z ${FUZZER+x} ]; then
  46. # First check if the build is successful
  47. ./tests/fuzz/check_build.sh
  48. if [ $? -ne 0 ] ; then exit 1 ; fi
  49. # Test the corpus generator and use new corpus for fuzz test
  50. ./tests/fuzz/generate_corpus.sh
  51. if [ $? -ne 0 ] ; then exit 1 ; fi
  52. cd build_fuzz
  53. make && make run_fuzzer
  54. if [ $? -ne 0 ] ; then exit 1 ; fi
  55. exit 0
  56. fi
  57. # INSTALL build test
  58. if ! [ -z ${INSTALL+x} ]; then
  59. echo "=== Install build, then compile examples ===" && echo -en 'travis_fold:start:script.build.install\\r'
  60. # Use make install to deploy files and then test if we can build the examples based on the installed files
  61. mkdir -p build
  62. cd build
  63. cmake \
  64. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  65. -DBUILD_SHARED_LIBS=ON \
  66. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  67. -DUA_NAMESPACE_ZERO=FULL \
  68. -DUA_ENABLE_AMALGAMATION=OFF \
  69. -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/open62541_install ..
  70. make -j install
  71. if [ $? -ne 0 ] ; then exit 1 ; fi
  72. cd .. && rm build -rf
  73. echo -en 'travis_fold:end:script.build.install\\r'
  74. echo -en 'travis_fold:start:script.build.mini-example\\r'
  75. # Now create a simple CMake Project which uses the installed file
  76. mkdir compile
  77. cp -r examples compile/examples && cd compile/examples
  78. cmake \
  79. -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/open62541_install \
  80. -DUA_NAMESPACE_ZERO=FULL .
  81. make -j
  82. if [ $? -ne 0 ] ; then exit 1 ; fi
  83. cd ../..
  84. rm -rf compile
  85. echo -en 'travis_fold:end:script.build.mini-example\\r'
  86. exit 0
  87. fi
  88. if ! [ -z ${CLANG_FORMAT+x} ]; then
  89. # Only run clang format on Pull requests, not on direct push
  90. if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
  91. echo -en "\\nSkipping clang-format on non-pull request\\n"
  92. exit 0
  93. fi
  94. echo "=== Running clang-format with diff against branch '$TRAVIS_BRANCH' ===" && echo -en 'travis_fold:start:script.clang-format\\r'
  95. # add clang-format-ci
  96. curl -Ls "https://raw.githubusercontent.com/llvm-mirror/clang/c510fac5695e904b43d5bf0feee31cc9550f110e/tools/clang-format/git-clang-format" -o "$LOCAL_PKG/bin/git-clang-format"
  97. chmod +x $LOCAL_PKG/bin/git-clang-format
  98. # Ignore files in the deps directory diff by resetting them to master
  99. git diff --name-only $TRAVIS_BRANCH | grep 'deps/*' | xargs git checkout $TRAVIS_BRANCH --
  100. # clang-format the diff to the target branch of the PR
  101. difference="$($LOCAL_PKG/bin/git-clang-format --style=file --diff $TRAVIS_BRANCH)"
  102. if ! case $difference in *"no modified files to format"*) false;; esac; then
  103. echo "====== clang-format did not find any issues. Well done! ======"
  104. exit 0
  105. fi
  106. if ! case $difference in *"clang-format did not modify any files"*) false;; esac; then
  107. echo "====== clang-format did not find any issues. Well done! ======"
  108. exit 0
  109. fi
  110. echo "====== clang-format Format Errors ======"
  111. echo "Uploading the patch to a pastebin page ..."
  112. pastebinUrl="$($LOCAL_PKG/bin/git-clang-format --style=file --diff $TRAVIS_BRANCH | curl -F 'sprunge=<-' http://sprunge.us)"
  113. echo "Created a patch file under: $pastebinUrl"
  114. echo "Please fix the following issues.\n\n"
  115. echo "You can also use the following command to apply the diff to your source locally:\n-------------\n"
  116. echo "curl -o format.patch $pastebinUrl && git apply format.patch\n-------------\n"
  117. echo "=============== DIFFERENCE - START =================\n"
  118. # We want to get colored diff output into the variable
  119. git config color.diff always
  120. $LOCAL_PKG/bin/git-clang-format --binary=clang-format-6.0 --style=file --diff $TRAVIS_BRANCH
  121. echo "\n============= DIFFERENCE - END ===================="
  122. echo -en 'travis_fold:start:script.clang-format\\r'
  123. exit 1
  124. fi
  125. if ! [ -z ${ANALYZE+x} ]; then
  126. echo "=== Running static code analysis ===" && echo -en 'travis_fold:start:script.analyze\\r'
  127. if ! case $CC in clang*) false;; esac; then
  128. mkdir -p build
  129. cd build
  130. scan-build-6.0 cmake \
  131. -DUA_BUILD_EXAMPLES=ON \
  132. -DUA_BUILD_UNIT_TESTS=ON ..
  133. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  134. -enable-checker security.insecureAPI.UncheckedReturn \
  135. --status-bugs -v \
  136. make -j
  137. cd .. && rm build -rf
  138. mkdir -p build
  139. cd build
  140. scan-build-6.0 cmake \
  141. -DUA_ENABLE_PUBSUB=ON \
  142. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  143. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON ..
  144. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  145. -enable-checker security.insecureAPI.UncheckedReturn \
  146. --status-bugs -v \
  147. make -j
  148. cd .. && rm build -rf
  149. mkdir -p build
  150. cd build
  151. scan-build-6.0 cmake \
  152. -DUA_ENABLE_AMALGAMATION=OFF ..
  153. scan-build-6.0 -enable-checker security.FloatLoopCounter \
  154. -enable-checker security.insecureAPI.UncheckedReturn \
  155. --status-bugs -v \
  156. make -j
  157. cd .. && rm build -rf
  158. #mkdir -p build && cd build
  159. #cmake -DUA_ENABLE_STATIC_ANALYZER=REDUCED ..
  160. ## previous clang-format to reduce to non-trivial warnings
  161. #make clangformat
  162. #make
  163. #cd .. && rm build -rf
  164. else
  165. cppcheck --template "{file}({line}): {severity} ({id}): {message}" \
  166. --enable=style --force --std=c++11 -j 8 \
  167. --suppress=duplicateBranch \
  168. --suppress=incorrectStringBooleanError \
  169. --suppress=invalidscanf --inline-suppr \
  170. -I include src plugins examples 2> cppcheck.txt
  171. if [ -s cppcheck.txt ]; then
  172. echo "====== CPPCHECK Static Analysis Errors ======"
  173. cat cppcheck.txt
  174. # flush output
  175. sleep 5
  176. exit 1
  177. fi
  178. fi
  179. echo -en 'travis_fold:end:script.analyze\\r'
  180. exit 0
  181. fi
  182. echo -en "\r\n=== Building ===\r\n"
  183. echo -e "\r\n== Documentation build ==" && echo -en 'travis_fold:start:script.build.doc\\r'
  184. mkdir -p build
  185. cd build
  186. cmake \
  187. -DCMAKE_BUILD_TYPE=Release \
  188. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  189. -DUA_BUILD_EXAMPLES=ON ..
  190. make doc
  191. make doc_pdf
  192. cp -r doc ../../
  193. cp -r doc_latex ../../
  194. cd .. && rm build -rf
  195. echo -en 'travis_fold:end:script.build.doc\\r'
  196. # cross compilation only with gcc
  197. if ! [ -z ${MINGW+x} ]; then
  198. echo -e "\r\n== Cross compile release build for MinGW 32 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw32\\r'
  199. mkdir -p build && cd build
  200. cmake \
  201. -DBUILD_SHARED_LIBS=ON \
  202. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  203. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-win32 \
  204. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake \
  205. -DUA_BUILD_EXAMPLES=ON \
  206. -DUA_ENABLE_AMALGAMATION=OFF ..
  207. make -j
  208. if [ $? -ne 0 ] ; then exit 1 ; fi
  209. make install
  210. if [ $? -ne 0 ] ; then exit 1 ; fi
  211. cd ..
  212. zip -r open62541-win32.zip ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-win32/*
  213. rm build -rf
  214. echo -en 'travis_fold:end:script.build.cross_mingw32\\r'
  215. echo -e "\r\n== Cross compile release build for MinGW 64 bit ==" && echo -en 'travis_fold:start:script.build.cross_mingw64\\r'
  216. mkdir -p build && cd build
  217. cmake \
  218. -DBUILD_SHARED_LIBS=ON \
  219. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  220. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-win64 \
  221. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake \
  222. -DUA_BUILD_EXAMPLES=ON \
  223. -DUA_ENABLE_AMALGAMATION=OFF ..
  224. make -j
  225. if [ $? -ne 0 ] ; then exit 1 ; fi
  226. make install
  227. if [ $? -ne 0 ] ; then exit 1 ; fi
  228. cd ..
  229. zip -r open62541-win64.zip ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-win64/*
  230. rm build -rf
  231. echo -en 'travis_fold:end:script.build.cross_mingw64\\r'
  232. echo -e "\r\n== Cross compile release build for 32-bit linux ==" && echo -en 'travis_fold:start:script.build.cross_linux\\r'
  233. mkdir -p build && cd build
  234. cmake \
  235. -DBUILD_SHARED_LIBS=ON \
  236. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  237. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux32 \
  238. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake \
  239. -DUA_BUILD_EXAMPLES=ON \
  240. -DUA_ENABLE_AMALGAMATION=OFF ..
  241. make -j
  242. if [ $? -ne 0 ] ; then exit 1 ; fi
  243. make install
  244. if [ $? -ne 0 ] ; then exit 1 ; fi
  245. cd ..
  246. tar -pczf open62541-linux32.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-linux32/*
  247. rm build -rf
  248. echo -en 'travis_fold:end:script.build.cross_linux\\r'
  249. echo -e "\r\n== Cross compile release build for RaspberryPi ==" && echo -en 'travis_fold:start:script.build.cross_raspi\\r'
  250. mkdir -p build && cd build
  251. git clone https://github.com/raspberrypi/tools
  252. export PATH=$PATH:${TRAVIS_BUILD_DIR}/build/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
  253. cmake \
  254. -DBUILD_SHARED_LIBS=ON \
  255. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  256. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-raspberrypi \
  257. -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-rpi64.cmake \
  258. -DUA_BUILD_EXAMPLES=ON \
  259. -DUA_ENABLE_AMALGAMATION=OFF ..
  260. make -j
  261. if [ $? -ne 0 ] ; then exit 1 ; fi
  262. make install
  263. if [ $? -ne 0 ] ; then exit 1 ; fi
  264. cd ..
  265. tar -pczf open62541-raspberrypi.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-raspberrypi/*
  266. rm build -rf
  267. echo -en 'travis_fold:end:script.build.cross_raspi\\r'
  268. fi
  269. echo -e "\r\n== Compile release build for 64-bit linux ==" && echo -en 'travis_fold:start:script.build.linux_64\\r'
  270. mkdir -p build && cd build
  271. cmake \
  272. -DBUILD_SHARED_LIBS=ON \
  273. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  274. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux64 \
  275. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  276. -DUA_BUILD_EXAMPLES=ON \
  277. -DUA_ENABLE_AMALGAMATION=OFF ..
  278. make -j
  279. if [ $? -ne 0 ] ; then exit 1 ; fi
  280. make install
  281. if [ $? -ne 0 ] ; then exit 1 ; fi
  282. cd ..
  283. tar -pczf open62541-linux64.tar.gz ../doc_latex/open62541.pdf LICENSE AUTHORS README.md open62541-linux64/*
  284. rm build -rf
  285. echo -en 'travis_fold:end:script.build.linux_64\\r'
  286. echo -e "\r\n== Compile with amalgamation ==" && echo -en 'travis_fold:start:script.build.amalgamate\\r'
  287. mkdir -p build && cd build
  288. cmake \
  289. -DBUILD_SHARED_LIBS=ON \
  290. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  291. -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/open62541-linux64 \
  292. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  293. -DUA_BUILD_EXAMPLES=OFF \
  294. -DUA_ENABLE_AMALGAMATION=ON \
  295. -DUA_ENABLE_HISTORIZING=ON ..
  296. make -j
  297. cp open62541.h ../.. # copy single file-release
  298. cp open62541.c ../.. # copy single file-release
  299. gcc -std=c99 -c open62541.c
  300. g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
  301. if [ $? -ne 0 ] ; then exit 1 ; fi
  302. cd .. && rm build -rf
  303. echo -en 'travis_fold:end:script.build.amalgamate\\r'
  304. echo "Compile as shared lib version" && echo -en 'travis_fold:start:script.build.shared_libs\\r'
  305. mkdir -p build && cd build
  306. cmake \
  307. -DBUILD_SHARED_LIBS=ON \
  308. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  309. -DUA_BUILD_EXAMPLES=ON \
  310. -DUA_ENABLE_AMALGAMATION=OFF ..
  311. make -j
  312. if [ $? -ne 0 ] ; then exit 1 ; fi
  313. cd .. && rm build -rf
  314. echo -en 'travis_fold:end:script.build.shared_libs\\r'
  315. if [ "$CC" != "tcc" ]; then
  316. echo -e "\r\n==Compile multithreaded version==" && echo -en 'travis_fold:start:script.build.multithread\\r'
  317. mkdir -p build && cd build
  318. cmake \
  319. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  320. -DUA_BUILD_EXAMPLES=ON \
  321. -DUA_ENABLE_MULTITHREADING=ON ..
  322. make -j
  323. if [ $? -ne 0 ] ; then exit 1 ; fi
  324. cd .. && rm build -rf
  325. echo -en 'travis_fold:end:script.build.multithread\\r'
  326. fi
  327. echo -e "\r\n== Compile with encryption ==" && echo -en 'travis_fold:start:script.build.encryption\\r'
  328. mkdir -p build && cd build
  329. cmake \
  330. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  331. -DUA_BUILD_EXAMPLES=ON \
  332. -DUA_ENABLE_ENCRYPTION=ON ..
  333. make -j
  334. if [ $? -ne 0 ] ; then exit 1 ; fi
  335. cd .. && rm build -rf
  336. echo -en 'travis_fold:end:script.build.encryption\\r'
  337. echo -e "\r\n== Compile without discovery version ==" && echo -en 'travis_fold:start:script.build.discovery\\r'
  338. mkdir -p build && cd build
  339. cmake \
  340. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  341. -DUA_BUILD_EXAMPLES=ON \
  342. -DUA_ENABLE_DISCOVERY=OFF \
  343. -DUA_ENABLE_DISCOVERY_MULTICAST=OFF ..
  344. make -j
  345. if [ $? -ne 0 ] ; then exit 1 ; fi
  346. cd .. && rm build -rf
  347. echo -en 'travis_fold:end:script.build.discovery\\r'
  348. if [ "$CC" != "tcc" ]; then
  349. echo -e "\r\n== Compile multithreaded version with discovery ==" && echo -en 'travis_fold:start:script.build.multithread_discovery\\r'
  350. mkdir -p build && cd build
  351. cmake \
  352. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  353. -DUA_BUILD_EXAMPLES=ON \
  354. -DUA_ENABLE_DISCOVERY=ON \
  355. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  356. -DUA_ENABLE_MULTITHREADING=ON ..
  357. make -j
  358. if [ $? -ne 0 ] ; then exit 1 ; fi
  359. cd .. && rm build -rf
  360. echo -en 'travis_fold:end:script.build.multithread_discovery\\r'
  361. fi
  362. echo -e "\r\n== Compile JSON encoding ==" && echo -en 'travis_fold:start:script.build.json\\r'
  363. mkdir -p build && cd build
  364. cmake \
  365. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  366. -DUA_ENABLE_JSON_ENCODING=ON ..
  367. make -j
  368. if [ $? -ne 0 ] ; then exit 1 ; fi
  369. cd .. && rm build -rf
  370. echo -en 'travis_fold:end:script.build.json\\r'
  371. echo -e "\r\n== Unit tests (full NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_full\\r'
  372. mkdir -p build && cd build
  373. # Valgrind cannot handle the full NS0 because the generated file is too big. Thus run NS0 full without valgrind
  374. cmake \
  375. -DCMAKE_BUILD_TYPE=Debug \
  376. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  377. -DUA_BUILD_EXAMPLES=ON \
  378. -DUA_BUILD_UNIT_TESTS=ON \
  379. -DUA_ENABLE_COVERAGE=OFF \
  380. -DUA_ENABLE_DA=ON \
  381. -DUA_ENABLE_DISCOVERY=ON \
  382. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  383. -DUA_ENABLE_ENCRYPTION=ON \
  384. -DUA_ENABLE_JSON_ENCODING=ON \
  385. -DUA_ENABLE_PUBSUB=ON \
  386. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  387. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON \
  388. -DUA_ENABLE_SUBSCRIPTIONS=ON \
  389. -DUA_ENABLE_SUBSCRIPTIONS_EVENTS=ON \
  390. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=OFF \
  391. -DUA_NAMESPACE_ZERO=FULL ..
  392. make -j && make test ARGS="-V"
  393. if [ $? -ne 0 ] ; then exit 1 ; fi
  394. cd .. && rm build -rf
  395. echo -en 'travis_fold:end:script.build.unit_test_ns0_full\\r'
  396. if ! [ -z ${DEBIAN+x} ]; then
  397. echo -e "\r\n== Building the Debian package ==" && echo -en 'travis_fold:start:script.build.debian\\r'
  398. /usr/bin/$PYTHON ./tools/prepare_packaging.py
  399. echo -e "\r\n --- New debian changelog content ---"
  400. echo "--------------------------------------"
  401. cat ./debian/changelog
  402. echo "--------------------------------------"
  403. # Create a backup copy. We need the clean debian directory for later packaging
  404. cp -r debian debian_bak
  405. dpkg-buildpackage -b
  406. if [ $? -ne 0 ] ; then exit 1 ; fi
  407. rm -rf debian
  408. mv debian_bak debian
  409. cp ../libopen62541*.deb .
  410. # Copy for github release script
  411. cp ../libopen62541*.deb ../..
  412. echo -en 'travis_fold:end:script.build.debian\\r'
  413. fi
  414. if [ "$CC" != "tcc" ]; then
  415. echo -e "\r\n== Unit tests (minimal NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_minimal\\r'
  416. mkdir -p build && cd build
  417. cmake \
  418. -DCMAKE_BUILD_TYPE=Debug \
  419. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  420. -DUA_BUILD_EXAMPLES=ON \
  421. -DUA_BUILD_UNIT_TESTS=ON \
  422. -DUA_ENABLE_COVERAGE=ON \
  423. -DUA_ENABLE_DA=ON \
  424. -DUA_ENABLE_DISCOVERY=ON \
  425. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  426. -DUA_ENABLE_ENCRYPTION=ON \
  427. -DUA_ENABLE_JSON_ENCODING=ON \
  428. -DUA_ENABLE_PUBSUB=ON \
  429. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  430. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=OFF \
  431. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON \
  432. -DUA_NAMESPACE_ZERO=MINIMAL ..
  433. make -j && make test ARGS="-V"
  434. if [ $? -ne 0 ] ; then exit 1 ; fi
  435. cd .. && rm build -rf
  436. echo -en 'travis_fold:end:script.build.unit_test_ns0_minimal\\r'
  437. echo -e "\r\n== Unit tests (reduced NS0) ==" && echo -en 'travis_fold:start:script.build.unit_test_ns0_reduced\\r'
  438. mkdir -p build && cd build
  439. cmake \
  440. -DCMAKE_BUILD_TYPE=Debug \
  441. -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/$PYTHON \
  442. -DUA_BUILD_EXAMPLES=ON \
  443. -DUA_BUILD_UNIT_TESTS=ON \
  444. -DUA_ENABLE_COVERAGE=ON \
  445. -DUA_ENABLE_DA=ON \
  446. -DUA_ENABLE_DISCOVERY=ON \
  447. -DUA_ENABLE_DISCOVERY_MULTICAST=ON \
  448. -DUA_ENABLE_ENCRYPTION=ON \
  449. -DUA_ENABLE_JSON_ENCODING=ON \
  450. -DUA_ENABLE_PUBSUB=ON \
  451. -DUA_ENABLE_PUBSUB_DELTAFRAMES=ON \
  452. -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON \
  453. -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON \
  454. -DUA_NAMESPACE_ZERO=REDUCED ..
  455. make -j && make test ARGS="-V"
  456. if [ $? -ne 0 ] ; then exit 1 ; fi
  457. echo -en 'travis_fold:end:script.build.unit_test_ns0_reduced\\r'
  458. # only run coveralls on main repo and when MINGW=true
  459. # We only want to build coveralls once, so we just take the travis run where MINGW=true which is only enabled once
  460. echo -e "\r\n== -> Current repo: ${TRAVIS_REPO_SLUG} =="
  461. if [ $MINGW = "true" ] && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
  462. echo -en "\r\n== Building codecov.io for ${TRAVIS_REPO_SLUG} ==" && echo -en 'travis_fold:start:script.build.codecov\\r'
  463. cd ..
  464. /bin/bash -c "bash <(curl -s https://codecov.io/bash)"
  465. if [ $? -ne 0 ] ; then exit 1 ; fi
  466. cd build
  467. echo -en 'travis_fold:end:script.build.codecov\\r'
  468. echo -en "\r\n== Building coveralls for ${TRAVIS_REPO_SLUG} ==" && echo -en 'travis_fold:start:script.build.coveralls\\r'
  469. coveralls -E '.*/build/CMakeFiles/.*' -E '.*/examples/.*' -E '.*/tests/.*' -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../ || true # ignore result since coveralls is unreachable from time to time
  470. cd .. && rm build -rf
  471. echo -en 'travis_fold:end:script.build.coveralls\\r'
  472. if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
  473. if [ "${TRAVIS_BRANCH}" = "master" ] || [ "${TRAVIS_BRANCH}" = "1.0" ]; then
  474. # Create a separate branch with the `pack/` prefix. This branch has the correct debian/changelog set, and
  475. # The submodules are directly copied
  476. echo -e "\r\n== Pushing 'pack/${TRAVIS_BRANCH}' branch ==" && echo -en 'travis_fold:start:script.build.pack-branch\\r'
  477. git checkout -b pack-tmp/${TRAVIS_BRANCH}
  478. cp -r deps/mdnsd deps/mdnsd_back
  479. cp -r deps/ua-nodeset deps/ua-nodeset_back
  480. git rm -rf --cached deps/mdnsd
  481. git rm -rf --cached deps/ua-nodeset
  482. mv deps/mdnsd_back deps/mdnsd
  483. rm -rf deps/mdnsd/.git
  484. mv deps/ua-nodeset_back deps/ua-nodeset
  485. rm -rf deps/ua-nodeset/.git
  486. rm -rf .gitmodules
  487. git add deps/*
  488. git add debian/*
  489. git add CMakeLists.txt
  490. git commit -m "[ci skip] Pack with inline submodules"
  491. git remote add origin-auth https://$GITAUTH@github.com/${TRAVIS_REPO_SLUG}
  492. git push -uf origin-auth pack-tmp/${TRAVIS_BRANCH}:pack/${TRAVIS_BRANCH}
  493. echo -en 'travis_fold:end:script.build.pack-branch\\r'
  494. fi
  495. fi
  496. fi
  497. fi