浏览代码

Merge of Pro's travis infrastructure migration

Closing #551 with this.

Squashed commit of the following:

commit 11f904349a76a68d6bb6deaf76c14e8c675b1753
Author: Stefan Profanter <git@s.profanter.me>
Date:   Thu Mar 3 16:06:41 2016 +0100

    Caching install dir

commit fce442443993c4f78089000b81d293c7b64ee794
Merge: 8eed598 559b88e
Author: Stefan Profanter <git@s.profanter.me>
Date:   Thu Mar 3 15:29:52 2016 +0100

    Merge remote-tracking branch 'upstream/master' and resolve conflicts

commit 8eed598e1283d54420848f4311b4367a9da7c4ba
Author: Stefan Profanter <git@s.profanter.me>
Date:   Thu Mar 3 15:22:09 2016 +0100

    Use valgrind 3.11

commit 2def5858cd68c3e5d52c5a2943909ead079e4cf2
Author: Stefan Profanter <git@s.profanter.me>
Date:   Wed Mar 2 08:32:01 2016 +0100

    Using -j8 flag for make

commit f75ea211d66f677de87fce7c180cd75a24fbec89
Merge: f0170c0 eb9b8e5
Author: Stefan Profanter <git@s.profanter.me>
Date:   Wed Mar 2 08:30:45 2016 +0100

    Merge remote-tracking branch 'upstream/simpify_amalgate'

commit eb9b8e57424d69a406cc661bbd6dbe37da992af0
Author: Stasik0 <github@stasik.com>
Date:   Wed Mar 2 08:19:06 2016 +0100

    trying to make CMake simpler, by removing additional dependencies

commit f0170c06ea9bc11d9a0156464a1c57ce1e3dd244
Author: Stefan Profanter <git@s.profanter.me>
Date:   Wed Mar 2 00:08:58 2016 +0100

    Minor build fixes
    - Add amalgamation to server-static
    - Only switch to gcc-4.8 if gcc is used
    - Build coveralls only if gcc is used
    - cast return value in examples (causes clang to fail otherwise)

commit c1e0e40672f105428754d61ef9a7e5c7dea4956c
Author: Stefan Profanter <git@s.profanter.me>
Date:   Tue Mar 1 15:57:31 2016 +0100

    Cross compile only for gcc

commit eb8e7a26388389576582f50972d80c989742f70f
Author: Stefan Profanter <git@s.profanter.me>
Date:   Tue Mar 1 15:15:46 2016 +0100

    Allow ANALYZE=true builds to fail

