From a77c269ed5c908c74879a206047991d264d4b615 Mon Sep 17 00:00:00 2001 From: Jose Cabral Date: Mon, 16 Sep 2024 18:43:43 +0200 Subject: [PATCH] add mqtt action in its own file and call it from the workflow --- .github/actions/mqtt/action.yml | 52 ++++++++++++++++++++++ .github/workflows/cmake-multi-platform.yml | 11 +++++ 2 files changed, 63 insertions(+) create mode 100644 .github/actions/mqtt/action.yml diff --git a/.github/actions/mqtt/action.yml b/.github/actions/mqtt/action.yml new file mode 100644 index 00000000..e617b144 --- /dev/null +++ b/.github/actions/mqtt/action.yml @@ -0,0 +1,52 @@ +name: Clone and compile paho-mqtt +author: Jose Cabral +Description: "Clone paho-mqtt and build a release static library with SSL enabled" + +inputs: + git_version: + type: string + Decription: Version of paho-mqtt to clone + required: True + + c_compiler: + type: string + Description: C compiler to use, passed as CMAKE_C_COMPILER to CMake + required: True + +outputs: + mqtt-include: + value: ${{ steps.vars.outputs.mqtt-include }} + description: The include directory + mqtt-lib-dir: + value: ${{ steps.vars.outputs.mqtt-lib-dir }} + description: The library directory + +runs: + using: "composite" + steps: + - name: Clone paho-mqtt + shell: bash + run: | + git clone https://github.com/eclipse/paho.mqtt.c.git -b ${{ inputs.git_version }} + + - name: Build paho-mqtt + shell: bash + run: | + cd paho.mqtt.c + + cmake \ + -B static \ + -DCMAKE_C_COMPILER=${{ inputs.c_compiler }} \ + -DCMAKE_BUILD_TYPE=Release \ + -DPAHO_BUILD_STATIC=ON \ + -DPAHO_BUILD_SHARED=OFF \ + -DPAHO_WITH_SSL=ON + + cmake --build static --config Release + + - name: Output variables + id: vars + shell: bash + run: | + echo "mqtt-include=${{ github.workspace }}/paho.mqtt.c/src" >> "$GITHUB_OUTPUT" + echo "mqtt-lib-dir=${{ github.workspace }}/paho.mqtt.c/static/src" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index cba04f02..1dbdb70f 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -73,6 +73,13 @@ jobs: cpp_compiler: ${{ matrix.cpp_compiler }} c_compiler: ${{ matrix.c_compiler }} + - name: clone and build paho-mqtt + id: paho-mqtt + uses: ./.github/actions/mqtt + with: + git_version: v1.3.13 + c_compiler: ${{ matrix.c_compiler }} + - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type @@ -92,6 +99,10 @@ jobs: -DFORTE_COM_OPC_UA_INCLUDE_DIR=${{ steps.open62541.outputs.opc_ua-include }} -DFORTE_COM_OPC_UA_LIB_DIR=${{ steps.open62541.outputs.opc_ua-lib-dir }}/${{ matrix.os == 'windows-latest' && matrix.build_type || '' }} -DFORTE_COM_OPC_UA_MULTICAST=ON + -DFORTE_COM_PAHOMQTT=ON + -DFORTE_COM_PAHOMQTT_INCLUDE_DIR=${{ steps.paho-mqtt.outputs.mqtt-include }} + -DFORTE_COM_PAHOMQTT_LIB_DIR=${{ steps.paho-mqtt.outputs.mqtt-lib-dir }}/${{ matrix.os == 'windows-latest' && 'Release' || '' }} + -DFORTE_COM_PAHOMQTT_LIB=${{ matrix.os == 'windows-latest' && 'paho-mqtt3a-static.lib' || 'libpaho-mqtt3as.a' }} -DFORTE_COM_RAW=ON -DFORTE_COM_SER=ON -DFORTE_COM_STRUCT_MEMBER=ON