Browse Source

Merge pull request #1142 from open62541/hotifx/ci_build_errors

Fix occasional build errors on travis/appveyor
Stefan Profanter 7 years ago
parent
commit
f58ea7a735
6 changed files with 135 additions and 115 deletions
  1. 26 28
      .travis.yml
  2. 55 23
      CMakeLists.txt
  3. 6 6
      appveyor.yml
  4. 1 1
      examples/CMakeLists.txt
  5. 7 12
      tools/travis/travis_osx_before_install.sh
  6. 40 45
      tools/travis/travis_osx_script.sh

+ 26 - 28
.travis.yml

@@ -1,15 +1,6 @@
 language: c
 
-compiler:
-- gcc
-- clang
-
-os:
-- linux
-- osx
-
 # use new build environment (docker)
-dist: trusty
 sudo: required
 
 env:
@@ -18,34 +9,40 @@ env:
     - secure: nSunY54Wp5HkQCHHbKwlwpbaKyqRVIu/0EnhaoJSwhM1wqerQV/E5d/2JelO9/tZgbungAO7wk/fjutRMVc7d378RTIPwS8vHpvZfEoGhCFsLoTOlqESzsZFBup2H5t1lpQ23jRHDOxlLdJy2lz5U+zd1YnYgDXqdDFjegsIYdo=
     # COVERITY_SCAN_TOKEN:
     - secure: C7LLWmOCdRYJGiXjFYDHWwBB6XGjs9Hio4kkvDehLRredRgp1UJ73g6Av9L7xrTUide6GiPrSd+RJw7py/twx5qaeIjOWPy+XvtmabDEQBquLjEkvS+LP2EycaMe92kHMo1ItFfRomgj1FyNYPVnUFgdyedGWv+p553ziDbrMas=
-  matrix:
-    # Do both, compile with static code analysis and without
-    - ANALYZE=false
-    - ANALYZE=true
-    - DOCKER=true
-    - FUZZER=true
+
+
+dist: trusty
 
 matrix:
-  exclude:
-  # This excludes OSX GCC builds.
-    - os: osx
+  fast_finish: true
+  include:
+    - os: linux
+      compiler: gcc
+      env: ANALYZE=false
+    - os: linux
       compiler: gcc
-    - os: osx
       env: ANALYZE=true
-    - os: osx
+    - os: linux
+      compiler: gcc
       env: DOCKER=true
-    - os: osx
-      env: FUZZER=true
+      services:
+        - docker
     - os: linux
       compiler: clang
-      env: DOCKER=true
+      env: ANALYZE=false
     - os: linux
-      compiler: gcc
+      compiler: clang
+      env: ANALYZE=true
+    - os: linux
+      compiler: clang
       env: FUZZER=true
-
-# Required for docker build test
-services:
-  - docker
+    - os: osx
+      compiler: clang
+      # disable homebrew auto update which takes a lot of time
+      env: HOMEBREW_NO_AUTO_UPDATE=1
+      cache:
+        directories:
+          - $HOME/Library/Caches/Homebrew
 
 addons:
   apt:
@@ -86,6 +83,7 @@ cache:
   apt: true
   directories:
     - $HOME/install
+    - $HOME/.cache/pip
 
 # combine all the commands into one single command. See https://github.com/travis-ci/travis-ci/issues/1066
 before_install: |

+ 55 - 23
CMakeLists.txt

@@ -296,6 +296,7 @@ set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c
                 ${PROJECT_SOURCE_DIR}/src/ua_types_encoding_binary.c
                 ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
                 ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_descriptions.c
                 ${PROJECT_SOURCE_DIR}/src/ua_util.c
                 ${PROJECT_SOURCE_DIR}/src/ua_connection.c
                 ${PROJECT_SOURCE_DIR}/src/ua_securechannel.c
@@ -388,6 +389,12 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated
                            ${PROJECT_SOURCE_DIR}/tools/schema/datatypes_minimal.txt
                            ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/Opc.Ua.Types.bsd
                            ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/NodeIds.csv)
+# we need a custom target to avoid that the generator is called concurrently and thus overwriting files while the other thread is compiling
+add_custom_target(open62541-generator-types DEPENDS
+        ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
+        ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h
+        ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_handling.h
+        ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated_encoding_binary.h)
 
 # transport data types
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
@@ -403,6 +410,12 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_transport_gener
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_datatypes.py
                            ${PROJECT_SOURCE_DIR}/tools/schema/datatypes_transport.txt
                            ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/Custom.Opc.Ua.Transport.bsd)
