Hi,
For my pre_script I need a way to check if the project will be rebuilt or not. With GNU make, it was possible to run “make --question all” and check the result.
Is there a way to check that in pre script?
The idea is to have a .py script which will increment the build version ONLY when the project is actually rebuilt. I saw some implementations for auto-increment, but all of them increment the version even when no changes were made to the project.
Thanks.
So stuff like https://github.com/sblantipodi/platformio_version_increment does not work?
Can you provide a minimal project that reproduces the problem with a given auto-increment script?
Hi Maximilian,
Here is a minimal project.
In current implementation, the version will increment on every build, even if NOTHING changed.
What I need, is a way to detect if SCons will actually build the project, or not. This way I can decide if version should be incremented or not. With GNU Make, this is done with - -question parameter
Expected behavior:
- Clean project
- Build project → Version is incremented
- Build project again → Version stays the same.
Thanks.
Sorry, forgot to push. It’s there now.
Have you tried wrapping the code that generates the new version file in a function and using that as a callback to the post action to build prog or before upload per Pre & Post Actions — PlatformIO latest documentation?
I tried your idea, but there seems to be a bug in PIO, or I’ missing something. I’ve updated the Git.
When building, the function is called as post, and not pre.
Here is a Build log:
Executing task in folder version-inc-test: C:\Users\popai\.platformio\penv\Scripts\platformio.exe run
Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (4.2.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.1.0
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\uno\src\main.cpp.o
Linking .pio\build\uno\firmware.elf
post_program_action([".pio\build\uno\firmware.elf"], [".pio\build\uno\src\main.cpp.o"])
Program has been built!
Program path D:\repos\version-inc-test\.pio\build\uno\firmware.elf
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 10.0% (used 204 bytes from 2048 bytes)
Flash: [ ] 4.7% (used 1508 bytes from 32256 bytes)
Building .pio\build\uno\firmware.hex
version_increment(["buildprog"], [".pio\build\uno\firmware.hex"])
version increment
Version String: 1.0.8
Major Version: 1
Minor Version: 0
Build Version: 8
Build timestamp: 2023-09-14 19:33:21
What did I miss?
Thanks.