Skip to content

Commit

Permalink
add mqtt action in its own file and call it from the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cochicde committed Sep 16, 2024
1 parent 539b6f7 commit ef67fe5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/actions/mqtt/action.yml
Original file line number Diff line number Diff line change
@@ -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 disabled"

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=OFF
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"
11 changes: 11 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ef67fe5

Please sign in to comment.