diff --git a/.github/workflows/build-arduino-emulator.yml b/.github/workflows/build-arduino-emulator.yml index 35931b70..00a02c57 100644 --- a/.github/workflows/build-arduino-emulator.yml +++ b/.github/workflows/build-arduino-emulator.yml @@ -41,12 +41,11 @@ jobs: - name: Clone AsyncTCP, Arduino FS headers, lwIP and lwIP contrib run: | - git clone --depth 1 https://github.com/ESP32Async/AsyncTCP .ci/asynctcp + git clone --depth 1 https://github.com/MitchBradley/PosixAsyncTCP .ci/asynctcp git clone --depth 1 https://github.com/espressif/arduino-esp32.git .ci/arduino-esp32 - git clone --depth 1 https://github.com/lwip-tcpip/lwip.git .ci/lwip - git clone --depth 1 https://git.savannah.nongnu.org/git/lwip/lwip-contrib.git .ci/lwip-contrib - name: Build with Arduino-Emulator run: | cmake -S examples/arduino_emulator -B .ci/arduino-emulator-build/out -G Ninja - cmake --build .ci/arduino-emulator-build/out --target espasyncwebserver --parallel + cmake --build .ci/arduino-emulator-build/out --target espasyncwebserver_host --parallel + chmod +x .ci/arduino-emulator-build/out/espasyncwebserver_host diff --git a/examples/arduino_emulator/CMakeLists.txt b/examples/arduino_emulator/CMakeLists.txt index 91ba9e62..a6b3b925 100644 --- a/examples/arduino_emulator/CMakeLists.txt +++ b/examples/arduino_emulator/CMakeLists.txt @@ -4,14 +4,26 @@ project(espasyncwebserver_host_compile LANGUAGES C CXX) add_subdirectory(${CMAKE_SOURCE_DIR}/../../.ci/arduino-emulator ${CMAKE_BINARY_DIR}/arduino-emulator) file(GLOB WEB_SRC "${CMAKE_SOURCE_DIR}/../../src/*.cpp") add_library(espasyncwebserver STATIC ${WEB_SRC}) +add_library(test STATIC + ${CMAKE_SOURCE_DIR}/../../.ci/asynctcp/src/AsyncTCP.cpp + ${CMAKE_SOURCE_DIR}/../../.ci/arduino-esp32/libraries/FS/src/FS.cpp + ${CMAKE_SOURCE_DIR}/../../.ci/arduino-emulator/ArduinoCore-Linux/cores/arduino/libb64/cencode.c +) target_compile_definitions(espasyncwebserver PUBLIC HOST ARDUINO=10813) target_include_directories(espasyncwebserver PUBLIC ${CMAKE_SOURCE_DIR}/../../src ${CMAKE_SOURCE_DIR}/../../.ci/asynctcp/src ${CMAKE_SOURCE_DIR}/../../.ci/arduino-esp32/libraries/FS/src - ${CMAKE_SOURCE_DIR}/../../.ci/lwip/src/include - ${CMAKE_SOURCE_DIR}/../../.ci/lwip-contrib/ports/unix/port/include - ${CMAKE_SOURCE_DIR}/host_config ) target_link_libraries(espasyncwebserver PUBLIC arduino_emulator) + +target_compile_definitions(test PUBLIC HOST ARDUINO=10813) +target_include_directories(test PUBLIC + ${CMAKE_SOURCE_DIR}/../../.ci/asynctcp/src + ${CMAKE_SOURCE_DIR}/../../.ci/arduino-esp32/libraries/FS/src +) +target_link_libraries(test PUBLIC arduino_emulator) + +add_executable(espasyncwebserver_host main.cpp) +target_link_libraries(espasyncwebserver_host PRIVATE espasyncwebserver test) diff --git a/examples/arduino_emulator/host_config/freertos/semphr.h b/examples/arduino_emulator/host_config/freertos/semphr.h deleted file mode 100644 index e375268b..00000000 --- a/examples/arduino_emulator/host_config/freertos/semphr.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -typedef void *SemaphoreHandle_t; diff --git a/examples/arduino_emulator/host_config/lwipopts.h b/examples/arduino_emulator/host_config/lwipopts.h deleted file mode 100644 index 89e5a55b..00000000 --- a/examples/arduino_emulator/host_config/lwipopts.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#define NO_SYS 1 -#define LWIP_SOCKET 0 -#define LWIP_NETCONN 0 -#define LWIP_TCP 1 -#define LWIP_IPV6 1 - -#if defined(__linux__) && !defined(LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS) -#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1 -#endif diff --git a/examples/arduino_emulator/host_config/sdkconfig.h b/examples/arduino_emulator/host_config/sdkconfig.h deleted file mode 100644 index e668816e..00000000 --- a/examples/arduino_emulator/host_config/sdkconfig.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define LWIP_IPV6 1 diff --git a/examples/arduino_emulator/main.cpp b/examples/arduino_emulator/main.cpp new file mode 100644 index 00000000..1afc375f --- /dev/null +++ b/examples/arduino_emulator/main.cpp @@ -0,0 +1,20 @@ +#include +#include + +static AsyncWebServer server(8080); + +void setup() { + server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { + request->send(200, "text/plain", "ESPAsyncWebServer host app is running on port 8080\n"); + }); + + server.onNotFound([](AsyncWebServerRequest *request) { + request->send(404, "text/plain", "Not found\n"); + }); + + server.begin(); +} + +void loop() { + delay(1000); +} diff --git a/src/ESPAsyncWebServer.h b/src/ESPAsyncWebServer.h index b790eb63..a45034c5 100644 --- a/src/ESPAsyncWebServer.h +++ b/src/ESPAsyncWebServer.h @@ -5,7 +5,10 @@ #include #include + +#if !defined(HOST) || __has_include() #include +#endif #include #include