Fix build failures on host platform caused by #6167 (#6338)

* Fix build failures for logger component on host platform

* Add climits header

* Restore logger functionality on host

* Install libsodium in ci
This commit is contained in:
Clyde Stubbs 2024-03-10 14:08:58 +11:00 committed by GitHub
parent 90f416bd0d
commit 0bc645ded7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 33 additions and 0 deletions

View file

@ -433,6 +433,9 @@ jobs:
matrix:
file: ${{ fromJson(needs.list-components.outputs.matrix) }}
steps:
- name: Install libsodium
run: sudo apt-get install libsodium-dev
- name: Check out code from GitHub
uses: actions/checkout@v4.1.1
- name: Restore Python

View file

@ -6,6 +6,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/version.h"
#include <cinttypes>
#include <climits>
#ifdef USE_ESP32
@ -49,6 +50,8 @@ static uint32_t get_free_heap() {
return rp2040.getFreeHeap();
#elif defined(USE_LIBRETINY)
return lt_heap_get_free();
#elif defined(USE_HOST)
return INT_MAX;
#endif
}

View file

@ -144,6 +144,8 @@ def uart_selection(value):
component = get_libretiny_component()
if component in UART_SELECTION_LIBRETINY:
return cv.one_of(*UART_SELECTION_LIBRETINY[component], upper=True)(value)
if CORE.is_host:
raise cv.Invalid("Uart selection not valid for host platform")
raise NotImplementedError

View file

@ -146,8 +146,10 @@ const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DE
void Logger::dump_config() {
ESP_LOGCONFIG(TAG, "Logger:");
ESP_LOGCONFIG(TAG, " Level: %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]);
#ifndef USE_HOST
ESP_LOGCONFIG(TAG, " Log Baud Rate: %" PRIu32, this->baud_rate_);
ESP_LOGCONFIG(TAG, " Hardware UART: %s", get_uart_selection_());
#endif
for (auto &it : this->log_levels_) {
ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.tag.c_str(), LOG_LEVELS[it.level]);

View file

@ -137,7 +137,9 @@ class Logger : public Component {
va_end(arg);
}
#ifndef USE_HOST
const char *get_uart_selection_();
#endif
uint32_t baud_rate_;
char *tx_buffer_{nullptr};

View file

@ -16,6 +16,8 @@ void HOT Logger::write_msg_(const char *msg) {
puts(msg);
}
void Logger::pre_setup() { global_logger = this; }
} // namespace logger
} // namespace esphome

View file

@ -0,0 +1 @@
debug:

View file

@ -0,0 +1,18 @@
esphome:
name: componenttesthost
friendly_name: $component_name
host:
mac_address: "62:23:45:AF:B3:DD"
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file