authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-01 13:08:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
loga7754d219a60fdc15d3bff0d6d2ac7fee9f7c4db
treedbfd7da3d5af3afba973256d8c794964021996cd
parente895d582143f74c9e3a2d06083017e74ad67b770

build system: better default name for ConfigHeaderStep


1 files changed, 23 insertions(+), 16 deletions(-)

lib/std/Build/ConfigHeaderStep.zig+23-16
...@@ -51,10 +51,30 @@ pub const Options = struct {...@@ -51,10 +51,30 @@ pub const Options = struct {
5151
52pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep {52pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep {
53 const self = builder.allocator.create(ConfigHeaderStep) catch @panic("OOM");53 const self = builder.allocator.create(ConfigHeaderStep) catch @panic("OOM");
54
55 var include_path: []const u8 = "config.h";
56
57 if (options.style.getFileSource()) |s| switch (s) {
58 .path => |p| {
59 const basename = std.fs.path.basename(p);
60 if (std.mem.endsWith(u8, basename, ".h.in")) {
61 include_path = basename[0 .. basename.len - 3];
62 }
63 },
64 else => {},
65 };
66
67 if (options.include_path) |p| {
68 include_path = p;
69 }
70
54 const name = if (options.style.getFileSource()) |s|71 const name = if (options.style.getFileSource()) |s|
55 builder.fmt("configure {s} header {s}", .{ @tagName(options.style), s.getDisplayName() })72 builder.fmt("configure {s} header {s} to {s}", .{
73 @tagName(options.style), s.getDisplayName(), include_path,
74 })
56 else75 else
57 builder.fmt("configure {s} header", .{@tagName(options.style)});76 builder.fmt("configure {s} header to {s}", .{@tagName(options.style), include_path});
77
58 self.* = .{78 self.* = .{
59 .builder = builder,79 .builder = builder,
60 .step = Step.init(builder.allocator, .{80 .step = Step.init(builder.allocator, .{
...@@ -67,23 +87,10 @@ pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep {...@@ -67,23 +87,10 @@ pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep {
67 .values = std.StringArrayHashMap(Value).init(builder.allocator),87 .values = std.StringArrayHashMap(Value).init(builder.allocator),
6888
69 .max_bytes = options.max_bytes,89 .max_bytes = options.max_bytes,
70 .include_path = "config.h",90 .include_path = include_path,
71 .output_file = .{ .step = &self.step },91 .output_file = .{ .step = &self.step },
72 };92 };
7393
74 if (options.style.getFileSource()) |s| switch (s) {
75 .path => |p| {
76 const basename = std.fs.path.basename(p);
77 if (std.mem.endsWith(u8, basename, ".h.in")) {
78 self.include_path = basename[0 .. basename.len - 3];
79 }
80 },
81 else => {},
82 };
83
84 if (options.include_path) |include_path| {
85 self.include_path = include_path;
86 }
8794
88 return self;95 return self;
89}96}