Skip to content

Commit

Permalink
Add coreMQTT library
Browse files Browse the repository at this point in the history
JIRA: NIL-588
  • Loading branch information
mateuszkobak authored and mateuszkobak committed Jul 25, 2024
1 parent d19244f commit 74b670b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ for port in "${ports[@]}"; do
fi
done

[ "${PORTS_COREMQTT}" = "y" ] && ./phoenix-rtos-ports/coreMQTT/build.sh

exit 0
26 changes: 26 additions & 0 deletions coreMQTT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

project(coreMQTT)
cmake_minimum_required(VERSION 3.5)

set(PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(COREMQTT "coreMQTT-2.3.0")
set(CMAKE_C_FLAGS $ENV{EXPORT_CFLAGS})

set(SRC_FILES
"${PROJECT_ROOT}/${COREMQTT}/source/core_mqtt.c"
"${PROJECT_ROOT}/${COREMQTT}/source/core_mqtt_state.c"
"${PROJECT_ROOT}/${COREMQTT}/source/core_mqtt_serializer.c"
)

set(INCLUDE_PATHS "${PROJECT_ROOT}/${COREMQTT}/source/include" "${PROJECT_ROOT}/${COREMQTT}/source/interface")

add_library(${PROJECT_NAME} STATIC ${SRC_FILES})

if (DEFINED ENV{COREMQTT_CONFIG_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE $ENV{COREMQTT_CONFIG_DIR})
else()
add_compile_definitions(MQTT_DO_NOT_USE_CUSTOM_CONFIG)
endif()

target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_PATHS})
29 changes: 29 additions & 0 deletions coreMQTT/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -e

COREMQTT_VERSION="2.3.0"
COREMQTT="coreMQTT-${COREMQTT_VERSION}"
PKG_URL="https://github.com/FreeRTOS/coreMQTT/archive/refs/tags/v${COREMQTT_VERSION}.tar.gz"

b_log "Building coreMQTT"
PREFIX_COREMQTT="${PREFIX_PROJECT}/phoenix-rtos-ports/coreMQTT"
PREFIX_COREMQTT_BUILD="${PREFIX_BUILD}/coreMQTT"
PREFIX_COREMQTT_SRC="${PREFIX_COREMQTT_BUILD}/${COREMQTT}/source"
PREFIX_COREMQTT_INSTALL="${PREFIX_COREMQTT_BUILD}/install"

mkdir -p "$PREFIX_COREMQTT_BUILD" "$PREFIX_COREMQTT_INSTALL"
if [ ! -f "$PREFIX_COREMQTT/v${COREMQTT_VERSION}.tar.gz" ]; then
wget "$PKG_URL" -P "${PREFIX_COREMQTT}" --no-check-certificate;
fi

[ -d "$PREFIX_COREMQTT_SRC" ] || tar zxf "$PREFIX_COREMQTT/v${COREMQTT_VERSION}.tar.gz" -C "$PREFIX_COREMQTT_BUILD"

cp "${PREFIX_COREMQTT}/CMakeLists.txt" "${PREFIX_COREMQTT_BUILD}/CMakeLists.txt"

cmake -S "$PREFIX_COREMQTT_BUILD" -B "$PREFIX_COREMQTT_INSTALL"
make -C "$PREFIX_COREMQTT_INSTALL"

cp -a "$PREFIX_COREMQTT_SRC/include/"*".h" "$PREFIX_H"
cp -a "$PREFIX_COREMQTT_SRC/interface/"*".h" "$PREFIX_H"
cp -a "$PREFIX_COREMQTT_INSTALL/libcoreMQTT.a" "$PREFIX_A"

0 comments on commit 74b670b

Please sign in to comment.