platformio / platform-espressif8266

Espressif 8266: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif8266
Apache License 2.0
323 stars 219 forks source link

build_cache_dir mostly ignored #174

Closed neophiliac closed 4 years ago

neophiliac commented 4 years ago

I'm building with both the IDE and the CLI, and I rarely see output about getting objects from the cache while building the arduino framework files for esp8266, but most of the time all of the framework files are recompiled every time. I have build_cache_dir set (and also PLATFORMIO_BUILD_CACHE_DIR) and the build_cache_dir subdirectories are populated with object files with every build.

The build log shows the object files being put in a local directory, e.g. .pio/build/debug_ota/FrameworkArduino/spiffs/spiffs_check.cpp.o (which is not the build_cache_dir). The files in the build_cache_dir directories have hashes for names. and new files are added to each subdirectory with each build.

I have run pio update && pio upgrade so everything is up to date, PlatformIO 4.0.3 on Ubuntu 19.04.

It seems like I must be missing something about using the build cache setting. Suggestions? Advice?

Thanks.

platformio.ini:

[platformio]
default_envs = debug_ota
build_cache_dir = /tmp/build_cache

[env]
platform = espressif8266
lib_extra_dirs = ~/Documents/Arduino/libraries
board = d1_mini
board_build.flash_mode = dout
framework = arduino
lib_deps=
  ArduinoJson@~5.13
  NtpClient
monitor_speed = 115200
monitor_baud = 115200
upload_speed = 256000

[env:production]
build_flags = 
  !echo "-DGIT_VERSION="$(git describe --tags --long)" -DBUILD_DATE="$(date +'%y%m%d-%H%M%S')" -DGIT_BUILDER="$(git config user.email)
  -Wl,-Map,linker.map
  -DDEBUG_ESP_PORT=Serial

[env:debug_ota]
build_flags = 
  !echo "-DGIT_VERSION="$(git describe --tags --long)" -DBUILD_DATE="$(date +'%y%m%d-%H%M%S')" -DGIT_BUILDER="$(git config user.email)
  -Wl,-Map,linker.map
  -DDEBUG_ESP_PORT=Serial
  -DDEBUG_ESP_SSL
  -DDEBUG_ESP_UPDATER
  -DDEBUG_ESP_OTA
mcspr commented 4 years ago

See https://community.platformio.org/t/build-cache-dir-will-not-share-object-files-between-envs/10011 in the example above, you modify global build_flags = ..., so the ~/.pio/build/env-name dir is destroyed by the platformio build signature checks as far as I understood it, at this time different envs will not share build cache because of the different paths used by the two different environments and a different contents of source files (ref: https://scons.org/doc/latest/HTML/scons-api/SCons.CacheDir-pysrc.html, signature calculation via https://scons.org/doc/latest/HTML/scons-api/SCons.Node.FS-pysrc.html#File.get_cachedir_bsig). If you delete the .pio/build/env-name and try to build it again without dynamic flags, it will use the cache. edit: sorry for the confusion between scons and pio actions, since pio itself also tracks source files + .ini

maybe this issue should be moved to platformio/platformio-core?

neophiliac commented 4 years ago

Yes, it's probably a platformio-core issue. Sorry for leaving this in the wrong place. I'll read the docs you linked before I do that though.

Thanks.

LordMike commented 1 year ago

For future readers. I've made this issue with platformio: https://github.com/platformio/platformio-core/issues/4574

ivankravets commented 1 year ago

-DBUILD_DATE="$(date +'%y%m%d-%H%M%S')"

This is the issue that triggers recompilation. The macro value changes on each build.

LordMike commented 1 year ago

Ooh. Ignore my interpretation then for this issue. :)