From a7754d219a60fdc15d3bff0d6d2ac7fee9f7c4db Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 1 Mar 2023 13:08:53 -0700 Subject: [PATCH] build system: better default name for ConfigHeaderStep --- lib/std/Build/ConfigHeaderStep.zig | 39 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/std/Build/ConfigHeaderStep.zig b/lib/std/Build/ConfigHeaderStep.zig index c74c03718e..994b71da32 100644 --- a/lib/std/Build/ConfigHeaderStep.zig +++ b/lib/std/Build/ConfigHeaderStep.zig @@ -51,10 +51,30 @@ pub const Options = struct { pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep { const self = builder.allocator.create(ConfigHeaderStep) catch @panic("OOM"); + + var include_path: []const u8 = "config.h"; + + if (options.style.getFileSource()) |s| switch (s) { + .path => |p| { + const basename = std.fs.path.basename(p); + if (std.mem.endsWith(u8, basename, ".h.in")) { + include_path = basename[0 .. basename.len - 3]; + } + }, + else => {}, + }; + + if (options.include_path) |p| { + include_path = p; + } + const name = if (options.style.getFileSource()) |s| - builder.fmt("configure {s} header {s}", .{ @tagName(options.style), s.getDisplayName() }) + builder.fmt("configure {s} header {s} to {s}", .{ + @tagName(options.style), s.getDisplayName(), include_path, + }) else - builder.fmt("configure {s} header", .{@tagName(options.style)}); + builder.fmt("configure {s} header to {s}", .{@tagName(options.style), include_path}); + self.* = .{ .builder = builder, .step = Step.init(builder.allocator, .{ @@ -67,23 +87,10 @@ pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep { .values = std.StringArrayHashMap(Value).init(builder.allocator), .max_bytes = options.max_bytes, - .include_path = "config.h", + .include_path = include_path, .output_file = .{ .step = &self.step }, }; - if (options.style.getFileSource()) |s| switch (s) { - .path => |p| { - const basename = std.fs.path.basename(p); - if (std.mem.endsWith(u8, basename, ".h.in")) { - self.include_path = basename[0 .. basename.len - 3]; - } - }, - else => {}, - }; - - if (options.include_path) |include_path| { - self.include_path = include_path; - } return self; }