commit e659d928bbcdb3fba07ba7b5c3b07fbe83665c4d
Author: Stefan Profanter <git@s.profanter.me>
Date:   Tue Mar 1 15:10:09 2016 +0100

    Using new travis build environment and cppcheck (fix #391 and fix #371)
Julius Pfrommer 9 年之前
父节点
当前提交
a6fbd5cf3a

+ 79 - 10
.travis.yml

@@ -1,16 +1,60 @@
 language: c
+
 compiler:
 - gcc
-#- clang
+- clang
+
 os:
 - linux
-- osx
-sudo: true
+# - osx
+
+# use new build environment (docker)
+sudo: false
+
 env:
   global:
-  - secure: nSunY54Wp5HkQCHHbKwlwpbaKyqRVIu/0EnhaoJSwhM1wqerQV/E5d/2JelO9/tZgbungAO7wk/fjutRMVc7d378RTIPwS8vHpvZfEoGhCFsLoTOlqESzsZFBup2H5t1lpQ23jRHDOxlLdJy2lz5U+zd1YnYgDXqdDFjegsIYdo=
-  - secure: ehswgymGXPM3UINhOOnfSByMnrRNTixeT2vEV+z3kXy3WHew/O1yt9GxaYGrUhJPg4+5chAQgjYmezO1x3/CUKFgeHQUmVTFWEzfy1kL1JVjO+ufYyJDnbY+x3OmyNmMYcef2J5MAuUS2C1KFvIxtLsljVK+gpe4LcylkCIF/3Y=
+    - secure: nSunY54Wp5HkQCHHbKwlwpbaKyqRVIu/0EnhaoJSwhM1wqerQV/E5d/2JelO9/tZgbungAO7wk/fjutRMVc7d378RTIPwS8vHpvZfEoGhCFsLoTOlqESzsZFBup2H5t1lpQ23jRHDOxlLdJy2lz5U+zd1YnYgDXqdDFjegsIYdo=
+    - secure: ehswgymGXPM3UINhOOnfSByMnrRNTixeT2vEV+z3kXy3WHew/O1yt9GxaYGrUhJPg4+5chAQgjYmezO1x3/CUKFgeHQUmVTFWEzfy1kL1JVjO+ufYyJDnbY+x3OmyNmMYcef2J5MAuUS2C1KFvIxtLsljVK+gpe4LcylkCIF/3Y=
+  matrix:
+    # Do both, compile with static code analysis and without
+    - ANALYZE=false
+    - ANALYZE=true
+
+matrix:
+  exclude:
+  # This excludes OSX GCC builds.
+    - os: osx
+      compiler: gcc
+    - os: osx
+      env: ANALYZE=true
+  allow_failures:
+    - env: ANALYZE=true
+
 addons:
+  apt:
+    sources:
+      # see https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
+      - kalakris-cmake
+      - ubuntu-toolchain-r-test
+    packages:
+      - binutils-mingw-w64-i686
+      - build-essential
+      - clang
+      - cmake
+      - cppcheck
+      - gcc-4.8
+      - gcc-mingw-w64-i686
+      - gcc-multilib
+      - g++-4.8
+      - libc6-dbg # for valgrind compilation
+      - libsubunit-dev
+      - libx11-dev
+      - mingw-w64
+      - python-lxml
+      - wget
+      - xutils-dev
+      - zip
+    # - libsubunit-dev #for check_0.10.0
   coverity_scan:
     project:
       name: acplt/open62541
@@ -19,21 +63,44 @@ addons:
     build_command_prepend: mkdir build && cd build && cmake ..
     build_command: make
     branch_pattern: coverity_scan
-matrix:
-  # This excludes OSX GCC builds.
-  exclude:
-    - os: osx
-      compiler: gcc
+
+cache:
+  pip: true
+  apt: true
+  directories:
+    - $HOME/install
+
 before_install:
+# set paths for locally installed libs (like liburcu)
+- export LOCAL_PKG=$HOME/install
+- mkdir -p $LOCAL_PKG/lib
+- mkdir -p $LOCAL_PKG/include
+- mkdir -p $LOCAL_PKG/bin
+- export LIBRARY_PATH=$LOCAL_PKG/lib:$LIBRARY_PATH
+- export C_INCLUDE_PATH=$LOCAL_PKG/include:$C_INCLUDE_PATH
+- export CPLUS_INCLUDE_PATH=$LOCAL_PKG/include:$CPLUS_INCLUDE_PATH
+- export PKG_CONFIG_PATH=$LOCAL_PKG/lib/pkgconfig:$PKG_CONFIG_PATH
+- export PATH=$LOCAL_PKG:$LOCAL_PKG/bin:$PATH
+# set local path for python packages
+- export PATH=$PATH:$HOME/.local/bin # linux
+- export PATH=$PATH:$HOME/Library/Python #OS X
+- export PATH=$PATH:$HOME/Library/Python/2.7/bin #OS X
+# set search path for check library
+- export CHECK_INCLUDE_DIRS=$LOCAL_PKG/include/
+- export CHECK_LIBRARIES=$LOCAL_PKG/lib/
+
 - if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis_linux_before_install.sh; fi
 - if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis_osx_before_install.sh; fi
+
 script:
 - if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis_linux_script.sh; fi
 - if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis_osx_script.sh; fi
+
 after_success:
 - if [[ ( ${TRAVIS_OS_NAME} == "linux" && ${CC} == "gcc" && ${TRAVIS_BRANCH} == "master" && ${TRAVIS_PULL_REQUEST} == "false" ) ]]; then sh ./tools/travis_push_doc.sh; fi
 - if [[ ( ${TRAVIS_OS_NAME} == "linux" && ${CC} == "gcc" && ${TRAVIS_BRANCH} == "master" && ${TRAVIS_PULL_REQUEST} == "false" ) ]]; then sh ./tools/travis_push_coverity.sh; fi
 - if [[ ( ${TRAVIS_OS_NAME} == "linux" && ${CC} == "gcc" ) ]]; then sh ./tools/travis_push_release.sh; fi
+
 before_deploy:
 - rm build -rf && mkdir -p build && cd build
 - echo "Cross compile release build for Raspberry Pi"
@@ -46,6 +113,7 @@ before_deploy:
 - tar -pczf open62541-raspberrypi.tar.gz ../doc ../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.so open62541.h open62541.c
 - cp open62541-raspberrypi.tar.gz ..
 - cd ..
+
 deploy:
   provider: releases
   api_key:
@@ -60,5 +128,6 @@ deploy:
     - open62541.h
   skip_cleanup: true
   on:
+    repo: open62541/open62541
     tags: true
     condition: $CC = gcc

+ 4 - 18
CMakeLists.txt

@@ -8,16 +8,10 @@ project(open62541 C)
 
 # Find Python and Python-lxml
 find_package(PythonInterp REQUIRED)
-execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
-                OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
-                OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(NOT EXISTS "${PYTHON_SITE_PACKAGES}/lxml")
-  execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
-                  OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
-    if(NOT EXISTS "${PYTHON_SITE_PACKAGES}/lxml")
-        message(FATAL_ERROR "Python-lxml is not installed.")
-    endif()
+execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import lxml"
+                RESULT_VARIABLE IMPORT_LXML_RESULT)
+if(NOT "${IMPORT_LXML_RESULT}" STREQUAL "0")
+    message(FATAL_ERROR "Python-lxml is not installed.")
 endif()
 
 # Check for git
