diff --git a/code/espurna/config/all.h b/code/espurna/config/all.h index dfa31e3f..36442202 100644 --- a/code/espurna/config/all.h +++ b/code/espurna/config/all.h @@ -34,3 +34,5 @@ #ifdef USE_CORE_VERSION_H #include "core_version.h" #endif + +#include "build.h" diff --git a/code/espurna/config/build.h b/code/espurna/config/build.h new file mode 100644 index 00000000..04cd6f8d --- /dev/null +++ b/code/espurna/config/build.h @@ -0,0 +1,3 @@ +// DO NOT EDIT THIS FILE MANUALLY +// This file is modified by PlatformIO +#define APP_BUILD_FLAGS "-g -DMQTT_MAX_PACKET_SIZE=400 -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH" \ No newline at end of file diff --git a/code/espurna/mdns.ino b/code/espurna/mdns.ino index c82f328a..be9ea215 100644 --- a/code/espurna/mdns.ino +++ b/code/espurna/mdns.ino @@ -67,6 +67,9 @@ void mdnsServerSetup() { itoa(ESP.getFreeSketchSpace(), buffer, 10); MDNS.addServiceTxt("arduino", "tcp", "free_space", (const char *) buffer); } + #ifdef APP_BUILD_FLAGS + //MDNS.addServiceTxt("arduino", "tcp", "build_flags", APP_BUILD_FLAGS); + #endif wifiRegister([](justwifi_messages_t code, char * parameter) { diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 467c4bd9..8f8566e6 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -252,6 +252,9 @@ void info() { // ------------------------------------------------------------------------- + #ifdef APP_BUILD_FLAGS + DEBUG_MSG_P(PSTR("[INIT] BUILD_FLAGS: %s\n"), APP_BUILD_FLAGS); + #endif DEBUG_MSG_P(PSTR("[INIT] BOARD: %s\n"), getBoardName().c_str()); DEBUG_MSG_P(PSTR("[INIT] SUPPORT:")); diff --git a/code/extra_scripts.py b/code/extra_scripts.py index c981db86..43e54ec4 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -39,8 +39,21 @@ def check_size(source, target, env): # print clr(Color.LIGHT_RED, "File too large for OTA!") # Exit(1) +def add_build_flags(source, target, env): + build_h = "espurna/config/build.h" + build_flags = env['BUILD_FLAGS'][0] + lines = open(build_h).readlines() + with open(build_h, "w") as fh: + for line in lines: + if "APP_BUILD_FLAGS" in line: + fh.write("#define APP_BUILD_FLAGS \"%s\"" % build_flags) + else: + fh.write(line) + + # ------------------------------------------------------------------------------ # Hooks # ------------------------------------------------------------------------------ +env.AddPreAction("$BUILD_DIR/src/espurna.ino.o", add_build_flags) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)