From 3159561cfbdd4fa6121d7c5bbec67621a6705bd1 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 2 Aug 2024 12:20:09 +0200 Subject: [PATCH] compile native on OSX --- lib/espMqttClient/src/Helpers.h | 2 +- lib/espMqttClient/src/Transport/ClientPosixIPAddress.cpp | 4 ---- lib/espMqttClient/src/espMqttClient.cpp | 2 +- lib/espMqttClient/src/espMqttClient.h | 2 +- platformio.ini | 2 +- src/console.cpp | 3 ++- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/espMqttClient/src/Helpers.h b/lib/espMqttClient/src/Helpers.h index 5228156ea..fcda6f3e2 100644 --- a/lib/espMqttClient/src/Helpers.h +++ b/lib/espMqttClient/src/Helpers.h @@ -47,7 +47,7 @@ the LICENSE file. #include // NOLINT [build/c++11] #define EMC_SEMAPHORE_TAKE() mtx.lock(); #define EMC_SEMAPHORE_GIVE() mtx.unlock(); -#elif defined(_WIN32) +#elif defined(_WIN32) || defined(__APPLE__) #include #define EMC_SEMAPHORE_TAKE() #define EMC_SEMAPHORE_GIVE() diff --git a/lib/espMqttClient/src/Transport/ClientPosixIPAddress.cpp b/lib/espMqttClient/src/Transport/ClientPosixIPAddress.cpp index 3bf936d93..b7d0c636a 100644 --- a/lib/espMqttClient/src/Transport/ClientPosixIPAddress.cpp +++ b/lib/espMqttClient/src/Transport/ClientPosixIPAddress.cpp @@ -6,8 +6,6 @@ For a copy, see or the LICENSE file. */ -#if defined(__linux__) || defined(_WIN32) - #include "ClientPosixIPAddress.h" IPAddress::IPAddress() @@ -28,5 +26,3 @@ IPAddress::IPAddress(uint32_t address) IPAddress::operator uint32_t() { return _address; } - -#endif diff --git a/lib/espMqttClient/src/espMqttClient.cpp b/lib/espMqttClient/src/espMqttClient.cpp index a2cdc5ba7..ab1a3649b 100644 --- a/lib/espMqttClient/src/espMqttClient.cpp +++ b/lib/espMqttClient/src/espMqttClient.cpp @@ -120,7 +120,7 @@ espMqttClient::espMqttClient() , _client() { _transport = &_client; } -#elif defined(_WIN32) +#elif defined(_WIN32) || defined(__APPLE__) // Windows espMqttClient::espMqttClient() : MqttClientSetup(espMqttClientTypes::UseInternalTask::NO) { diff --git a/lib/espMqttClient/src/espMqttClient.h b/lib/espMqttClient/src/espMqttClient.h index 8e42052d2..531dd7ba5 100644 --- a/lib/espMqttClient/src/espMqttClient.h +++ b/lib/espMqttClient/src/espMqttClient.h @@ -76,7 +76,7 @@ class espMqttClient : public MqttClientSetup { protected: espMqttClientInternals::ClientPosix _client; }; -#elif defined(_WIN32) +#elif defined(_WIN32) || defined(__APPLE__) class espMqttClient : public MqttClientSetup { public: espMqttClient(); diff --git a/platformio.ini b/platformio.ini index a1b785614..e4a6bab4f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -260,7 +260,7 @@ lib_ignore = Module EMS-ESP-Modules ; unit tests ; pio run -e native-test -t exec -; works on Linux and Windows +; works on Linux, Windows, and MacOS [env:native-test] platform = native test_build_src = true diff --git a/src/console.cpp b/src/console.cpp index 3d4dfb0c6..3a3642820 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -532,7 +532,8 @@ static void setup_commands(std::shared_ptr & commands) { JsonDocument doc; int8_t id = -1; - const char * cmd = Helpers::toLower(arguments[1]).c_str(); + auto arg = Helpers::toLower(arguments[1]); + const char * cmd = arg.c_str(); // prevent loosing pointer after object destruction uint8_t return_code = CommandRet::OK; JsonObject json = doc.to(); bool has_data = false;