mobizt / ESP-Mail-Client

The comprehensive Arduino Email Client Library to send and read Email for Arduino devices. The library also supports other network shields or modules e.g., Wi-Fi, Ethernet, and GSM/4G modules.

Home Page:https://mobizt.github.io/ESP-Mail-Client/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile flags and not unsets

guestisp opened this issue · comments

Please use compile flags (like -D ENABLE_IMAP) and not "everything enabled and just disable what you want by editing a core file) to set which component has to be incuded.

This would be much easier for platformio users. Also, it's impossible to include Custom_ESP_Mail_FS.h in the same directory as ESP_Mail_FS.h if you are using a library manager like platformio, because the ESP_Mail_FS.h is outside the project directory.

So:

A. please use compile flag so that we can choose what to compile, by chaging the platformio config file
B. please don't search for Custom_ESP_Mail_FS.h in the same directory of ESP_Mail_FS.h but use the project directory. (but solution "A" is much better)

Did you try it?

In platformio.ini file, you can use build_flags option to do the same as in ESP_Mail_FS.h like this

build_flags = -DENABLE_IMAP
              -DENABLE_SMTP

And use build_unflags to remove definitions.

build_unflags = -DENABLE_IMAP
              -DENABLE_SMTP    

The library config file should be placed in the library installation folder as it exposed the default configuration definitions to user and user can edit it via user defined config file Custom_ESP_Mail_FS.h.

Please note that, the library works for different IDE and CLI included Arduino IDE which user have to edit boards.txt file to add extra build flags in Arduino IDE which is not easy as in PlatformIO which platformio.ini is already in your project folder.

Yes, tried and build size is always the same regardless build_unflgas


build_unflags =
	-D ENABLE_IMAP
	-D ESP_MAIL_DEFAULT_SD_FS
	-D ESP_MAIL_DEFAULT_FLASH_FS
	-D ENABLE_NTP_TIME

i would expect a much smaller library, but the firmware is always the same.

Update:

Use build flags -D and -U can't take effect when that preprocessor macros are already defined.

You should remove preprocessor macro from ESP_Mail_FS.h then you can use build flags to def and undef.

If you use PlatformIO, please read PlatformIO documentation first.

-D followed by preprocessor name without space.

The goal is to NOT customize library files, because they aren't easily available in platformio. libs are outside the project and handled by pio itself. That' why i've asked for something that doesn't enable everything by default because it's hard to disable when you need to strip down the libraary

It's not possible as this is not a single header library that the config file is commonly used by other headers.

You can fork the library to work in your customization version.

By default, in ESP_Mail_FS.h file it can be only following.

#include <FS.h> //<- use in v3.4.0
#define ESP_MAIL_DEFAULT_DEBUG_PORT Serial

Forking is what i'll do if i can't use the build_flag/unflag from pio