You can achieve this by using the export
keyword to pass the environment variable through to a child process (bash, in this case), and then using the child process' ability to access environment variables to then run whatever script you want.
To do this, create a helper script:
#!/bin/bash
# bootstrap-script.sh
"${!1}/$2"
which takes the first argument passed to it, resolves it as a variable name, and then performs a replacement (where as the second argument is a direct replacement), and then run it from your Tupfile by using:
# Tupfile
export SCRIPT_DIR
run ./bootstrap-script.sh SCRIPT_DIR my_script.py
The above passes through SCRIPT_DIR
to the previously mentioned bootstrap script, along with a target script or program to run (in order to generate rules using Tup's run
keyword).