PlatformIO Community

Problem with 'extra_scripts'

I am getting the following messages when trying to build at project with pre-hooks, anyone know what the meaning is?:

warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=False to SConscript calls.
Missing SConscript ''
File "C:\Users\niels\.platformio\penv\lib\site-packages\platformio\builder\", line 179, in <module>


default_envs = nodemcu-32s

platform = espressif32
framework = espidf
;platform =
board = nodemcu-32s
board_upload.flash_size = 4MB
board_upload.maximum_size = 4194304
board_build.partitions = ESP32_OTA_4M.csv
board_build.embed_files = src/cert/ca_cert.pem
monitor_speed = 115200
debug_tool = olimex-arm-usb-ocd-h
debug_speed = 8000
build_flags = -DCORE_DEBUG_LEVEL=5
extra_scripts = (placed in the src dir):

import subprocess

Import("env", "projenv")

def get_firmware_specifier_build_flag():
    #ret =["git", "describe"], stdout=subprocess.PIPE, text=True) #Uses only annotated tags
    ret =["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True) #Uses any tags

    build_version = ret.stdout.strip()
    build_flag = "-D AUTO_VERSION=\\\"" + build_version + "\\\""
    print ("Firmware Revision: " + build_version)
    return (build_flag)

env.Append( BUILD_FLAGS=[get_firmware_specifier_build_flag()])

Should be in the root of project, or change to extra_scripts = pre:src/

@ivankravets Thanks that did it!
So for clarity, the messages actually meant that the script was “nowhere to be found”?

Just so you’re aware, in my experience, dynamically defining things on each build will result in riddiculous build times since the define change will also be applied to all the core files (or at least this happens with Arduino) and no cached object files will be reused since the compiler doesn’t know where the changed define is used necessarily.

I would instead recommend you dynamically create a firmware_version.h file and only include that where you need it