this snippets keeps my output file in my output folder, and the other one doesn’t, I don’t know why:
// Results files are availlable:
runModeExeStep.addArg("results");
runModeExeStep.addArg(fullName);
runModeExeStep.addArg(outName);
// No more results :(
runModeExeStep.addArg("results");
runModeExeStep.addFileArg(b.path(fullName));
_ = runModeExeStep.addOutputFileArg(outName);
Is this a feature or a bug ?
What is the value of outName?
I think what is going on here is that addOutputFileArg is passing a path to the build cache. It will be written in zig-cache for the build step. In order for it to be in your output folder, you will need to take the LazyPath that it provides and b.addInstallFile to add that file to the installation directory (typicall a local zig-out folder).
Without knowing more about where you want the file to be placed. it’s hard to help further.
2 Likes
yes that’s exactly it. the argument is just the last component of the path
If you want to write the file not to the install directory, but to your sources (for example to manually update some file you want to commit to source control and use with b.path() in another step), you can create a UpdateSourceFiles step using b.addUpdateSourceFiles() and pass the output of addOutputFileArg to it’s addCopyFileToSource function, and then create a custom top level step to run it:
runModeExeStep.addArg("results");
runModeExeStep.addFileArg(b.path(fullName));
const outfile = runModeExeStep.addOutputFileArg(outName);
const update_src = b.addUpdateSourceFiles()
update_src.addCopyFileToSource(outfile, "path/in/sources")
b.step("update-source", "description").dependOn(&update_src.step);
and then you can run zig build update-source to regenerate the file.
Well, It was more important for me to check the content of the files, than having them at a specific place. That was all I needed to check the intermediary steps of my pipeline, thanks ! Watching it traverse the whole graph is mesmerizing !