@@ -354,7 +348,6 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
 
 # build shared library
 if(UA_ENABLE_AMALGAMATION)
-    add_custom_target(amalgamation ALL DEPENDS ${PROJECT_BINARY_DIR}/open62541.h ${PROJECT_BINARY_DIR}/open62541.c)
     add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
     include_directories(${PROJECT_BINARY_DIR})
 else()
@@ -380,9 +373,6 @@ if(UA_BUILD_EXAMPLESERVER)
     set(server_source $<TARGET_OBJECTS:open62541-object>)
     add_executable(server_static examples/server.c ${server_source})
     add_executable(server examples/server.c)
-    if(UA_ENABLE_AMALGAMATION)
-       ADD_DEPENDENCIES(server amalgamation)
-    endif()
     target_link_libraries(server ${open62541_LIBRARIES} open62541)
     target_link_libraries(server_static ${open62541_LIBRARIES})
     if(WIN32)
@@ -425,10 +415,6 @@ if(UA_BUILD_EXAMPLECLIENT)
     set(client_source $<TARGET_OBJECTS:open62541-object>)
 	add_executable(client_static examples/client.c ${client_source})
     add_executable(client examples/client.c)
-	if(UA_ENABLE_AMALGAMATION)
-	   ADD_DEPENDENCIES(client_static amalgamation)
-	   ADD_DEPENDENCIES(client amalgamation)
-	endif()
 	target_link_libraries(client_static ${open62541_LIBRARIES})
 	target_link_libraries(client open62541 ${open62541_LIBRARIES})
     if(WIN32)

+ 1 - 1
examples/client.c

@@ -252,6 +252,6 @@ int main(int argc, char *argv[]) {
 #endif
     UA_Client_disconnect(client);
     UA_Client_delete(client);
-    return UA_STATUSCODE_GOOD;
+    return (int) UA_STATUSCODE_GOOD;
 }
 

