trouble using source_file macro in recipe.hooks.sketch.prebuild

I'm running 1.8.7 on a Linux box. I'm trying to use the recipe.hooks.sketch.prebuild.x.pattern to invoke a bash script pre-compile. I want to pass the sketch's pathname in to my bash script. Here's my recipe:

recipe.hooks.sketch.prebuild.1.pattern=/home/user/bin/myCmd "{source_file}"

(My bash script uses dirname to get the sketch's home folder and then writes a custom header file there with a unique serial number.)

myCmd runs fine but "{source_file}" is not interpreted, it is passed in verbatim, which of course makes no sense to my script.

To verify where the problem lies, I changed "{source_file}" to "{build.path}" - that worked! But of course, it's not the directory path I need.

The problem seems to be that "{source_file}" is not yet interpreted when the prebuild pattern is parsed. "{source_file}" is interpreted in subsequent lines in platform.txt.

I've tried moving my recipe line to different locations in platform.txt, putting it after other lines have interpreted "{source_file}", to no avail.

Anyone know how to get the IDE to interpret "{source_file}" in the prebuild recipe??

Replying to my own post ...

Digging around in build/shared/revisions.txt, I found this:

In platform.txt, pre and post build hooks can now be specified. Example: recipe.hooks.prebuild.0.pattern=echo "Hello {build.source.path}". Thanks @Wackerbarth

build.source.path works!! just tried it.

Thanks for taking the time to share your solution tjlynchny!

As you discovered, some properties can only be used in certain recipes. I wrote an explanation of why it couldn't be any other way for {source_file} here:

I wrote a dummy hardware package that allows you to see exactly where the various properties can be used: