i'm attempting to generate a config header for a C app, and in my build.zig i have my include_path in my ConfigHeaderStep.Options setup in a way so that even if a build.zig from a parent folder includes this build.zig, it still all works out and goes to the right folder
var relative_path = try std.fs.path.relative(allocator, try std.fs.cwd().realpathAlloc(allocator, "."), root_path ++ "include/DPLBuildConfiga.h");
std.debug.print("relative path {s}\n", .{relative_path});
var config_header: *std.build.ConfigHeaderStep = b.addConfigHeader(std.build.ConfigHeaderStep.Options{
.style = .blank,
.include_path = relative_path,
}, .{
...
/// Finds the root of the project
fn root() []const u8 {
return std.fs.path.dirname(@src().file) orelse @panic("Unable to get the directory name of the build.zig file!");
}
/// The root path of the project
const root_path = root() ++ "/";
but this causes a segfault because my arena allocator gets deinit'd at the end of the build() scope, and the compiler then tries to use that memory afterward, is the solution to just not free the memory since its a short build func and doesnt matter?