Run an artifact with a dependency on a file as a run step

Hi, I’m working on upgrading a [program] packaged(https://codeberg.org/AlexBlais/stlink) with Zig 0.16.0 to Zig 0.17.0.

To compile the st-flash program, you used to be required to define a macro that has the path to a chips directory which contains information needed to flash a microcontroller properly. I used to use b.install_prefix in the Zig 0.16.0 version. I wasn’t able to do something similar in the Zig 0.17.0, I’m guessing it’s caused by the maker and configurer process separation which makes the install prefix not known at configure time.

Luckily, the original stlink project added a commit to make it resolve that directory at runtime (it looks at ../share/other/stuff/chips which solves my usecase.

However, I’m running into another issue. My package also exposes the compiled artifact so it can be used as part of a build step like so:

const stlink_dep = b.dependency("stlink", .{ .optimize = .safe });
const stflash = stlink_dep.artifact("st-flash");

const flash_mcu = b.addRunArtifact(stflash);
flash_mcu.addArg("write");
flash_mcu.addFileArg(firmware);
flash_mcu.addArg("0x08000000");

This used to work correctly, but now, the program fails to find it’s required chips directory.
I’ve tracked down the issue to the Build.addInstallDirectory function which is used to install the chips from the source to prefix/share/....
In Zig 0.16.0, that directory used to be installed in .zig-cache/i/... and the st-flash executable could find it because it had it’s absolute path.
In Zig 0.17.0, that directory is installed in the prefix and the executable is at .zig-cache/o/{hash}/st-flash and so cannot find the chips directory with the usual relative path.

So it comes down to this: How can I run a compiled artifact that has a dependency on a directory with a fixed relative path to that artifact? I’d also prefer if it didn’t pollute the installed files of the main project.

Thanks!