+ 1 - 1
examples/client_firstSteps.c

@@ -48,5 +48,5 @@ int main(void) {
 
     UA_Client_disconnect(client);
     UA_Client_delete(client);
-    return UA_STATUSCODE_GOOD;
+    return (int) UA_STATUSCODE_GOOD;
 }

+ 1 - 1
examples/server_udp.c

@@ -47,5 +47,5 @@ int main(int argc, char** argv) {
     UA_StatusCode retval = UA_Server_run(server, 1, &running);
 	UA_Server_delete(server);
 
-	return retval;
+	return (int) retval;
 }

+ 2 - 2
src/server/ua_nodestore.c

@@ -185,8 +185,8 @@ void UA_NodeStore_delete(UA_NodeStore *ns) {
     UA_free(ns);
 }
 
-UA_Node * UA_NodeStore_newNode(UA_NodeClass nodeClass) {
-    UA_NodeStoreEntry *entry = instantiateEntry(nodeClass);
+UA_Node * UA_NodeStore_newNode(UA_NodeClass class) {
+    UA_NodeStoreEntry *entry = instantiateEntry(class);
     if(!entry)
         return NULL;
     return (UA_Node*)&entry->node;

+ 1 - 1
src/server/ua_nodestore.h

@@ -20,7 +20,7 @@ UA_NodeStore * UA_NodeStore_new(void);
 void UA_NodeStore_delete(UA_NodeStore *ns);
 
 /** Create an editable node of the given NodeClass. */
-UA_Node * UA_NodeStore_newNode(UA_NodeClass nodeClass);
+UA_Node * UA_NodeStore_newNode(UA_NodeClass class);
 #define UA_NodeStore_newObjectNode() (UA_ObjectNode*)UA_NodeStore_newNode(UA_NODECLASS_OBJECT)
 #define UA_NodeStore_newVariableNode() (UA_VariableNode*)UA_NodeStore_newNode(UA_NODECLASS_VARIABLE)
 #define UA_NodeStore_newMethodNode() (UA_MethodNode*)UA_NodeStore_newNode(UA_NODECLASS_METHOD)

+ 2 - 2
src/server/ua_nodestore_concurrent.c

@@ -84,8 +84,8 @@ void UA_NodeStore_delete(UA_NodeStore *ns) {
     UA_free(ns);
 }
 
-UA_Node * UA_NodeStore_newNode(UA_NodeClass nodeClass) {
-    struct nodeEntry *entry = instantiateEntry(nodeClass);
+UA_Node * UA_NodeStore_newNode(UA_NodeClass class) {
+    struct nodeEntry *entry = instantiateEntry(class);
     if(!entry)
         return NULL;
     return (UA_Node*)&entry->node;

+ 8 - 1
src_extra/networklayer_tcp.c

@@ -35,7 +35,6 @@
 
 /* workaround a glibc bug where an integer conversion is required */
 #if !defined(_WIN32)
-# include <features.h>
 # if defined(__GNU_LIBRARY__) && (__GNU_LIBRARY__ >= 6) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 16)
 #  define UA_fd_set(fd, fds) FD_SET(fd, fds)
 #  define UA_fd_isset(fd, fds) FD_ISSET(fd, fds)
@@ -110,7 +109,11 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
         /* currently, only the client uses timeouts */
 #ifndef _WIN32
         UA_UInt32 timeout_usec = timeout * 1000;
+    #ifdef __APPLE__
+        struct timeval tmptv = {(long int)(timeout_usec / 1000000), timeout_usec % 1000000};
+	#else
         struct timeval tmptv = {(long int)(timeout_usec / 1000000), (long int)(timeout_usec % 1000000)};
+	#endif
         int ret = setsockopt(connection->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tmptv, sizeof(struct timeval));
 #else
         DWORD timeout_dw = timeout;
@@ -130,7 +133,11 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
     if (timeout > 0) {
         fd_set fdset;
         UA_UInt32 timeout_usec = timeout * 1000;
+    #ifdef __APPLE__
+        struct timeval tmptv = {(long int)(timeout_usec / 1000000), timeout_usec % 1000000};
+	#else
         struct timeval tmptv = {(long int)(timeout_usec / 1000000), (long int)(timeout_usec % 1000000)};
+	#endif
         UA_Int32 retval;
 
         FD_ZERO(&fdset);

+ 53 - 15
tools/travis_linux_before_install.sh

@@ -1,17 +1,55 @@
 #!/bin/bash
 set -ev
-sudo apt-get update
-sudo apt-get install binutils-mingw-w64-i686 gcc-mingw-w64-i686 mingw-w64
-sudo add-apt-repository ppa:kalakris/cmake -y
-sudo apt-get update -qq
-sudo apt-get install -qq --no-install-recommends build-essential cmake python-lxml gcc-multilib wget zip
-sudo apt-get install libsubunit-dev #for check_0.10.0
-wget http://ftp.de.debian.org/debian/pool/main/c/check/check_0.10.0-3_amd64.deb
-sudo dpkg -i check_0.10.0-3_amd64.deb
-wget https://launchpad.net/ubuntu/+source/liburcu/0.8.5-1ubuntu1/+build/6513813/+files/liburcu2_0.8.5-1ubuntu1_amd64.deb
-wget https://launchpad.net/ubuntu/+source/liburcu/0.8.5-1ubuntu1/+build/6513813/+files/liburcu-dev_0.8.5-1ubuntu1_amd64.deb
-sudo dpkg -i liburcu2_0.8.5-1ubuntu1_amd64.deb
-sudo dpkg -i liburcu-dev_0.8.5-1ubuntu1_amd64.deb
-sudo pip install cpp-coveralls
-sudo pip install sphinx
-sudo pip install sphinx_rtd_theme
+
+if [ $ANALYZE = "true" ]; then
+  	g++ --version
+  	cppcheck --version
+else
+	cd $LOCAL_PKG
+
+	# travis caches the $LOCAL_PKG dir. If it is loaded, we don't need to reinstall the packages
+	if [ ! -f $LOCAL_PKG/.cached ]; then
+
+		# Install newer valgrind
+		mkdir -p $LOCAL_PKG/package && cd $LOCAL_PKG/package
+		wget http://valgrind.org/downloads/valgrind-3.11.0.tar.bz2
+		tar xf valgrind-3.11.0.tar.bz2
+		cd valgrind-3.11.0
+		./configure --prefix=$LOCAL_PKG
+		make -s -j8 install
+		echo "\n### Installed valgrind version: $(valgrind --version)"
+		cd $LOCAL_PKG
+
+		# Install specific check version which is not yet in the apt package
+	 	wget http://ftp.de.debian.org/debian/pool/main/c/check/check_0.10.0-3_amd64.deb
+	 	dpkg -x check_0.10.0-3_amd64.deb $LOCAL_PKG/package
+	 	# change pkg-config file path
+		sed -i "s|prefix=/usr|prefix=${LOCAL_PKG}|g" $LOCAL_PKG/package/usr/lib/x86_64-linux-gnu/pkgconfig/check.pc
+		sed -i 's|libdir=.*|libdir=${prefix}/lib|g' $LOCAL_PKG/package/usr/lib/x86_64-linux-gnu/pkgconfig/check.pc
+		# move files to globally included dirs
+		cp -R $LOCAL_PKG/package/usr/lib/x86_64-linux-gnu/* $LOCAL_PKG/lib/
+		cp -R $LOCAL_PKG/package/usr/include/* $LOCAL_PKG/include/
+		cp -R $LOCAL_PKG/package/usr/bin/* $LOCAL_PKG/
+
+		# Install specific liburcu version which is not yet in the apt package
+		wget https://launchpad.net/ubuntu/+source/liburcu/0.8.5-1ubuntu1/+build/6513813/+files/liburcu2_0.8.5-1ubuntu1_amd64.deb
+		wget https://launchpad.net/ubuntu/+source/liburcu/0.8.5-1ubuntu1/+build/6513813/+files/liburcu-dev_0.8.5-1ubuntu1_amd64.deb
+		dpkg -x liburcu2_0.8.5-1ubuntu1_amd64.deb $LOCAL_PKG/package
+		dpkg -x liburcu-dev_0.8.5-1ubuntu1_amd64.deb $LOCAL_PKG/package
+		# move files to globally included dirs
+		cp -R $LOCAL_PKG/package/usr/lib/x86_64-linux-gnu/* $LOCAL_PKG/lib/
+		cp -R $LOCAL_PKG/package/usr/include/* $LOCAL_PKG/include/
+
+		# create cached flag
+		touch $LOCAL_PKG/.cached
+
+	else
+		echo "\n## Using local packages from cache\n"
+	fi
+
+
+
+	pip install --user cpp-coveralls
+	pip install --user sphinx
+	pip install --user sphinx_rtd_theme
+fi

+ 99 - 65
tools/travis_linux_script.sh

@@ -1,76 +1,110 @@
 #!/bin/bash
 set -ev
 
-echo "Documentation and certificate build"
-mkdir -p build
-cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
-make doc
-make selfsigned
-cp -r doc ../../
-cp server_cert.der ../../
-cd .. && rm build -rf 
+if [ $ANALYZE = "true" ]; then
+	echo "\n=== Running static code analysis ==="
+	if [ "$CC" = "clang" ]; then
+		mkdir -p build
+		cd build
+        scan-build cmake -G "Unix Makefiles" ..
+        scan-build -enable-checker security.FloatLoopCounter \
+          -enable-checker security.insecureAPI.UncheckedReturn \
+          --status-bugs -v \
+          make -j 8
+    else
+        cppcheck --template "{file}({line}): {severity} ({id}): {message}" \
+            --enable=style --force --std=c++11 -j 8 \
+            --suppress=incorrectStringBooleanError \
+            --suppress=invalidscanf --inline-suppr \
+            -I include src src_extra 2> cppcheck.txt
+        if [ -s cppcheck.txt ]; then
+        	echo "\n\n====== CPPCHECK Static Analysis Errors ======"
+            cat cppcheck.txt
+            exit 1
+        fi
+    fi
+else
+	echo "\n=== Building ==="
 
-echo "Cross compile release build for MinGW 32 bit"
-mkdir -p build && cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON ..
-make
-zip -r open62541-win32.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static.exe server.exe client.exe client_static.exe libopen62541.dll libopen62541.dll.a open62541.h open62541.c
-cp open62541-win32.zip ..
-cd .. && rm build -rf 
+	echo "Documentation and certificate build"
+	mkdir -p build
+	cd build
+	cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
+	make doc
+	make selfsigned
+	cp -r doc ../../
+	cp server_cert.der ../../
+	cd .. && rm build -rf
 
-echo "Cross compile release build for MinGW 64 bit"
-mkdir -p build && cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON ..
-make
-zip -r open62541-win64.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static.exe server.exe client.exe client_static.exe libopen62541.dll libopen62541.dll.a open62541.h open62541.c
-cp open62541-win64.zip ..
-cd .. && rm build -rf 
+	# cross compilation only with gcc
+	if [ "$CC" = "gcc" ]; then
+		echo "Cross compile release build for MinGW 32 bit"
+		mkdir -p build && cd build
+		cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON ..
+		make -j8
+		zip -r open62541-win32.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static.exe server.exe client.exe client_static.exe libopen62541.dll libopen62541.dll.a open62541.h open62541.c
+		cp open62541-win32.zip ..
+		cd .. && rm build -rf
 
-echo "Cross compile release build for 32-bit linux"
-mkdir -p build && cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON ..
-make
-tar -pczf open62541-linux32.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.so open62541.h open62541.c
-cp open62541-linux32.tar.gz ..
-cd .. && rm build -rf 
+		echo "Cross compile release build for MinGW 64 bit"
+		mkdir -p build && cd build
+		cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_EXAMPLES=ON ..
+		make -j8
+		zip -r open62541-win64.zip ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static.exe server.exe client.exe client_static.exe libopen62541.dll libopen62541.dll.a open62541.h open62541.c
+		cp open62541-win64.zip ..
+		cd .. && rm build -rf
 
-echo "Compile release build for 64-bit linux"
-mkdir -p build && cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON ..
-make
-tar -pczf open62541-linux64.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.so open62541.h open62541.c
-cp open62541-linux64.tar.gz ..
-cp open62541.h ../../ #copy single file-release
-cp open62541.c ../../ #copy single file-release
-cd .. && rm build -rf 
+		echo "Cross compile release build for 32-bit linux"
+		mkdir -p build && cd build
+		cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON ..
+		make -j8
+		tar -pczf open62541-linux32.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.so open62541.h open62541.c
+		cp open62541-linux32.tar.gz ..
+		cd .. && rm build -rf
+	fi
 
-echo "Upgrade to gcc 4.8"
-sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
-sudo apt-get update -qq
-sudo apt-get install -qq gcc-4.8 g++-4.8 valgrind
-sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
-sudo update-alternatives --config gcc
+	echo "Compile release build for 64-bit linux"
+	mkdir -p build && cd build
+	cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON ..
+	make -j8
+	tar -pczf open62541-linux64.tar.gz ../../doc ../../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.so open62541.h open62541.c
+	cp open62541-linux64.tar.gz ..
+	cp open62541.h ../../ #copy single file-release
+	cp open62541.c ../../ #copy single file-release
+	cd .. && rm build -rf
 
-echo "Building the C++ example"
-mkdir -p build && cd build
-cp ../../open62541.* .
-gcc -std=c99 -c open62541.c
-g++-4.8 ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
-cd .. && rm build -rf 
+	if [ "$CC" = "gcc" ]; then
+		echo "Upgrade to gcc 4.8"
+		export CXX="g++-4.8" CC="gcc-4.8"
+	fi
+	
+	echo "Building the C++ example"
+	mkdir -p build && cd build
+	cp ../../open62541.* .
+	gcc-4.8 -std=c99 -c open62541.c
+	g++-4.8 ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
+	cd .. && rm build -rf
 
-echo "Compile multithreaded version"
-mkdir -p build && cd build
-cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON ..
-make
-cd .. && rm build -rf 
+	echo "Compile multithreaded version"
+	mkdir -p build && cd build
+	cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON ..
+	make -j8
+	cd .. && rm build -rf
 
-#this run inclides full examples and methodcalls
-echo "Debug build and unit tests (64 bit)"
-mkdir -p build && cd build
-cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_METHODCALLS=ON -DUA_BUILD_DEMO_NODESET=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_ENABLE_COVERAGE=ON ..
-make && make test ARGS="-V"
-echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
-(valgrind --error-exitcode=3 ./server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
-coveralls --gcov /usr/bin/gcov-4.8 -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../
-cd .. && rm build -rf
+	#this run inclides full examples and methodcalls
+	echo "Debug build and unit tests (64 bit)"
+	mkdir -p build && cd build
+	cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_METHODCALLS=ON -DUA_BUILD_DEMO_NODESET=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_ENABLE_COVERAGE=ON ..
+	make -j8 && make test ARGS="-V"
+	echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
+	(valgrind --error-exitcode=3 ./server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
+	# only run coveralls on main repo, otherwise it fails uploading the files
+	echo "-> Current repo: ${TRAVIS_REPO_SLUG}"
+	if ([ "$CC" = "gcc-4.8" ] || [ "$CC" = "gcc" ]) && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then
+		echo "	Building coveralls for ${TRAVIS_REPO_SLUG}"
+		coveralls --gcov /usr/bin/gcov-4.8 -E '.*\.h' -E '.*CMakeCXXCompilerId\.cpp' -E '.*CMakeCCompilerId\.c' -r ../
+	else
+		echo "	Skipping coveralls since not gcc and/or ${TRAVIS_REPO_SLUG} is not the main repo"
+	fi
+	cd .. && rm build -rf
+fi

+ 15 - 9
tools/travis_osx_before_install.sh

@@ -1,12 +1,18 @@
 #!/bin/bash
 set -ev
-brew install cmake
-brew install check
-brew install libxml2
-brew install userspace-rcu
-brew install --HEAD valgrind
 
-sudo pip install lxml
-sudo pip install sphinx
-sudo pip install breathe
-sudo pip install sphinx_rtd_theme
+if [ $ANALYZE = "true" ]; then
+	echo "Skipping static analysis for OS X"
+	exit 0
+else
+	brew install check
+	brew install libxml2
+	brew install userspace-rcu
+	brew install valgrind
+
+	pip install --user lxml
+	pip install --user sphinx
+	pip install --user breathe
+	pip install --user sphinx_rtd_theme
+
+fi

+ 36 - 21
tools/travis_osx_script.sh

@@ -1,26 +1,41 @@
 #!/bin/bash
 set -ev
 
-echo "Compile release build for OS X"
-mkdir -p build && cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_GENERATE_SELFSIGNED=ON ..
-make
-tar -pczf open62541-osx.tar.gz ../doc ../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.dylib open62541.h open62541.c
-cp open62541-osx.tar.gz ..
-cp open62541.h .. #copy single file-release
-cp open62541.c .. #copy single file-release
-cd .. && rm -rf build
+if [ $ANALYZE = "true" ]; then
+	echo "\n=== Skipping static analysis on OS X ==="
+	exit 0
+else
+	echo "\n=== Building ==="
 
-echo "Compile multithreaded version"
-mkdir -p build && cd build
-cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON ..
-make
-cd .. && rm -rf build
+	echo "Create certificate for OS X build"
+	mkdir -p build && cd build
+	cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLESERVER=OFF -DUA_BUILD_EXAMPLECLIENT=OFF -DUA_BUILD_EXAMPLES=OFF -DUA_BUILD_DOCUMENTATION=OFF -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
+	make selfsigned
+	cp server_cert.der ../
+	cd .. && rm -rf build
 
-echo "Debug build and unit tests (64 bit)"
-mkdir -p build && cd build
-cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_DEMO_NODESET=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_ENABLE_COVERAGE=ON ..
-make && make test
-echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
-(valgrind --error-exitcode=3 ./server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
-cd .. && rm -rf build
+	echo "Compile release build for OS X"
+	mkdir -p build && cd build
+	cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_BUILD_EXAMPLECLIENT=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_GENERATE_SELFSIGNED=ON ..
+	make -j8
+	tar -pczf open62541-osx.tar.gz ../doc ../server_cert.der ../LICENSE ../AUTHORS ../README.md server_static server client_static client libopen62541.dylib open62541.h open62541.c
+	cp open62541-osx.tar.gz ..
+	cp open62541.h .. #copy single file-release
+	cp open62541.c .. #copy single file-release
+	cd .. && rm -rf build
+
+	echo "Compile multithreaded version"
+	mkdir -p build && cd build
+	cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLESERVER=ON ..
+	make -j8
+	cd .. && rm -rf build
+
+	echo "Debug build and unit tests (64 bit)"
+	mkdir -p build && cd build
+	cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_DEMO_NODESET=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_BUILD_EXAMPLESERVER=ON -DUA_ENABLE_COVERAGE=ON ..
+	make -j8 && make test
+	echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
+	(valgrind --error-exitcode=3 ./server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
+	cd .. && rm -rf build
+
+fi