Support hosted builds against Arduino-Emulator#420
Support hosted builds against Arduino-Emulator#420MitchBradley wants to merge 7 commits intoESP32Async:mainfrom
Conversation
* Factors the locking into one place * Adds "|| defined(HOST)" as needed elsewhere * Adds "override" in a few places where it was missing
There was a problem hiding this comment.
Pull request overview
This PR improves hosted/POSIX build compatibility (Arduino-Emulator) by expanding HOST platform guards, centralizing locking primitives, and tightening virtual overrides across the async webserver components.
Changes:
- Add
HOSTto platform-specific include/behavior guards (WiFi, MD5, String clearing paths, TCP backends). - Factor ESP32-style locking into shared macros and apply them consistently in WebSocket and SSE (EventSource) code paths.
- Add missing
overridespecifiers for response implementations.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/WebServer.cpp | Include WiFi.h under HOST to support hosted builds. |
| src/WebRequest.cpp | Treat HOST like certain embedded cores for _temp clearing behavior. |
| src/WebAuthentication.cpp | Add missing include and extend MD5 implementation selection to HOST. |
| src/ESPAsyncWebServer.h | Guard lwIP include for HOST; introduce shared locking macros; define __unused if missing. |
| src/AsyncWebSocket.h | Add HOST platform section; switch mutex members to shared locking macro; add overrides. |
| src/AsyncWebSocket.cpp | Replace ESP32-only mutex usage with shared lock macros; add hosted SHA1 backport include. |
| src/AsyncWebServerLogging.h | Disable framework logging macros for HOST. |
| src/AsyncEventSource.h | Add HOST to AsyncTCP include path; switch mutex members to shared locking macro; add overrides. |
| src/AsyncEventSource.cpp | Replace ESP32-only mutex usage with shared lock macros for queue/client-list protection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #define async_ws_log_e(format, ...) | ||
| #define async_ws_log_w(format, ...) | ||
| #define async_ws_log_i(format, ...) | ||
| #define async_ws_log_d(format, ...) | ||
| #define async_ws_log_v(format, ...) |
There was a problem hiding this comment.
@MitchBradley is it normal to not implement them ? Cannot even be similar to what is done for 8266 ? All logs will be muted... Is that expected ?
There was a problem hiding this comment.
I fixed it. Note that the other versions that use Serial.printf() probably are missing newlines, possibly causing run-on lines and perhaps output delays depending on buffering.
There was a problem hiding this comment.
Indeed! For the RPI use cases right ?
| #if !defined(ASYNCWEBSERVER_USE_MUTEX) | ||
| #define ASYNCWEBSERVER_USE_MUTEX defined(ESP32) || defined(HOST) | ||
| #endif |
There was a problem hiding this comment.
| #if !defined(ASYNCWEBSERVER_USE_MUTEX) | |
| #define ASYNCWEBSERVER_USE_MUTEX defined(ESP32) || defined(HOST) | |
| #endif | |
| #if !defined(ASYNCWEBSERVER_USE_MUTEX) | |
| #if defined(ESP32) || defined(HOST) | |
| #define ASYNCWEBSERVER_USE_MUTEX 1 | |
| #else | |
| #define ASYNCWEBSERVER_USE_MUTEX 0 | |
| #endif | |
| #endif |
I would prefer that in order to be able to document a consistant behavior: ASYNCWEBSERVER_USE_MUTEX can be either 1 or 0.
src/ESPAsyncWebServer.h
Outdated
|
|
||
| #ifndef __unused | ||
| #define __unused __attribute__((unused)) | ||
| #endif |
There was a problem hiding this comment.
I placed a comment previously about that but it got lost I think.
This can define __unused globally to any use code that includes our header. Maybe that's not what the user expects. And definitely it is at risk that he depends in his code on a macro definition that comes from a library and is internal to this library.
I would rather have it defined as #define __asyncws_unused __attribute__((unused))
Or surrounded with #ifdef HOST to scope this definition to 1 platform only, but that does not remove the issue.
|
@MitchBradley : thank you for your last updates :-) I have 2 more comments left. I will first merge #421, then you will be able to rebase this PR with the comments fixed and it will be ready to be merged. |
This partially supersedes #416 , addressing only the topic of compatibility with Arduino-Emulator, without the emptyString part (already addressed) and without the on-close state machine fixes (to be addressed in a separate PR).