Skip to content

Support hosted builds against Arduino-Emulator#420

Merged
mathieucarbou merged 21 commits intoESP32Async:mainfrom
MitchBradley:HOSTmacro
Apr 8, 2026
Merged

Support hosted builds against Arduino-Emulator#420
mathieucarbou merged 21 commits intoESP32Async:mainfrom
MitchBradley:HOSTmacro

Conversation

@MitchBradley
Copy link
Copy Markdown

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).

  • Factors the locking into one place
  • Adds "|| defined(HOST)" as needed elsewhere
  • Adds "override" in a few places where it was missing

* Factors the locking into one place
* Adds "|| defined(HOST)" as needed elsewhere
* Adds "override" in a few places where it was missing
Copilot AI review requested due to automatic review settings April 4, 2026 21:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HOST to 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 override specifiers 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.

@mathieucarbou
Copy link
Copy Markdown
Member

@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.

@mathieucarbou mathieucarbou self-assigned this Apr 8, 2026
@mathieucarbou
Copy link
Copy Markdown
Member

@MitchBradley I fixed some compilation issues and added a CI workflow for Arduino-Emulator. I don't understand why you removed the inclusion of tcp_base lwip header for HOST: it is required since defines the tcp_stats enumerated type returned by asyncws. The right way is I think to compile the project with lwip.

@mathieucarbou
Copy link
Copy Markdown
Member

@MitchBradley : I added several commits to make sure the added feature work and that we can indeed compile with Arduino Emulator. I added a CI workflow for that also and an exemple in examples/arduino_emulator.
As you can will see, for now, the cmake file only compiles.
This is not possible to link to an exec because AsyncTCP does not support Arduino Emulator and won't compile: AsyncTCP relies on some freertos functions that are mort part of Arduino Emulator.

I will merge this PR because this still has some value, but if you can take time to send another one to complete this examples/arduino_emulator example in order to really show a use case (I do think you have one in hand), it would be nice.

I am wondering if similar work should happen in AsyncTCP too.

Thanks!

@mathieucarbou mathieucarbou merged commit c25aabc into ESP32Async:main Apr 8, 2026
34 checks passed
@MitchBradley
Copy link
Copy Markdown
Author

http://github.com/MitchBradley/PosixAsyncTCP

This effort was very tricky because it involved coordinated changes to so many different packages. I tried to break it down into isolated stages, but until all pieces were addressed, it was not easy to test the stages.

@mathieucarbou
Copy link
Copy Markdown
Member

http://github.com/MitchBradley/PosixAsyncTCP

This effort was very tricky because it involved coordinated changes to so many different packages. I tried to break it down into isolated stages, but until all pieces were addressed, it was not easy to test the stages.

Nice! So now that the PR is merged and we have a CI + example it should be easier to complete any testing you need.
Ideally the example would need to be completed up to the link state and create an executable.

@mathieucarbou
Copy link
Copy Markdown
Member

@MitchBradley : I also now understand why you attempted to remove the inclusion of lwip header, which I rolled back when adding a CI example....

I pushed a new PR to switch to your fork for the compilation: #423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants