Skip to content

Commit 741dbfc

Browse files
committed
fix(build): Allow Arduino to compile in IDF without components
This adds guards for the rest of the extra components
1 parent f8d9ffb commit 741dbfc

File tree

11 files changed

+45
-15
lines changed

11 files changed

+45
-15
lines changed

CMakeLists.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ set(ARDUINO_ALL_LIBRARIES
119119
)
120120

121121
set(ARDUINO_LIBRARY_ArduinoOTA_SRCS libraries/ArduinoOTA/src/ArduinoOTA.cpp)
122-
set(ARDUINO_LIBRARY_ArduinoOTA_REQUIRES esp_https_ota)
123122

124123
set(ARDUINO_LIBRARY_AsyncUDP_SRCS libraries/AsyncUDP/src/AsyncUDP.cpp)
125124

@@ -160,7 +159,6 @@ set(ARDUINO_LIBRARY_HTTPUpdate_SRCS libraries/HTTPUpdate/src/HTTPUpdate.cpp)
160159
set(ARDUINO_LIBRARY_Insights_SRCS libraries/Insights/src/Insights.cpp)
161160

162161
set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp)
163-
set(ARDUINO_LIBRARY_LittleFS_REQUIRES joltwallet__littlefs)
164162

165163
set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp)
166164

@@ -325,7 +323,7 @@ endforeach()
325323
set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRARIES_INCLUDEDIRS})
326324
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
327325
set(priv_includes cores/esp32/libb64)
328-
set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_ringbuf esp_driver_gptimer esp_driver_usb_serial_jtag driver espressif__network_provisioning)
326+
set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_ringbuf esp_driver_gptimer esp_driver_usb_serial_jtag driver)
329327
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES})
330328

331329
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_OpenThread)
@@ -391,3 +389,9 @@ endif()
391389
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_Matter)
392390
maybe_add_component(espressif__esp_matter)
393391
endif()
392+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LittleFS)
393+
maybe_add_component(joltwallet__littlefs)
394+
endif()
395+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_WiFiProv)
396+
maybe_add_component(espressif__network_provisioning)
397+
endif()

libraries/ArduinoOTA/src/ArduinoOTA.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ void ArduinoOTAClass::begin() {
120120
sprintf(tmp, "esp32-%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
121121
_hostname = tmp;
122122
}
123+
#ifdef CONFIG_MDNS_MAX_INTERFACES
123124
if (_mdnsEnabled) {
124125
MDNS.begin(_hostname.c_str());
125126
MDNS.enableArduino(_port, (_password.length() > 0));
126127
}
128+
#endif
127129
_initialized = true;
128130
_state = OTA_IDLE;
129131
log_i("OTA server at: %s.local:%u", _hostname.c_str(), _port);
@@ -358,9 +360,11 @@ void ArduinoOTAClass::_runUpdate() {
358360
void ArduinoOTAClass::end() {
359361
_initialized = false;
360362
_udp_ota.stop();
363+
#ifdef CONFIG_MDNS_MAX_INTERFACES
361364
if (_mdnsEnabled) {
362365
MDNS.end();
363366
}
367+
#endif
364368
_state = OTA_IDLE;
365369
log_i("OTA server stopped.");
366370
}

libraries/ESP_I2S/src/ESP_I2S.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include "esp32-hal-periman.h"
99
#include "wav_header.h"
10+
#if ARDUINO_HAS_MP3_DECODER
1011
#include "mp3dec.h"
12+
#endif
1113

1214
#define I2S_READ_CHUNK_SIZE 1920
1315

@@ -1014,6 +1016,7 @@ void I2SClass::playWAV(uint8_t *data, size_t len) {
10141016
write(data + WAVE_HEADER_SIZE + data_offset, data_chunk->subchunk_size);
10151017
}
10161018

1019+
#if ARDUINO_HAS_MP3_DECODER
10171020
bool I2SClass::playMP3(uint8_t *src, size_t src_len) {
10181021
int16_t outBuf[MAX_NCHAN * MAX_NGRAN * MAX_NSAMP];
10191022
uint8_t *readPtr = NULL;
@@ -1051,5 +1054,6 @@ bool I2SClass::playMP3(uint8_t *src, size_t src_len) {
10511054
MP3FreeDecoder(decoder);
10521055
return true;
10531056
}
1057+
#endif
10541058

10551059
#endif /* SOC_I2S_SUPPORTED */

libraries/ESP_I2S/src/ESP_I2S.h

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#pragma once
22

3+
#if defined __has_include && __has_include("mp3dec.h")
4+
#define ARDUINO_HAS_MP3_DECODER 1
5+
#endif
6+
37
#include "soc/soc_caps.h"
48
#if SOC_I2S_SUPPORTED
59

@@ -85,8 +89,10 @@ class I2SClass : public Stream {
8589
uint8_t *recordWAV(size_t rec_seconds, size_t *out_size);
8690
// Play short PCM WAV from memory
8791
void playWAV(uint8_t *data, size_t len);
92+
#if ARDUINO_HAS_MP3_DECODER
8893
// Play short MP3 from memory
8994
bool playMP3(uint8_t *src, size_t src_len);
95+
#endif
9096

9197
private:
9298
esp_err_t last_error;

libraries/ESPmDNS/src/ESPmDNS.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ License (MIT license):
3939
#endif
4040

4141
#include "ESPmDNS.h"
42+
#ifdef CONFIG_MDNS_MAX_INTERFACES
4243
#include <functional>
4344
#include "esp_mac.h"
4445
#include "soc/soc_caps.h"
@@ -391,3 +392,5 @@ String MDNSResponder::txtKey(int idx, int txtIdx) {
391392
}
392393

393394
MDNSResponder MDNS;
395+
396+
#endif /* CONFIG_MDNS_MAX_INTERFACES */

libraries/ESPmDNS/src/ESPmDNS.h

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ License (MIT license):
4141
#ifndef ESP32MDNS_H
4242
#define ESP32MDNS_H
4343

44+
#include "sdkconfig.h"
45+
#ifdef CONFIG_MDNS_MAX_INTERFACES
46+
4447
#include "Arduino.h"
4548
#include "mdns.h"
4649
#include "esp_interface.h"
@@ -125,4 +128,5 @@ class MDNSResponder {
125128

126129
extern MDNSResponder MDNS;
127130

131+
#endif /* CONFIG_MDNS_MAX_INTERFACES */
128132
#endif //ESP32MDNS_H

libraries/LittleFS/src/LittleFS.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "LittleFS.h"
16+
17+
#ifdef CONFIG_LITTLEFS_PAGE_SIZE
1518
#include "vfs_api.h"
1619

1720
extern "C" {
1821
#include <sys/unistd.h>
1922
#include <sys/stat.h>
2023
#include <dirent.h>
21-
}
22-
#include "sdkconfig.h"
23-
#include "LittleFS.h"
24-
25-
#ifdef CONFIG_LITTLEFS_PAGE_SIZE
26-
extern "C" {
2724
#include "esp_littlefs.h"
2825
}
2926

@@ -125,4 +122,4 @@ size_t LittleFSFS::usedBytes() {
125122
}
126123

127124
LittleFSFS LittleFS;
128-
#endif
125+
#endif /* CONFIG_LITTLEFS_PAGE_SIZE */

libraries/LittleFS/src/LittleFS.h

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#ifndef _LITTLEFS_H_
1515
#define _LITTLEFS_H_
1616

17+
#include "sdkconfig.h"
18+
19+
#ifdef CONFIG_LITTLEFS_PAGE_SIZE
20+
1721
#include "FS.h"
1822

1923
namespace fs {
@@ -36,4 +40,5 @@ class LittleFSFS : public FS {
3640

3741
extern fs::LittleFSFS LittleFS;
3842

43+
#endif /* CONFIG_LITTLEFS_PAGE_SIZE */
3944
#endif

libraries/PPP/src/PPP.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define ARDUINO_CORE_BUILD
22
#include "PPP.h"
3-
#if CONFIG_LWIP_PPP_SUPPORT
3+
#if CONFIG_LWIP_PPP_SUPPORT && ARDUINO_HAS_ESP_MODEM
44
#include "esp32-hal-periman.h"
55
#include "esp_netif.h"
66
#include "esp_netif_ppp.h"

libraries/PPP/src/PPP.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#pragma once
22

33
#include "sdkconfig.h"
4-
#if CONFIG_LWIP_PPP_SUPPORT
4+
#if defined __has_include && __has_include("esp_modem_c_api_types.h")
5+
#define ARDUINO_HAS_ESP_MODEM 1
6+
#endif
7+
8+
#if CONFIG_LWIP_PPP_SUPPORT && ARDUINO_HAS_ESP_MODEM
59
#include "Network.h"
610
#include "esp_modem_c_api_types.h"
711

@@ -109,5 +113,4 @@ class PPPClass : public NetworkInterface {
109113
};
110114

111115
extern PPPClass PPP;
112-
113-
#endif /* CONFIG_LWIP_PPP_SUPPORT */
116+
#endif /* CONFIG_LWIP_PPP_SUPPORT && ARDUINO_HAS_ESP_MODEM */

libraries/PPP/src/ppp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "sdkconfig.h"
2-
#if CONFIG_LWIP_PPP_SUPPORT
2+
#if CONFIG_LWIP_PPP_SUPPORT && defined __has_include && __has_include("esp_modem_api.h")
33
#include "esp_modem_api.h"
44

55
esp_err_t _esp_modem_at(esp_modem_dce_t *dce_wrap, const char *at, char *p_out, int timeout) {

0 commit comments

Comments
 (0)