I am trying to do two things, get the output filename, and if possible have a build step thats just points to a zig function.
// Add Translate-C Process
var idf_sys = b.addTranslateC(.{
.target = target,
.optimize = optimize,
.root_source_file = .{
.cwd_relative = "station_example_main.c",
},
});
idf_sys.out_basename = "idf-out.zig";
It ends out as a different name in under zig-cache:
./.zig-cache/o/8e6cf1a8dbfca50b9546ca416e05382f/station_example_main.zig
I’ve added to my build lib step:
lib.step.dependOn(&idf_sys.step);
However even then I am not sure how to get the generate output and work on it from there. If I try to grab the output name i.e
std.debug.print("{s}\n", .{idf_sys.getOutput().generated.file.getPath()});
I’ll end up with the error:
thread 165328 panic: getPath() was called on a GeneratedFile that wasn't built yet. Is there a missing Step dependency on step 'translate-c'?
/home/joseph/Apps/zig-linux-x86_64-0.14.0-dev.3046+08d661fcf/lib/std/Build.zig:2444:75: 0x1413a6a in getPath (build)
return gen.step.owner.pathFromRoot(gen.path orelse std.debug.panic(
^
So I tried to just do a move file command:
const cli = &[_][]const u8{
"mv",
".zig-cache/**/*/station_example_main.zig",
"out.zig",
// "sed -i '/pub const wifi_sta_config_t = opaque {};/d' out.zig",
};
var idf_sys_patch = b.addSystemCommand(cli);
idf_sys_patch.step.dependOn(&idf_sys.step);
lib.step.dependOn(&idf_sys_patch.step);
But it seems like the glob pattern isn’t working? It works in the terminal. I’d also just rather get the resulting path anyways than a hacky solution. It would be great if its possible to just pipe the translate-c to a Zig function as a step and I work inside that function instead.