Skip to content

Commit

Permalink
Merge pull request #65 from INTO-CPS-Association/kel/openssl-win
Browse files Browse the repository at this point in the history
Updated openssl
  • Loading branch information
gitting-around authored Oct 31, 2024
2 parents deb14ee + d22df96 commit ed7c37c
Show file tree
Hide file tree
Showing 16 changed files with 550 additions and 285 deletions.
282 changes: 114 additions & 168 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

274 changes: 274 additions & 0 deletions .github/workflows/loadLibraryTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
# This is a basic workflow to help you get started with Actions

name: openssl-tests

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the development branch
push:
branches: [gf/update-rabbitmq-c]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [windows-latest,ubuntu-latest,macos-12]

steps:
- uses: TheMrMilchmann/setup-msvc-dev@v3
if: matrix.os == 'windows-latest'
with:
arch: x64

- uses: actions/checkout@v2
if: matrix.os == 'ubuntu-20.04'
with:
submodules: true
fetch-depth: 0

- uses: actions/checkout@v2
if: matrix.os != 'ubuntu-20.04'
with:
submodules: true

- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.22.0" # <--= optional, use most recent 3.25.x version
ninjaVersion: "^1.11.1" # <--= optional, use most recent 1.x version

- name: Prepare variables for windows
shell: bash
if: matrix.os == 'windows-latest'
run: |
echo "win-x64" > target
echo "win-x86_64" > install_name
echo -G > cmakeFlag
echo Unix Makefiles > cmakeFlagValue
- name: Other win prep
if: matrix.os == 'windows-latest'
run: |
openssl version
openssl version -d
choco uninstall openssl -x
choco install openssl --version 3.3.2
openssl version
openssl version -d
which openssl
cmake --version
- name: Build
#if: matrix.os == 'windows-latest'
shell: bash
run: |
export target=$(cat target)
export install_name=$(cat install_name)
export cmakeFlag=$(cat cmakeFlag)
export cmakeFlagValue=$(cat cmakeFlagValue)
echo $target
echo $install_name
repo=$(git rev-parse --show-toplevel)
current_dir=$(pwd)
cd $repo
working_dir=build/$target
mkdir -p $working_dir
echo Build dependencies
build_xercersc()
{
if [ $target == "linux-x64" ]; then
transcoder_option="-Dtranscoder=gnuiconv"
else
transcoder_option=""
fi
echo cmake $3 "$4" -B$1 -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX=$2 -Dthreads:BOOL=OFF -Dnetwork:BOOL=OFF $transcoder_option -Hthirdparty/xerces-c
cmake $3 "$4" -B$1 -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX=$2 -Dthreads:BOOL=OFF -Dnetwork:BOOL=OFF $transcoder_option -Hthirdparty/xerces-c
make -C$1 -j8
make -C$1 install
}
if [ ! -d build/external/$install_name ]
then
echo build_xercersc $working_dir/xerces-c build/external/$install_name $cmakeFlag "$cmakeFlagValue"
build_xercersc $working_dir/xerces-c build/external/$install_name $cmakeFlag "$cmakeFlagValue"
else
echo "Dependency already generated"
fi
echo Contents of build sub folders
ls build/external/$target
echo --------------------------
ls build/external/$target/lib
echo --------------------------
ls build/external/$target/lib/cmake
echo --------------------------
ls build/external/$target/lib/cmake/XercesC
echo --------------------------
echo Running CMake
rm -f thirdparty/rabbitmq-c/rabbitmq-c/librabbitmq/config.h
cmake $cmakeFlag "$cmakeFlagValue" -B$working_dir -H.
echo Compiling
make -C$working_dir
make -C$working_dir/rabbitmq-fmu install
cd $current_dir
echo Done
echo $(pwd)
ls
- name: List dependencies for windows
if: matrix.os == 'windows-latest'
run: |
echo "$RUNNER_OS"
systeminfo | findstr /B /C:"OS Name" /B /C:"OS Version"
echo Dependencies
dumpbin /dependents build/win-x64/rabbitmq-fmu/rabbitmq.dll
- name: Run unit tests on WIN
if: matrix.os == 'windows-latest'
shell: bash
run: |
export target=$(cat target)
echo $(pwd)
pacman -S --noconfirm mingw-w64-x86_64-gcc-libs
cmake --install build/$target
echo check for dll dependencies for the core test
ldd build/$target/rabbitmq-core/unit-test-rabbitmq-core.exe
echo check for dll dependencies for the container test
ldd build/$target/rabbitmq-fmu/unit-test-rabbitmq.exe
#Call ctest
ctest --test-dir build/$target --output-on-failure -R unit-test-rabbitmq
echo Tests complete
- name: Upload artifact windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: rabbitmq.dll
path: build/win-x64/rabbitmq-fmu/rabbitmq.dll