+# we need a custom target to avoid that the generator is called concurrently and thus overwriting files while the other thread is compiling
+add_custom_target(open62541-generator-transport DEPENDS
+        ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
+        ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.h
+        ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_handling.h
+        ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated_encoding_binary.h)
 
 # statuscode explanation
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_descriptions.c
@@ -411,24 +424,9 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_desc
         ${PROJECT_SOURCE_DIR}/tools/schema/Opc.Ua.StatusCodes.csv ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_descriptions
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_statuscode_descriptions.py
         ${CMAKE_CURRENT_SOURCE_DIR}/tools/schema/Opc.Ua.StatusCodes.csv)
-list(APPEND lib_sources ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_descriptions.c)
-
-# generated namespace 0
-add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.c
-                          ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.h
-                   PRE_BUILD
-                   COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
-                           -i ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_AssumeExternal.txt
-                           -s description -b ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_Blacklist.txt
-                           ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
-                           ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated
-                   DEPENDS ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/open62541_MacroHelper.py
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_builtin_types.py
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_constants.py
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_namespace.py
-                           ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_node_types.py)
+# we need a custom target to avoid that the generator is called concurrently and thus overwriting files while the other thread is compiling
+add_custom_target(open62541-generator-statuscode DEPENDS
+        ${PROJECT_BINARY_DIR}/src_generated/ua_statuscode_descriptions.c)
 
 # single-file release
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
@@ -445,8 +443,32 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
                            ${internal_headers} ${lib_sources} ${default_plugin_sources}
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers} ${lib_sources})
 
-ADD_CUSTOM_TARGET(open62541_amalgamation DEPENDS ${PROJECT_BINARY_DIR}/open62541.h
-                                                 ${PROJECT_BINARY_DIR}/open62541.c)
+add_custom_target(open62541_amalgamation_source DEPENDS ${PROJECT_BINARY_DIR}/open62541.c)
+add_custom_target(open62541_amalgamation_header DEPENDS ${PROJECT_BINARY_DIR}/open62541.h)
+
+add_dependencies(open62541_amalgamation_source open62541-generator-types open62541-generator-transport open62541-generator-statuscode)
+add_dependencies(open62541_amalgamation_header open62541-generator-types)
+
+# generated namespace 0
+add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.c
+        ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.h
+        PRE_BUILD
+        COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
+        -i ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_AssumeExternal.txt
+        -s description -b ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/NodeID_Blacklist.txt
+        ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
+        ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated
+        DEPENDS ${PROJECT_SOURCE_DIR}/tools/schema/namespace0/${GENERATE_NAMESPACE0_FILE}
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/generate_open62541CCode.py
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/open62541_MacroHelper.py
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_builtin_types.py
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_constants.py
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_namespace.py
+        ${PROJECT_SOURCE_DIR}/tools/pyUANamespace/ua_node_types.py)
+# we need a custom target to avoid that the generator is called concurrently and thus overwriting files while the other thread is compiling
+add_custom_target(open62541-generator-namespace DEPENDS
+        ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.c
+        ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_generated.h)
 
 #####################
 # Build the Library #
@@ -460,9 +482,10 @@ if(UA_ENABLE_AMALGAMATION)
     add_library(open62541-object OBJECT ${PROJECT_BINARY_DIR}/open62541.c ${PROJECT_BINARY_DIR}/open62541.h)
     target_include_directories(open62541-object PRIVATE ${PROJECT_BINARY_DIR})
 
-    # make sure the open62541_amalgamation target builds before so that amalgamation is finished and it is not executed again for open62541-object 
+    # make sure the open62541_amalgamation target builds before so that amalgamation is finished and it is not executed again for open62541-object
     # and thus may overwrite the amalgamation result during multiprocessor compilation
-    add_dependencies(open62541-object open62541_amalgamation)
+    # the header is already a dependency of open62541 target itself
+    add_dependencies(open62541-object open62541_amalgamation_source)
 
     add_library(open62541 $<TARGET_OBJECTS:open62541-object>)
 
