mirror of
https://github.com/espressif/esp-protocols.git
synced 2026-01-25 08:32:22 +01:00
feat(mosq): Add support for linux build
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
idf_build_get_property(idf_target IDF_TARGET)
|
||||
|
||||
set(m_dir mosquitto)
|
||||
set(m_src_dir ${m_dir}/src)
|
||||
set(m_incl_dir ${m_dir}/include)
|
||||
@@ -94,6 +96,10 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
# without modifying upstream code
|
||||
target_link_options(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mosquitto_unpwd_check")
|
||||
|
||||
if(${idf_target} STREQUAL "linux")
|
||||
target_link_options(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=main")
|
||||
endif()
|
||||
|
||||
# Some mosquitto source unconditionally define `_GNU_SOURCE` which collides with IDF build system
|
||||
# producing warning: "_GNU_SOURCE" redefined
|
||||
# This workarounds this issue by undefining the macro for the selected files
|
||||
|
||||
@@ -3,4 +3,11 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
if("${IDF_TARGET}" STREQUAL "linux")
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "../../../../common_components/linux_compat")
|
||||
endif()
|
||||
|
||||
idf_build_set_property(MINIMAL_BUILD ON)
|
||||
|
||||
project(broker)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "mosq_broker.h"
|
||||
#include "protocol_examples_common.h"
|
||||
|
||||
const static char *TAG = "mqtt_broker";
|
||||
__attribute__((unused)) const static char *TAG = "mqtt_broker";
|
||||
|
||||
/* Basic auth credentials for the example */
|
||||
#define EXAMPLE_USERNAME "testuser"
|
||||
|
||||
@@ -8,3 +8,6 @@ dependencies:
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
espressif/sock_utils:
|
||||
version: '*'
|
||||
override_path: '../../../../sock_utils'
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "mosquitto_broker_internal.h"
|
||||
#include "memory_mosq.h"
|
||||
#include "mosq_broker.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static struct mosquitto__listener_sock *listensock = NULL;
|
||||
static int listensock_count = 0;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "utlist.h"
|
||||
#include "lib_load.h"
|
||||
#include "syslog.h"
|
||||
#include <limits.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
||||
@@ -244,3 +245,13 @@ pid_t fork(void)
|
||||
abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_LINUX
|
||||
extern void app_main(void);
|
||||
|
||||
int __wrap_main(int argc, char *argv[])
|
||||
{
|
||||
app_main();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "time_mosq.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
void mosquitto_time_init(void)
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||
|
||||
#include "esp_log.h"
|
||||
#define LOG_EMERG (0)
|
||||
#define LOG_ALERT (1)
|
||||
@@ -30,6 +28,5 @@
|
||||
|
||||
#define syslog(sev, format, ... ) ESP_LOG_LEVEL_LOCAL(sev-2, "mosquitto", format, ##__VA_ARGS__)
|
||||
|
||||
#define gai_strerror(x) "gai_strerror() not supported"
|
||||
#define openlog(a, b, c)
|
||||
#define closelog()
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
* SPDX-FileContributor: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
#include "signal.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
int sigprocmask (int, const sigset_t *, sigset_t *)
|
||||
#ifndef CONFIG_IDF_TARGET_LINUX
|
||||
int sigprocmask(int, const sigset_t *, sigset_t *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user