Skip to content

Commit 68c2255

Browse files
authored
Merge pull request #977 from david-cermak/feat/mosq_linux_build
[mosq]: Add support for linux build
2 parents d30246b + be35e7c commit 68c2255

File tree

19 files changed

+84
-12
lines changed

19 files changed

+84
-12
lines changed

.github/workflows/examples_build-host-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,22 @@ jobs:
5353
steps:
5454
- name: Checkout esp-protocols
5555
uses: actions/checkout@v4
56+
with:
57+
submodules: recursive
5658
- name: Build with IDF-${{ matrix.idf_ver }}
5759
shell: bash
5860
run: |
5961
. ${GITHUB_WORKSPACE}/ci/config_env.sh
6062
. ${IDF_PATH}/export.sh
6163
python -m pip install idf-build-apps
6264
python ./ci/build_apps.py examples/mqtt -l -t linux -r 'sdkconfig.ci'
65+
./ci/test_broker/run.sh
66+
sleep 1
67+
failed=0
6368
timeout 5 ./examples/mqtt/build_linux/esp_mqtt_demo.elf | tee test.log || true
64-
grep 'MQTT_EVENT_DATA' test.log
69+
grep 'MQTT_EVENT_DATA' test.log || failed=1
70+
pkill -f 'broker.elf' || true
71+
exit $failed
6572
6673
run_on_target:
6774
# Skip running on forks since it won't have access to secrets

ci/test_broker/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BROKER_PATH=components/mosquitto/examples/broker
6+
SCRIPT_DIR=$(dirname $0)
7+
cp ${SCRIPT_DIR}/sdkconfig.broker ${BROKER_PATH}/sdkconfig.broker
8+
idf.py -B build -DSDKCONFIG=sdkconfig.broker -C ${BROKER_PATH} build
9+
10+
./build/broker.elf &
11+
export MOSQ_PID=$!
12+
echo "Broker started with PID ${MOSQ_PID}"

ci/test_broker/sdkconfig.broker

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_IDF_TARGET="linux"
2+
CONFIG_EXAMPLE_BROKER_PORT=1234
3+
CONFIG_EXAMPLE_BROKER_RUN_LOCAL_MQTT_CLIENT=n
4+
CONFIG_EXAMPLE_BROKER_WITH_TLS=n
5+
CONFIG_ESP_EVENT_POST_FROM_ISR=n

components/mosquitto/.cz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(mosq): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py mosquitto
55
tag_format: mosq-v$version
6-
version: 2.0.20~5
6+
version: 2.0.20~6
77
version_files:
88
- idf_component.yml

components/mosquitto/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [2.0.20~6](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_6)
4+
5+
### Features
6+
7+
- Add support for linux build ([58380585](https://github.com/espressif/esp-protocols/commit/58380585))
8+
9+
### Bug Fixes
10+
11+
- Fix mosquitto build on latest master ([ebc1258e](https://github.com/espressif/esp-protocols/commit/ebc1258e))
12+
- Fix build with the new picolibc ([dc68bf87](https://github.com/espressif/esp-protocols/commit/dc68bf87))
13+
314
## [2.0.20~5](https://github.com/espressif/esp-protocols/commits/mosq-v2.0.20_5)
415

516
### Features

components/mosquitto/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
idf_build_get_property(idf_target IDF_TARGET)
2+
13
set(m_dir mosquitto)
24
set(m_src_dir ${m_dir}/src)
35
set(m_incl_dir ${m_dir}/include)
@@ -94,6 +96,10 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
9496
# without modifying upstream code
9597
target_link_options(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mosquitto_unpwd_check")
9698

99+
if(${idf_target} STREQUAL "linux")
100+
target_link_options(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=main")
101+
endif()
102+
97103
# Some mosquitto source unconditionally define `_GNU_SOURCE` which collides with IDF build system
98104
# producing warning: "_GNU_SOURCE" redefined
99105
# This workarounds this issue by undefining the macro for the selected files

components/mosquitto/examples/broker/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@
33
cmake_minimum_required(VERSION 3.16)
44

55
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6+
7+
if("${IDF_TARGET}" STREQUAL "linux")
8+
list(APPEND EXTRA_COMPONENT_DIRS "../../../../common_components/linux_compat")
9+
endif()
10+
11+
idf_build_set_property(MINIMAL_BUILD ON)
12+
613
project(broker)

components/mosquitto/examples/broker/main/example_broker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "mosq_broker.h"
1414
#include "protocol_examples_common.h"
1515

16-
const static char *TAG = "mqtt_broker";
16+
__attribute__((unused)) const static char *TAG = "mqtt_broker";
1717

1818
/* Basic auth credentials for the example */
1919
#define EXAMPLE_USERNAME "testuser"

components/mosquitto/examples/broker/main/idf_component.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ dependencies:
88
rules:
99
- if: idf_version >=6.0
1010
version: ^1.0.0
11+
espressif/sock_utils:
12+
version: '*'
13+
override_path: '../../../../sock_utils'

components/mosquitto/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.20~5"
1+
version: "2.0.20~6"
22
url: https://github.com/espressif/esp-protocols/tree/master/components/mosquitto
33
description: The component provides a simple ESP32 port of mosquitto broker
44
dependencies:

0 commit comments

Comments
 (0)