Skip to content

Commit 5238519

Browse files
committed
Merge branch 'bugfix/enable_simple_http_server_on_linux' into 'master'
fix(examples): simple http_server example build for Linux target See merge request espressif/esp-idf!36277
2 parents 52b558d + 25fe9e5 commit 5238519

File tree

7 files changed

+39
-87
lines changed

7 files changed

+39
-87
lines changed

components/esp_http_server/CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
set(priv_req mbedtls)
2-
set(priv_inc_dir "src/util")
1+
set(priv_req mbedtls lwip esp_timer)
2+
set(priv_inc_dir "src/util" "src/port/esp32")
33
set(requires http_parser esp_event)
4-
if(NOT ${IDF_TARGET} STREQUAL "linux")
5-
list(APPEND priv_req lwip esp_timer)
6-
list(APPEND priv_inc_dir "src/port/esp32")
7-
else()
8-
list(APPEND priv_inc_dir "src/port/linux")
9-
list(APPEND priv_req pthread)
10-
endif()
114

125
idf_component_register(SRCS "src/httpd_main.c"
136
"src/httpd_parse.c"

components/esp_http_server/src/port/linux/osal.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

components/freertos/esp_additions/idf_additions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
/* Allocate memory for the task's stack using the provided memory caps
4949
* */
50-
pxStack = heap_caps_malloc( usStackDepth, ( uint32_t ) uxMemoryCaps );
50+
pxStack = heap_caps_malloc( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ), ( uint32_t ) uxMemoryCaps );
5151

5252
if( ( pxTaskBuffer == NULL ) || ( pxStack == NULL ) )
5353
{

examples/protocols/.build-test-rules.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ examples/protocols/esp_http_client:
2323
- if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux"
2424
disable_test:
2525
- if: IDF_TARGET not in ["esp32", "linux"]
26-
depends_filepatterns:
27-
- components/esp_http_client/**/*
26+
depends_components+:
27+
- esp_http_client
2828

2929
examples/protocols/esp_local_ctrl:
3030
<<: *default_dependencies
@@ -36,8 +36,9 @@ examples/protocols/esp_local_ctrl:
3636
- if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"]
3737
reason: only test on these targets
3838
depends_filepatterns:
39-
- components/protocomm/**/*
4039
- tools/esp_prov/**/*
40+
depends_components+:
41+
- protocomm
4142

4243
examples/protocols/http_request:
4344
<<: *default_dependencies
@@ -50,8 +51,8 @@ examples/protocols/http_server:
5051
disable_test:
5152
- if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"]
5253
reason: only test on these targets
53-
depends_filepatterns:
54-
- components/esp_http_server/**/*
54+
depends_components+:
55+
- esp_http_server
5556

5657
examples/protocols/http_server/captive_portal:
5758
<<: *default_dependencies
@@ -61,25 +62,35 @@ examples/protocols/http_server/captive_portal:
6162
disable_test:
6263
- if: IDF_TARGET != "esp32"
6364
reason: only test on esp32
64-
depends_filepatterns:
65-
- components/esp_http_server/**/*
65+
depends_components+:
66+
- esp_http_server
6667

6768
examples/protocols/http_server/restful_server:
6869
<<: *default_dependencies
6970
disable:
7071
- if: IDF_TARGET in ["esp32h2"]
7172
temporary: true
7273
reason: not supported yet
73-
depends_filepatterns:
74-
- components/esp_http_server/**/*
74+
depends_components+:
75+
- esp_http_server
76+
77+
examples/protocols/http_server/simple:
78+
<<: *default_dependencies
79+
enable:
80+
- if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux"
81+
disable_test:
82+
- if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"]
83+
reason: only test on these targets
84+
depends_components+:
85+
- esp_http_server
7586

7687
examples/protocols/http_server/ws_echo_server:
7788
<<: *default_dependencies
7889
disable_test:
7990
- if: IDF_TARGET != "esp32"
8091
reason: only test on esp32
81-
depends_filepatterns:
82-
- components/esp_http_server/**/*
92+
depends_components+:
93+
- esp_http_server
8394

8495
examples/protocols/https_mbedtls:
8596
<<: *default_dependencies
@@ -104,25 +115,25 @@ examples/protocols/https_server/simple:
104115
disable_test:
105116
- if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"]
106117
reason: only test on these targets
107-
depends_filepatterns:
108-
- components/esp_https_server/**/*
109-
- components/esp_tls/**/*
118+
depends_components+:
119+
- esp_https_server
120+
- esp-tls
110121

111122
examples/protocols/https_server/wss_server:
112123
<<: *default_dependencies
113124
disable_test:
114125
- if: IDF_TARGET != "esp32"
115126
reason: only test on esp32
116-
depends_filepatterns:
117-
- components/esp_https_server/**/*
127+
depends_components+:
128+
- esp_https_server
118129

119130
examples/protocols/https_x509_bundle:
120131
<<: *default_dependencies
121132
disable_test:
122133
- if: IDF_TARGET != "esp32"
123134
reason: only test on esp32
124-
depends_filepatterns:
125-
- components/esp_tls/**/*
135+
depends_components+:
136+
- esp-tls
126137

127138
examples/protocols/icmp_echo:
128139
<<: *default_dependencies

examples/protocols/http_server/simple/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | Linux |
2+
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- | ----- |
33

44
# Simple HTTPD Server Example
55

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
set(requires esp-tls nvs_flash esp_netif esp_http_server esp_wifi esp_eth)
1+
set(requires esp-tls nvs_flash esp_netif esp_http_server)
22
idf_build_get_property(target IDF_TARGET)
33

44
if(${target} STREQUAL "linux")
55
list(APPEND requires esp_stubs protocol_examples_common)
6+
else()
7+
list(APPEND requires esp_wifi esp_eth)
68
endif()
9+
710
idf_component_register(SRCS "main.c"
811
INCLUDE_DIRS "."
912
PRIV_REQUIRES ${requires})

examples/protocols/http_server/simple/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static esp_err_t sse_handler(httpd_req_t *req)
407407
gettimeofday(&tv, NULL); // Get the current time
408408
int64_t time_since_boot = tv.tv_sec; // Time since boot in seconds
409409
esp_err_t err;
410-
int len = snprintf(sse_data, sizeof(sse_data), "data: Time since boot: %lld seconds\n\n", time_since_boot);
410+
int len = snprintf(sse_data, sizeof(sse_data), "data: Time since boot: %" PRIi64 " seconds\n\n", time_since_boot);
411411
if ((err = httpd_resp_send_chunk(req, sse_data, len)) != ESP_OK) {
412412
ESP_LOGE(TAG, "Failed to send sse data (returned %02X)", err);
413413
break;

0 commit comments

Comments
 (0)