feature. See also
. The project being documented here (as the example) is the Zig library itself.
ConfigHeader.create
pub fn create(owner: *std.Build, options: Options) *ConfigHeader
File
Code
pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
const graph = owner.graph;
const arena = graph.arena;
const wc = &graph.wip_configuration;
const config_header = graph.create(ConfigHeader);
const include_path: []const u8 = p: {
if (options.include_path) |p|
break :p graph.dupeString(p);
if (options.style.getPath()) |s| default: {
const sub_path = switch (s) {
.src_path => |sp| sp.sub_path,
.generated => break :default,
.cwd_relative => |sub_path| sub_path,
.relative => |r| r.sub_path,
.dependency => |dependency| dependency.sub_path,
};
const basename = Io.Dir.path.basename(sub_path);
if (std.mem.endsWith(u8, basename, ".h.in"))
break :p graph.dupeString(basename[0 .. basename.len - 3]);
}
break :p "config.h";
};
const name = if (options.style.getPath()) |s|
arena.print("configure {t} header {f} to {s}", .{ options.style, s, include_path }) catch @panic("OOM")
else
arena.print("configure {t} header to {s}", .{ options.style, include_path }) catch @panic("OOM");
config_header.* = .{
.step = .init(.{
.tag = base_tag,
.name = name,
.owner = owner,
.first_ret_addr = options.first_ret_addr orelse @returnAddress(),
}),
.style = options.style,
.input_size_limit = options.max_bytes,
.include_path = include_path,
.include_guard = if (options.include_guard) |s| .init(wc.addString(s) catch @panic("OOM")) else .none,
.generated_dir = graph.addGeneratedFile(&config_header.step),
};
if (options.style.getPath()) |s| {
s.addStepDependencies(&config_header.step);
}
return config_header;
}