I’ve read-up on SCons and created a really straightforward extra_script, but whatever I do I can’t get either of the Command
s to actually run!:
import os
Import("env")
release_dir = "releases"
def create_release(target, source, env):
print("target=%s, source=%s" % (target[0], source[0]))
firmware_version = env.GetProjectOption("custom_build_number")
tag = env['PIOENV']
release_file = env.Command(
os.path.join(release_dir, tag + "_" + source[0].name),
source[0],
action=[
Mkdir(release_dir),
Copy("$TARGET", "$SOURCE"),
sayHi
])
print("release_file[0] is %s" % release_file[0])
release_descriptor = env.Command(
os.path.join(release_dir, tag + ".json"),
release_file,
sayHi)
def sayHi():
print("Hi")
script_action = env.AddCustomTarget(
"create_release",
["$BUILD_DIR/${PROGNAME}.bin"],
create_release,
title="Create Release",
description="Deploy to release folder and create descriptor file",
always_build=True,
)
The extra_script is being found just fine, and the print
calls are running as the script is parsed, because the output (snipped) is:
rebuilding `checkprogsize' because AlwaysBuild() is specified
Retrieving maximum program size .pio/build/bench_test/firmware_2.4.elf
Checking size .pio/build/bench_test/firmware_2.4.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 11.5% (used 37836 bytes from 327680 bytes)
Flash: [======= ] 71.0% (used 1488093 bytes from 2097152 bytes)
rebuilding `create_release' because AlwaysBuild() is specified
create_release(["create_release"], [".pio/build/bench_test/firmware_2.4.bin"])
target=create_release, source=.pio/build/bench_test/firmware_2.4.bin
release_file[0] is releases/bench_test_firmware_2.4.bin
But the directory is never created, the file is never copied and - as you can see above - the sayHi()
method doesn’t ever get called.
Where am I going wrong? I’ve tried setting Default, Alias, Depends and any number of other things - but my SCons commands are never run, the build just finishes Please help!
(I should add that I’ve got a pre:
script appending the _2.4
to the PROGNAME as per one of the examples in the docs, and the file does get compiled just fine)