- name: Upload artifact windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: it-test-rabbitmq.exe
path: build/win-x64/rabbitmq-fmu/it-test-rabbitmq.exe

- name: Upload artifact windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: unit-test-rabbitmq.exe
path: build/win-x64/rabbitmq-fmu/unit-test-rabbitmq.exe

- name: Upload artifact windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: unit-test-rabbitmq-core.exe
path: build/win-x64/rabbitmq-core/unit-test-rabbitmq-core.exe

- name: Upload artifact windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: it-test-rabbitmq-core.exe
path: build/win-x64/rabbitmq-core/it-test-rabbitmq-core.exe

- name: Update version on modelDescription.xml
shell: bash
if: matrix.os == 'ubuntu-20.04'
run: |
cd rabbitmq-fmu/
../scripts/set_fmu_version.sh modelDescription.xml
- name: Upload modelDescription.xml
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v4
with:
name: modelDescription.xml
path: rabbitmq-fmu/modelDescription.xml

- name: Upload rabbitmq configuration script
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v4
with:
name: rabbitmq_fmu_configure.py
path: scripts/rabbitmq_fmu_configure.py

- name: Upload readme
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v4
with:
name: readme.md
path: readme.md

pack-fmu:
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0

- name: Download dll
uses: actions/download-artifact@v4
with:
name: rabbitmq.dll
path: rabbitmq/binaries/win64/

- name: Download model description file
uses: actions/download-artifact@v4
with:
name: modelDescription.xml
path: rabbitmq/

- name: Download model description file to resources folder
uses: actions/download-artifact@v4
with:
name: modelDescription.xml
path: rabbitmq/resources

- name: Download readme
uses: actions/download-artifact@v4
with:
name: readme.md
path: rabbitmq/

- name: Download configuration script
uses: actions/download-artifact@v4
with:
name: rabbitmq_fmu_configure.py
path: rabbitmq/

- name: Get version of the tool
run: |
cd rabbitmq-fmu/
echo "::set-output name=VERSION::$(git describe --tags --long)"
id: version

- name: Upload FMU
uses: actions/upload-artifact@v4
with:
name: rabbitmq-${{steps.version.outputs.VERSION}}.fmu
path: rabbitmq

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
[submodule "thirdparty/date/date"]
path = thirdparty/date/date
url = https://github.com/HowardHinnant/date.git
[submodule "thirdparty/openssl"]
path = thirdparty/openssl
url = https://github.com/openssl/openssl.git
35 changes: 28 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7.2)


#cmake_policy(SET CMP0002 OLD)
set(CMAKE_POLICY_DEFAULT_CMP0079 NEW)

set(CMAKE_MACOSX_RPATH 1)
Expand All @@ -11,11 +11,6 @@ set(CMAKE_PROJECT_VERSION_MAJOR "")
set(CMAKE_PROJECT_VERSION_MINOR "")
set(CMAKE_PROJECT_VERSION_PATCH "")

#so that it can find the ssl stuff
if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl/lib")
ENDIF ()

set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/build/install" )

Expand Down Expand Up @@ -59,12 +54,35 @@ if (NOT DEFINED THIRD_PARTY_LIBRARIES_ROOT)
if (UNIX)
if (APPLE)
set(THIRD_PARTY_LIBRARIES_ROOT ${THIRD_PARTY_LIBRARIES_ROOT}/darwin)
set(XercesC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/external/darwin-${arch}/xerces-c/lib/cmake/XercesC")


set(OPENSSL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/build/external/darwin-${arch}/openssl/lib)
set(OPENSSL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/darwin-${arch}/openssl/include)
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/darwin-${arch}/openssl/lib)


