diff --git a/.github/workflows/opendatacon.yml b/.github/workflows/opendatacon.yml index c58c7f6a..55a27b5f 100644 --- a/.github/workflows/opendatacon.yml +++ b/.github/workflows/opendatacon.yml @@ -55,6 +55,18 @@ jobs: build-type: Debug docker-args: + - name: Redhat Enterprise Linux 9 Release + run-os: ubuntu-latest + docker-file: RHEL9 + build-type: Release + docker-args: + + - name: Redhat Enterprise Linux 9 Debug + run-os: ubuntu-latest + docker-file: RHEL9 + build-type: Debug + docker-args: + runs-on: ${{ matrix.run-os }} steps: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b4a66d82..00000000 --- a/.travis.yml +++ /dev/null @@ -1,193 +0,0 @@ -#TODO: add socat dep for when dnp3 tests work - -language: cpp - -git: - depth: false #shallow clone causes problem with tags - -addons: - apt: - update: true - -os: linux - #- osx - -compiler: gcc - #- clang - -env: BUILD_CONFIG=Release DOCKER_BUILD=OEL - -services: docker - -branches: - only: - #- develop - #- master - #- /^release\/.*$/ - - /^[0-9]+\.[0-9]+\.[0-9]+.*$/ - #- /^feature\/.*$/ - -dist: bionic - -install: - - export SRC_DIR=$(pwd) - - mkdir -p build/install && cd build - - export INSTALL_PREFIX=$(pwd)/install - - | - if [ -z "$LOG_LVL" ]; then - export LOG_LVL="error" - fi - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - HOMEBREW_NO_AUTO_UPDATE=1 brew install libmodbus libmicrohttpd socat openssl - export TOOLCHAIN_OPT="-DPACKAGE_DNP3=OFF -DPACKAGE_LIBMICROHTTPD=OFF -DPACKAGE_LIBMODBUS=OFF -DPACKAGE_PYTHON=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" - elif [ -z "$DOCKER_BUILD" ]; then - # Not a docker build, just normal linux - sudo apt-get install -y libmodbus-dev libmicrohttpd-dev socat libc++-dev libc++abi-dev python3.6 python3.6-dev openssl libssl-dev - export SYSVER_OPT="-DCMAKE_SYSTEM_VERSION=generic" - fi - - | - if [ "$DOCKER_BUILD" == "Rpi" ]; then - # Install qemu-static and the arm cross compiler into the travis host - # - sudo apt-get install -y qemu-user qemu-user-static g++-arm-linux-gnueabihf - # - # Run the docker image and keep the returned container name for use in exec calls. - # Run detatched, the volume command is -v hostdir:containerdir, -rm indicates cleanup on exit unnamed vols, - # -ti maintain a terminal, the docker image is jessie:latest - DOCK=$(docker run -d -v $SRC_DIR:/mnt -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static --rm -ti 2000cubits/raspbian:buster bash) - # Install the arm versions of dependencies into the QEMU user image - docker exec -i $DOCK sh -c "apt-get update && apt-get install -y libmodbus-dev libmicrohttpd-dev socat psmisc libc6-dev openssl libssl-dev" - docker exec -i $DOCK sh -c "apt-get install -y python3.7 python3.7-dev" - mkdir sysroot - # Copy headers and libs to sysroot from within the docker image - docker exec -i $DOCK sh -c ' - mkdir -p /mnt/build/sysroot$(dirname /usr/include/*/*/pyconfig.h) - rm /usr/lib/python3.7/sitecustomize.py - cp /etc/python3.7/sitecustomize.py /usr/lib/python3.7/sitecustomize.py - cp -a /usr/include/*/*/pyconfig.h /mnt/build/sysroot$(dirname /usr/include/*/*/pyconfig.h) - cp -a /usr/include/microhttpd.h /mnt/build/sysroot/usr/include/ - cp -a /usr/include/modbus /mnt/build/sysroot/usr/include/ - cp -a /usr/include/python* /mnt/build/sysroot/usr/include/ - cp -a /usr/include/openssl /mnt/build/sysroot/usr/include/ - cp -a /usr/include/*/*/opensslconf.h /mnt/build/sysroot/usr/include/openssl/ - cp -a /usr/lib /mnt/build/sysroot/usr/ - cp -a /lib* /mnt/build/sysroot/ - ' - # make symlink so absolute paths work within docker - docker exec -i $DOCK mkdir -p $(dirname $SRC_DIR) - docker exec -i $DOCK ln -s /mnt $SRC_DIR - # replace ldd with docker wrapper (so BundleUtilities might work) - sudo ln -sf $SRC_DIR/Code/scripts/lddrunwrapper.pl $(which ldd) - # Export a bunch of defines to travis to use in the build and run phases of the script section - export SYSROOT=$(pwd)/sysroot/ - export RUN="docker exec --interactive --workdir /mnt/build $DOCK" - export STOP="docker stop $DOCK" - export TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=../Code/cmake/rpi-toolchain.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=$SRC_DIR/Code/scripts/runwrapper" - fi - - | - if [ "$DOCKER_BUILD" == "OEL" ]; then - DOCK=$(docker run -d -v $SRC_DIR:/mnt/src --rm -ti library/oraclelinux:7.6) - - # load dependencies into docker image - docker exec -i $DOCK sh -c ' - yum install -y oracle-softwarecollection-release-el7 - /usr/bin/ol_yum_configure.sh - yum repolist - yum install -y applydeltarpm - yum install -y scl-utils glibc-devel iso-codes redhat-rpm-config libmicrohttpd make devtoolset-8-gcc-c++ cmake3 git file openssl11 openssl11-devel openssl11-static - ln -s /usr/bin/cmake3 /bin/cmake - mkdir -p /opt/openssl-root - ln -s /usr/include/openssl11 /opt/openssl-root/include - ln -s /usr/lib64/openssl11 /opt/openssl-root/lib - - #Extras that aren-t yum-able - curl -O https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libmodbus-devel-3.0.8-1.el7.x86_64.rpm - curl -O https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libmodbus-3.0.8-1.el7.x86_64.rpm - rpm -i libmodbus-3.0.8-1.el7.x86_64.rpm - rpm -i libmodbus-devel-3.0.8-1.el7.x86_64.rpm - # To get Python3.6 we need scl-util-build tools - curl -O http://public-yum.oracle.com/repo/OracleLinux/OL7/optional/developer/x86_64/getPackage/scl-utils-build-20130529-19.el7.x86_64.rpm - rpm -i scl-utils-build-20130529-19.el7.x86_64.rpm - curl -O https://public-yum.oracle.com/repo/OracleLinux/OL7/optional/latest/x86_64/getPackage/libmicrohttpd-devel-0.9.33-2.el7.x86_64.rpm - rpm -i libmicrohttpd-devel-0.9.33-2.el7.x86_64.rpm - - yum install -y rh-python36 rh-python36-python-devel - ' - #Set up mirror paths inside the docker - so it-s the same command to run tests as other configs - docker exec -i $DOCK mkdir -p $(dirname $SRC_DIR) - docker exec -i $DOCK ln -s /mnt/src $SRC_DIR - - export TOOLCHAIN_OPT="-DPYTHON_HOME=/opt/rh/rh-python36/root/usr -DOPENSSL_ROOT_DIR=/opt/openssl-root -DADD_LIBS=z" - export SYSVER_OPT="-DCMAKE_SYSTEM_VERSION=oel7" - export PRESOURCE="source scl_source enable rh-python36 && source scl_source enable devtoolset-8 &&" - export RUN="docker exec --interactive --workdir /mnt/src/build $DOCK" - export BUILDRUN="$RUN" - export STOP="docker stop $DOCK" - fi - - | - if [ "$DOCKER_BUILD" == "i386" ]; then - sudo apt-get update - sudo apt-get install -y g++-7-i686-linux-gnu - DOCK=$(docker run -d -v $SRC_DIR:/mnt --rm -ti i386/ubuntu:bionic) - docker exec -i $DOCK sh -c "apt-get update && apt-get install -y libmodbus-dev libmicrohttpd-dev socat psmisc libc6-dev openssl libssl-dev" - docker exec -i $DOCK sh -c "apt-get install -y python3.6 python3.6-dev" - mkdir sysroot - # Copy headers and libs to sysroot from within the docker image - docker exec -i $DOCK sh -c ' - mkdir -p /mnt/build/sysroot$(dirname /usr/include/*/*/pyconfig.h) - rm /usr/lib/python3.5/sitecustomize.py - cp /etc/python3.5/sitecustomize.py /usr/lib/python3.5/sitecustomize.py - cp -a /usr/include/*/*/pyconfig.h /mnt/build/sysroot$(dirname /usr/include/*/*/pyconfig.h) - cp -a /usr/include/microhttpd.h /mnt/build/sysroot/usr/include/ - cp -a /usr/include/modbus /mnt/build/sysroot/usr/include/ - cp -a /usr/include/python* /mnt/build/sysroot/usr/include/ - cp -a /usr/include/openssl /mnt/build/sysroot/usr/include/ - cp -a /usr/include/*/*/opensslconf.h /mnt/build/sysroot/usr/include/openssl/ - cp -a /usr/lib /mnt/build/sysroot/usr/ - cp -a /lib* /mnt/build/sysroot/ - ' - sudo chown -R $USER.$USER sysroot - # make symlink so absolute paths work within docker - docker exec -i $DOCK mkdir -p $(dirname $SRC_DIR) - docker exec -i $DOCK ln -s /mnt $SRC_DIR - # replace ldd with docker wrapper (so BundleUtilities might work) - sudo ln -sf $SRC_DIR/Code/scripts/lddrunwrapper.pl $(which ldd) - # Export a bunch of defines to travis to use in the build and run phases of the script section - export SYSROOT=$(pwd)/sysroot/ - export RUN="docker exec --interactive --workdir /mnt/build $DOCK" - export STOP="docker stop $DOCK" - export TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=../Code/cmake/i386-toolchain.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=$SRC_DIR/Code/scripts/runwrapper" - fi - -script: - - $BUILDRUN sh -c "$PRESOURCE cmake -DFULL=ON -DCMAKE_BUILD_TYPE=$BUILD_CONFIG -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX $TOOLCHAIN_OPT $SYSVER_OPT .." - - $BUILDRUN sh -c "$PRESOURCE make -j8" - - $BUILDRUN sh -c "$PRESOURCE make package" - - $BUILDRUN sh -c "$PRESOURCE make install" - #tagged builds are redundant for running tests - they run on branch builds anyway - #so skip running them on tags to speed up deploy - #also skip Rpi Debug build tests - there's a fault that can't be debugged in docker - - function if_notag { if [ -z "$TRAVIS_TAG" ] && [ -z "$RPI_DEBUG" ]; then $1; fi } - - if_notag "$RUN install/bin/ODC_tests $LOG_LVL -d yes" - - if_notag "$RUN install/bin/DNP3Port_tests $LOG_LVL -d yes" - - if_notag "$RUN install/bin/SimPort_tests -d yes" - - if_notag "$RUN install/bin/MD3Port_tests $LOG_LVL -d yes" - - if_notag "$RUN install/bin/CBPort_tests $LOG_LVL -d yes" - - if_notag "$RUN install/bin/PyPort_tests $LOG_LVL -d yes" - - if_notag "$RUN install/bin/Integration_tests $LOG_LVL -d yes" - - $STOP - -#deploy: -# # Only do a git deploy on a tagged release. -# provider: releases -# api_key: -# secure: "a1Vm3l2QwXhwDoFpQn1Rw6BEL+gHHDlSAL5C43IWjr52qPRBL/qiQi9DBSrb4421M01QQtfxHOAxVs7bcM3oZ6oTeqy4vVHA3oqMhDtlVrt0Om4tlyLdY8kuSM/Hxm5G6WPYcgIj2ABMoX0PxpEftgrEtqa8E/cu8WkSP1Hmuv5RC5fJ+TmLHTTW7KxRSKZ9clmjWzRgLyrLYB+eS3HFfo64XW98XHkop9U+rb7+NQ9E4oZ9gVXmPYwEG805lNePAhyJ+EZ6NAMwY0HFeNj5JRt73EFtokYaLTW+drf7zUnptT9grquCpu16EbmEnUrgdJfUKjZHUAuBu6vYGLmM1SJ9PcS9+PGnGqhKyIZhSRFZCeCH5//gc3sh+Yp7NxT+6IrqsOKVitNoeiXykpk4MwCefuxvB5kDboxic8vxniSp+awnlzmwyKHP/aDCUANHpkQ+uNHnpA7Ev+zFeZnsDoDmcrzT39pWZav23ofP4c7H7MsgjQV/SWutHp91Bqs8AR2sBRpXl6FbLKIMrgXUQWd52lsSGWUUW042KddzGlfiWPV24P642AI40LbkPD1yD4FStH/KniA+9q0xvKeDqGqSB/8IrH0ZUxB/pCrHbsLl0R77Wi2PmYYIT+LGL58UxaJzMr+CyMTW05HH6/ruM4pUXzSMes7GC7cdJs2D/g8=" -# file_glob: true -# file: opendatacon-*.*.*-*-*-*-*-*.sh -# name: "opendatacon ${TRAVIS_TAG}" -# skip_cleanup: true -# on: -# tags: true -# compiler: gcc - diff --git a/Code/Libs/ODC/CMakeLists.txt b/Code/Libs/ODC/CMakeLists.txt index 1cd942d7..2cbc7d08 100644 --- a/Code/Libs/ODC/CMakeLists.txt +++ b/Code/Libs/ODC/CMakeLists.txt @@ -35,9 +35,19 @@ endif() if(ODC_ASIO_SSL) message("OpenSSL root dir: ${OPENSSL_ROOT_DIR}") + + # First try with static libs set(OPENSSL_USE_STATIC_LIBS TRUE) set(OPENSSL_MSVC_STATIC_RT TRUE) - find_package(OpenSSL 1.1.1 REQUIRED) + find_package(OpenSSL 1.1.1 QUIET) + + if(NOT OpenSSL_FOUND) + message(STATUS "Static OpenSSL libraries not found, falling back to dynamic...") + set(OPENSSL_USE_STATIC_LIBS FALSE) + set(OPENSSL_MSVC_STATIC_RT FALSE) + find_package(OpenSSL 1.1.1 REQUIRED) + endif() + add_definitions(-DODC_ASIO_SSL) message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") diff --git a/Code/Ports/DNP3Port/CMakeLists.txt b/Code/Ports/DNP3Port/CMakeLists.txt index 72bfd36c..24502076 100644 --- a/Code/Ports/DNP3Port/CMakeLists.txt +++ b/Code/Ports/DNP3Port/CMakeLists.txt @@ -45,7 +45,7 @@ if(USE_DNP3_SUBMODULE) DNP3_CMAKE_OPTS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DDNP3_STATIC_LIBS=ON - -DOPENSSL_USE_STATIC_LIBS=TRUE + -DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS} "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -fPIC" -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX=${DNP3_HOME}/ diff --git a/DockerFiles/RHEL9 b/DockerFiles/RHEL9 new file mode 100644 index 00000000..8c431be8 --- /dev/null +++ b/DockerFiles/RHEL9 @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.2 + +FROM redhat/ubi9 as builder + +RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm +RUN yum install -y socat g++ libstdc++-static cmake git openssl-devel python3-devel file libmodbus libmodbus-devel + +RUN git clone --recurse-submodules https://github.com/neilstephens/opendatacon.git +ARG BUILD_COMMIT=develop +RUN git -C opendatacon checkout $BUILD_COMMIT + +ARG BUILD_TYPE=Release +RUN mkdir opendatacon-build + +RUN cmake -DFULL=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_SYSTEM_VERSION=rhel9 \ +-DOPENSSL_ROOT_DIR=/usr/ -S opendatacon -B opendatacon-build + +RUN cmake --build opendatacon-build --parallel 8 +RUN cmake --build opendatacon-build --target install +RUN cmake --build opendatacon-build --target package + +FROM scratch AS export-stage +COPY --from=builder opendatacon-build/opendatacon*.sh / diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3df149ea..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,140 +0,0 @@ -version: AppVeyorBuild-{build} -branches: - only: - - develop - - master - - /^release\/.*$/ - - /^[0-9]+\.[0-9]+\.[0-9]+.*$/ - - /^feature\/.*$/ - -os: Visual Studio 2019 - - -#---------------------------------# -# build configuration # -#---------------------------------# -configuration: - - Release - - Debug - -environment: - matrix: - - platform: Win32 - cpu_bits: 32 - python_inst: C:\Python37 - cmake_builddir: build-win32 - - platform: x64 - cpu_bits: 64 - python_inst: C:\Python37-x64 - cmake_builddir: build-win64 - -clone_folder: C:\projects\opendatacon - -init: - -install: -- ps: >- - If (-not (Test-Path C:\libmodbus\libmodbus)){ - Start-FileDownload "https://www.dropbox.com/s/iqf95y9x1x4ol36/libmodbus.zip?dl=1" -FileName libmodbus.zip - 7z x -y libmodbus.zip - New-Item C:\libmodbus -ItemType Directory - Move-Item .\libmodbus C:\libmodbus\libmodbus - } - If (-not (Test-Path C:\libmicrohttpd\libmicrohttpd-0.9.17-w32)){ - Start-FileDownload "https://www.dropbox.com/s/13t92f57wie4wnb/libmicrohttpd-0.9.17-w32.zip?dl=1" -FileName libmicrohttpd-0.9.17-w32.zip - 7z x -y libmicrohttpd-0.9.17-w32.zip - New-Item C:\libmicrohttpd -ItemType Directory - Move-Item .\libmicrohttpd-0.9.17-w32 C:\libmicrohttpd\libmicrohttpd-0.9.17-w32 - } - If (-not (Test-Path C:\libmicrohttpd\libmicrohttpd-0.9.17-w64)){ - Start-FileDownload "https://drive.google.com/uc?export=download&id=1Xfl5iwGOjm2Ggb_nwWJcNzjM05Bl9irT" -FileName libmicrohttpd-0.9.37-w64.zip - 7z x -y libmicrohttpd-0.9.37-w64.zip - Move-Item .\libmicrohttpd-0.9.37-w64 C:\libmicrohttpd\libmicrohttpd-0.9.17-w64 - } -cache: -- C:\libmodbus\ -- C:\libmicrohttpd\ - -before_build: -- cmd: cd C:\projects\opendatacon -- ps: >- - If ($env:Platform -Match "64") { - $env:GEN_PLAT="-Ax64" - } Else { - $env:GEN_PLAT="-AWin32" - Remove-Item 'C:/OpenSSL-Win64' -Recurse - } - If (-not (Test-Path env:LOG_LVL)) { - $env:LOG_LVL="error" - } -- cmd: 'cmake . -B%cmake_builddir% -G"Visual Studio 16 2019" %GEN_PLAT% -DFULL=ON -DCMAKE_CONFIGURATION_TYPES=%configuration% -DCMAKE_INSTALL_PREFIX=%cmake_builddir%\install -DMODBUS_HOME=c:\libmodbus\libmodbus\windows%cpu_bits% -DMICROHTTPD_HOME=C:\libmicrohttpd\libmicrohttpd-0.9.17-w%cpu_bits% -DPYTHON_HOME=%python_inst% -DOPENSSL_ROOT_DIR=C:\OpenSSL-v111-Win%cpu_bits%' -#build: -# parallel: true # enable MSBuild parallel builds -# project: build-win32\opendatacon_suite.sln # path to Visual Studio solution or project -build_script: -- cmd: cmake --build %cmake_builddir% --config %configuration% -- cmd: cmake --build %cmake_builddir% --config %configuration% --target INSTALL -- cmd: cmake --build %cmake_builddir% --config %configuration% --target PACKAGE - -test_script: -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\ODC_tests.exe %LOG_LVL% -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\DNP3Port_tests.exe %LOG_LVL% -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\SimPort_tests.exe -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\MD3Port_tests.exe %LOG_LVL% -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\CBPort_tests.exe %LOG_LVL% -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\PyPort_tests.exe %LOG_LVL% -d yes)' -- cmd: 'IF "%APPVEYOR_REPO_TAG_NAME%"=="" (%cmake_builddir%\install\Integration_tests.exe %LOG_LVL% -d yes)' - -# Capture the log file outputs so we can debug failed tests. -on_finish: -- echo Scanning project folder for all files - C:\projects\opendatacon -- cmd: ls -oR --group-directories-first C:\projects\opendatacon > dirlist.txt -- ps: Push-AppveyorArtifact dirlist.txt -FileName ProjectDirectoryListing.txt -- ps: Get-ChildItem C:\projects\opendatacon\*.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } -#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - -artifacts: - - path: $(cmake_builddir)\opendatacon-*.*.*-*-*-*-*-*.exe - name: Releases - - -#deploy: -# release: 'opendatacon $(APPVEYOR_REPO_TAG_NAME)' -# description: '' -# provider: GitHub -# auth_token: -# secure: MuDZnJV9gGH51bmihPpcFDEyAVC3bU9BPaciSz48OI3sZfe1j4Y7BaMLV4qJqwIC -# draft: false -# prerelease: false -# tag: $(APPVEYOR_REPO_TAG_NAME) -# on: -# appveyor_repo_tag: true - -### -##Here is a script your can run in your browser's javascript terminal to build any branch/commit -##, so you don't need to bother with auth (run on project's page) -### - -#var [, , accountName, projectSlug] = document.location.pathname.split('/'); -#fetch(`https://ci.appveyor.com/api/account/${accountName}/builds`, -#{ -# method: "POST", -# headers: { -# 'Content-Type': 'application/json', -# }, -# body: JSON.stringify({ -# accountName, -# projectSlug, -# // from commit -# commitId: 'aa03f23db5840f9251006b9df9f46a19cf07bfff', // CHANGE ME - delete to build latest -# branch: 'master', // CHANGE ME -# // // or from PR -# // pullRequestId: 3, -# // // env vars -# // "environmentVariables": { -# // "my_var": "value", -# // "another_var": "another value" -# // } -# }), -#}); -