We have several projects using espressif32 platform and we don’t update to the latest version automatically.
We are now running into a problem with a shared piece of code between projects which are build on version 1.12.4 and 3.2.0 where the signature of a method in the platform has changed.
I don;t want to update the 1.12.4 project just yet so I need to have a way to determine the current version of espressif32 platform that is being used.
Is there a define I can use in an #ifdef to realize that?
You can add a small extra-script that will inject the package versions as macros into the build system, which your code can then check against. See Injection of version of the computed libraries - #4 by maxgerhardt
I was wrong. If you include Arduino.h you also get the information from this file
So you can check the Arduino core version macros, which are very likely the cause of the build failure.
Are you hower sure you don’t want to enforce
platform = email@example.com so that everyone 100% guaranteed builds on the same basis? (Arduino core, platform code etc.)
Thanks for the answer, but those defines are part of the framework and not the platform
And I dont see tat file included in the framework i’m using …
Which framework are you using then? ESP-IDF?
platform = espressif32@~3.2.0
board = esp32dev
framework = arduino
Oh correct, the file I referenced really only exists the very latest, not-yet-released version.
Then I’d actually suggest
Added an advanced script, based on the link by @maxgerhardt
from platformio.builder.tools.piolib import PackageItem
from platformio.package.version import get_original_version
print("Adding platform and package version defines")
platform = env.PioPlatform()
used_packages = platform.dump_used_packages()
pkg_metadata = PackageItem(platform.get_dir()).metadata
platform_version = str(pkg_metadata.version if pkg_metadata else platform.version)
platform_version_split = platform_version.split(sep=".")
for package in used_packages:
pio_package_version = package["version"] # e.g. "1.70300.191015"
pio_package_name = package["name"] # e.g. "toolchain-atmelavr"
# can fail at decoding and return None if package version is not in semver format
# in these cases the pio package version is already the decoded version
# e.g. 1.70300.191015 => 7.3.0
# e.g. 5.1.0 => None
pio_decoded_version = get_original_version(pio_package_version)
name_converter = lambda name: name.upper().replace(" ", "_").replace("-", "_")
print("PIO_PACKAGE_%s_PKG_VERSION=%s" % (name_converter(pio_package_name), "\\\"" + pio_package_version + "\\\""))
("PIO_PACKAGE_%s_PKG_VERSION" % name_converter(pio_package_name) , "\\\"" + pio_package_version + "\\\"")
if pio_decoded_version is not None:
print("PIO_PACKAGE_%s_DECODED_VERSION=%s" % (name_converter(pio_package_name), pio_decoded_version))
("PIO_PACKAGE_%s_DECODED_VERSION" % name_converter(pio_package_name) , "\\\"" + pio_decoded_version + "\\\"")