Always fully rebuilding the project and libraries

Hi All,
I know this has been brought up numerous times before but there doesn’t seem to be a definitive answer.

Below is my config:

  • Win10 (64Bit)
  • VSCode 1.63.2
  • PlatformIO Core 5.2.4, Home 3.4.0
  • Python 3.10.2 (64Bit)

platformio.ini
;====================================================================

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = COM3
upload_speed = 921600
monitor_port = COM3
monitor_speed = 115200
lib_deps =
    mcxiaoke/ESPDateTime@^0.2.0
    mr-glt/SHA-1 Hash@^1.1.0
    arduino-libraries/Arduino_JSON@^0.1.0
    me-no-dev/ESP Async WebServer@^1.2.3
    bblanchon/ArduinoJson@^6.18.0
    ayushsharma82/WebSerial@^1.2.0
    adafruit/Adafruit SSD1306@^2.4.6
    adafruit/Adafruit BusIO@^1.9.3
    adafruit/Adafruit GFX Library@^1.10.12
    adafruit/RTClib@^1.14.1
; Set/override default options for each "[env:***]"
build_flags =
    -D CURRENT_TIME=$UNIX_TIME
    -D BUILD_ENV_NAME="$PIOENV"
    -D PROJECT_DIR=$PIOHOME_DIR
    -DCOMPILE_UNIX_TIME=$UNIX_TIME
    ; Below required for colored log_* information
    -DCORE_DEBUG_LEVEL=5
    -DCONFIG_ARDUHAL_LOG_COLORS=1
    ;-Werror=unused-variable            ; https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

    ; PSRAM definitions and fixes
    ;-DBOARD_HAS_PSRAM
    ;-mfix-esp32-psram-cache-issue
;extra_scripts = pre:inject_path.py
monitor_flags = --raw
;board_build.partitions = default_8MB.csv
;====================================================================

With ALL workspace file edit windows closed, performing a build takes 138 seconds, at times up to 173 seconds.
All project files and library files are being rebuilt.

Archiving .pio\build\esp32dev\lib10d\libWebSerial.a
Compiling .pio\build\esp32dev\libb58\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\esp32dev\libb58\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
Compiling .pio\build\esp32dev\libb58\Adafruit GFX Library\Adafruit_SPITFT.cpp.o

project.checksum remains unchanged
d8a41d17e7c3d97829c6e3c925738becb465d1e6

How do I stop it from performing a full rebuild all of the time?

On a side question:
I have seen other computers performing a background compile of saved project files. E.g. I change fred.cpp and fred.h, go back to editing main.cpp and in the background, it is compiling fred.*.
Is there a switch/option to turn this functionality ON?

Thanks,
Neil.

Since you inject the unix time into the build which always changes per second, and thus a global macro changes, there will be a global full rebuild every time.

If you don’t need an accurate time for every build, just create a two [env:...] in which one has CURRENT_TIME set to a constant value and the other one has $UNIX_TIME.

2 Likes

Thanks Max,
After discovering this, it turns out that I am better off using “__TIMESTAMP__” in my code as opposed to CURRENT_TIME.
__TIMESTAMP__” does not cause a full rebuild every time.

For anyone that may be interetsed, I call the below two functions at the start and end of my setup code -

// The below six lines are required for building of the BUILD_ENV_NAME. Don't understand why but!!!
#ifndef ST
#define ST(A) #A
#endif
#ifndef STR
#define STR(A) ST(A)
#endif

#define FIRMWARE "Sensor_Int"
#define VERSION  "B.2 2022-01-19"
#define AUTHOR   "Joe.Smith"

void SignOnStart(){
    Debug.print("\n\n");
    Debug.printf("\033[1;33m"); // Yellow       https://en.wikipedia.org/wiki/ANSI_escape_code
    Debug.printf("========================================\n");
    Debug.printf("FIRMWARE : %s\n",FIRMWARE);
    Debug.printf("VERSION  : %s\n",VERSION);
    Debug.printf("AUTHOR   : %s\n",AUTHOR);
    Debug.printf("PATH     : %s\n",PROJECT_PATH);
    Debug.printf("ENVIRO   : %s\n",STR(BUILD_ENV_NAME));
    Debug.printf("DATE     : %s\n",__TIMESTAMP__);
    Debug.print("----------------------------------------\n");
    Debug.printf("Flash Chip Size = %d.0 (MBs)\n",ESP.getFlashChipSize()/1000000);
    Debug.printf("========================================\n");
    Debug.printf("\033[0m");  // Normal color      // https://en.wikipedia.org/wiki/ANSI_escape_code
}

void SignOnEnd(){
    Debug.printf("\033[1;33m"); // Yellow       https://en.wikipedia.org/wiki/ANSI_escape_code
    Debug.print("\n>> Set up Complete!!\n");
    Debug.printf("========================================\n");
    Debug.printf("\033[0m");  // Normal color      // https://en.wikipedia.org/wiki/ANSI_escape_code
    Debug.print("\n\n");
}
1 Like