I am attempting to create a post:extra_script.py file that creates a symlink to the compiled program in the build directory.
I know that the environment variable I want is called PROJECT_DIR but I cannot figure out how to grab it.
This is what I have at the moment:
from pathlib import Path
Import("env", "projenv")
# Dump construction environment (for debug purpose)
# print(env.Dump())
# Dump project construction environment (for debug purpose)
# print(projenv.Dump())
print("Current CLI targets", COMMAND_LINE_TARGETS)
print("Current Build targets", BUILD_TARGETS)
def post_program_action(source, target, env):
print("Program has been built!")
program_path = target[0].get_abspath()
print("Program path = ", program_path)
# Use case: sign a firmware, do any manipulations with ELF, etc
# env.Execute(f"sign --elf {program_path}")
project_path = source[0].get_abspath()
print("Project path = ", project_path)
p = Path(PROJECT_DIR + "/TestTarget")
p.unlink()
p.symlink_to(program_path)
env.AddPostAction("$PROGPATH", post_program_action)
Comments or suggestions are greatly appreciated!