@@ -472,9 +495,11 @@ if(UA_ENABLE_AMALGAMATION)
 else()
     add_definitions(-DUA_NO_AMALGAMATION)
     add_library(open62541-object OBJECT ${lib_sources} ${internal_headers} ${exported_headers})
+    add_dependencies(open62541-object open62541-generator-types open62541-generator-transport open62541-generator-statuscode)
     target_include_directories(open62541-object PRIVATE ${PROJECT_SOURCE_DIR}/src)
 
     add_library(open62541-plugins OBJECT ${default_plugin_sources} ${exported_headers})
+    add_dependencies(open62541-plugins open62541-generator-types)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_SOURCE_DIR}/plugins)
     target_include_directories(open62541-plugins PRIVATE ${PROJECT_BINARY_DIR}/src_generated)
     target_compile_definitions(open62541-plugins PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
@@ -487,6 +512,13 @@ else()
     endif()
 endif()
 
+if(UA_ENABLE_GENERATE_NAMESPACE0)
+    add_dependencies(open62541_amalgamation_source open62541-generator-namespace)
+    if(NOT UA_ENABLE_AMALGAMATION)
+        add_dependencies(open62541-object open62541-generator-namespace)
+    endif()
+endif()
+
 # Export Symbols
 target_compile_definitions(open62541-object PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
 target_compile_definitions(open62541 PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
@@ -499,7 +531,7 @@ endif()
 target_link_libraries(open62541 ${open62541_LIBRARIES})
 
 # Always generate the amalgamated header
-add_dependencies(open62541 open62541_amalgamation)
+add_dependencies(open62541 open62541_amalgamation_header)
 
 # Generate properly versioned shared library links on Linux
 SET_TARGET_PROPERTIES(open62541 PROPERTIES SOVERSION 0 VERSION "${OPEN62541_VER_MAJOR}.${OPEN62541_VER_MINOR}.${OPEN62541_VER_PATCH}")

+ 6 - 6
appveyor.yml

@@ -22,22 +22,22 @@ environment:
           OUT_DIR_EXAMPLES: bin\examples
         - CC_NAME: Visual Studio 9 2008
           CC_SHORTNAME: vs2008
-          # Do not use multicore switch (/m), it causes appveyor to randomly fail
-          MAKE: msbuild open62541.sln
+          # Do not build in parallel, project dependencies are not solved correctly and thus appveyor may randomly fail
+          MAKE: msbuild /m:1 /p:BuildInParallel=false open62541.sln
           FORCE_CXX: ON
           OUT_DIR_LIB: bin\Debug
           OUT_DIR_EXAMPLES: bin\examples\Debug
         - CC_NAME: Visual Studio 12 2013
           CC_SHORTNAME: vs2013
-          # Do not use multicore switch (/m), it causes appveyor to randomly fail
-          MAKE: msbuild open62541.sln
+          # Do not build in parallel, project dependencies are not solved correctly and thus appveyor may randomly fail
+          MAKE: msbuild /m:1 /p:BuildInParallel=false open62541.sln
           FORCE_CXX: OFF
           OUT_DIR_LIB: bin\Debug
           OUT_DIR_EXAMPLES: bin\examples\Debug
         - CC_NAME: Visual Studio 12 2013 Win64
           CC_SHORTNAME: vs2013-x64
-          # Do not use multicore switch (/m), it causes appveyor to randomly fail
-          MAKE: msbuild open62541.sln
+          # Do not build in parallel, project dependencies are not solved correctly and thus appveyor may randomly fail
+          MAKE: msbuild /m:1 /p:BuildInParallel=false open62541.sln
           FORCE_CXX: OFF
           OUT_DIR_LIB: bin\Debug
           OUT_DIR_EXAMPLES: bin\examples\Debug

+ 1 - 1
examples/CMakeLists.txt

@@ -12,7 +12,7 @@ macro(add_example EXAMPLE_NAME EXAMPLE_SOURCE)
   add_executable(${EXAMPLE_NAME} ${STATIC_OBJECTS} ${EXAMPLE_SOURCE} ${ARGN})
   target_link_libraries(${EXAMPLE_NAME} open62541 ${open62541_LIBRARIES})
   assign_source_group(${EXAMPLE_SOURCE})
-  add_dependencies(${EXAMPLE_NAME} open62541_amalgamation)
+  add_dependencies(${EXAMPLE_NAME} open62541_amalgamation_header open62541_amalgamation_source)
   set_target_properties(${EXAMPLE_NAME} PROPERTIES FOLDER "open62541/examples")
   if(UA_COMPILE_AS_CXX)
     set_source_files_properties(${EXAMPLE_SOURCE} PROPERTIES LANGUAGE CXX)

+ 7 - 12
tools/travis/travis_osx_before_install.sh

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

+ 40 - 45
tools/travis/travis_osx_script.sh

@@ -1,54 +1,49 @@
 #!/bin/bash
 set -ev
 
-if [ $ANALYZE = "true" ]; then
-    echo "\n=== Skipping static analysis on OS X ==="
-    exit 0
-else
-    echo "\n=== Building ==="
-    export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"
-    export PATH="/Users/travis/Library/Python/2.7/bin:$PATH"
+echo "\n=== Building ==="
+export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"
+export PATH="/Users/travis/Library/Python/2.7/bin:$PATH"
 
 
-    echo "Documentation and certificate build"  && echo -en 'travis_fold:start:script.build.doc\\r'
-    mkdir -p build && cd build
-    cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
-    make selfsigned
-    ls examples
-    cp examples/server_cert.der ../
-    cd .. && rm -rf build
-    echo -en 'travis_fold:end:script.build.doc\\r'
+echo "Documentation and certificate build"  && echo -en 'travis_fold:start:script.build.doc\\r'
+mkdir -p build && cd build
+cmake -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_SELFSIGNED_CERTIFICATE=ON ..
+make selfsigned
+ls examples
+cp examples/server_cert.der ../
+cd .. && rm -rf build
+echo -en 'travis_fold:end:script.build.doc\\r'
 
-    echo "Full Namespace 0 Generation"  && echo -en 'travis_fold:start:script.build.ns0\\r'
-    mkdir -p build
-    cd build
-    cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON  ..
-    make -j
-    cd .. && rm -rf build
-    echo -en 'travis_fold:end:script.build.ns0\\r'
+echo "Full Namespace 0 Generation"  && echo -en 'travis_fold:start:script.build.ns0\\r'
+mkdir -p build
+cd build
+cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON  ..
+make -j
+cd .. && rm -rf build
+echo -en 'travis_fold:end:script.build.ns0\\r'
 
-    echo "Compile release build for OS X" && echo -en 'travis_fold:start:script.build.osx\\r'
-    mkdir -p build && cd build
-	cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
-    make -j
-    tar -pczf open62541-osx.tar.gz ../LICENSE ../AUTHORS ../README.md ./bin/examples/server ./bin/examples/client ./bin/libopen62541.a 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 -en 'travis_fold:end:script.build.osx\\r'
+echo "Compile release build for OS X" && echo -en 'travis_fold:start:script.build.osx\\r'
+mkdir -p build && cd build
+cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
+make -j
+tar -pczf open62541-osx.tar.gz ../LICENSE ../AUTHORS ../README.md ./bin/examples/server ./bin/examples/client ./bin/libopen62541.a 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 -en 'travis_fold:end:script.build.osx\\r'
 
-    echo "Compile multithreaded version" && echo -en 'travis_fold:start:script.build.multithread\\r'
-    mkdir -p build && cd build
-    cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLES=ON ..
-    make -j
-    cd .. && rm -rf build
-	echo -en 'travis_fold:end:script.build.multithread\\r'
+echo "Compile multithreaded version" && echo -en 'travis_fold:start:script.build.multithread\\r'
+mkdir -p build && cd build
+cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLES=ON ..
+make -j
+cd .. && rm -rf build
+echo -en 'travis_fold:end:script.build.multithread\\r'
 
-    echo "Debug build and unit tests with valgrind" && echo -en 'travis_fold:start:script.build.unit_test\\r'
-    mkdir -p build && cd build
-    cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
-    make -j && make test ARGS="-V"
-    cd .. && rm -rf build
-	echo -en 'travis_fold:end:script.build.unit_test\\r'
-fi
+echo "Debug build and unit tests with valgrind" && echo -en 'travis_fold:start:script.build.unit_test\\r'
+mkdir -p build && cd build
+cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
+make -j && make test ARGS="-V"
+cd .. && rm -rf build
+echo -en 'travis_fold:end:script.build.unit_test\\r'