ELSE ()
set(THIRD_PARTY_LIBRARIES_ROOT ${THIRD_PARTY_LIBRARIES_ROOT}/linux)
set(XercesC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/external/linux-${arch}/xerces-c/lib/cmake/XercesC")


set(OPENSSL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/build/external/linux-${arch}/openssl/lib64)
set(OPENSSL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/linux-${arch}/openssl/include)
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/linux-${arch}/openssl/lib64)


ENDIF ()
set(THIRD_PARTY_LIBRARIES_ROOT ${THIRD_PARTY_LIBRARIES_ROOT}-${arch})
message("Thirdparty libraries root:")
message(${THIRD_PARTY_LIBRARIES_ROOT})
ELSEIF (WIN32)
set(XercesC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/external/win-${arch}/cmake")
set(XercesC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/external/win-${arch}/xerces-c/cmake")
set(OPENSSL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/build/external/win-${arch}/openssl/lib64)
set(OPENSSL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/win-${arch}/openssl/include)
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/external/win-${arch}/openssl/lib64)


ENDIF ()
endif ()

Expand Down Expand Up @@ -112,6 +130,9 @@ message("ENABLE_RBMQ_FMU_TESTS: ${ENABLE_RBMQ_FMU_TESTS}")
set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)


set(RAPIDJSON_BUILD_DOC OFF CACHE BOOL "" FORCE)
set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/rapidjson)
#add_subdirectory(thirdparty/amqp-cpp)
#### Comment line 118 to build locally.
Expand Down
10 changes: 7 additions & 3 deletions rabbitmq-fmu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ include_directories(${gtest_SOURCE_DIR}/include)

# I need this: -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
#message(path to xercesc is ${xercerc_lib_path})

message("Path for XercesC_DIR is:")
message(${XercesC_DIR})
message("Path for CMAKE_PREFIX_PATH is:")
find_package(XercesC CONFIG PATHS ${THIRD_PARTY_LIBRARIES_ROOT} REQUIRED) # XSD DEPENDS ON ${XERCESC_FOUND}
if (XercesC_FOUND)
message(STATUS "Package Xerces-C++ found: ${XercesC_INCLUDE_DIR}")
Expand Down Expand Up @@ -80,9 +82,11 @@ elseif(APPLE)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(OPENSSL_ROOT_DIR "C:\\Strawberry\\c\\lib")
set(OPENSSL_ROOT_DIR "C:\\Program Files\\Common Files\\SSL")
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL 1.1.1 REQUIRED)
set(OPENSSL_MIN_VERSION 3.0.0)
set(OPENSSL_NO_DEPRECATED_3_0 TRUE)
find_package(OpenSSL REQUIRED)
target_link_libraries(rabbitmq XercesC::XercesC rabbitmq-static tz rabbitmq-core Threads::Threads OpenSSL::SSL OpenSSL::Crypto -static )
#target_link_libraries(rabbitmq XercesC::XercesC rabbitmq-static tz rabbitmq-core)
endif()
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq-fmu/test/basic_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ namespace{
int count = 0;

amqp_basic_properties_t props;
std::string routingkey = "linefollower.system_health.from_cosim";
std::string routingkey = "system_health.from_cosim";

////// create consumer on same connection different channel
int channelSub = 2;
amqp_channel_open(conn, channelSub);
printText = "Opening channel with ID: " + std::to_string(channelSub);

const char* qnametest = "boasorte";
const char* queueBindingKey = "linefollower.system_health.to_cosim";
const char* queueBindingKey = "system_health.to_cosim";
printText = "Declaring queue on channel with ID: " + std::to_string(channelSub);
printf("\n%s\n", printText.c_str());
amqp_queue_declare_ok_t *res = amqp_queue_declare(
Expand Down
Loading

0 comments on commit ed7c37c

Please sign in to comment.