mirror of
https://github.com/ziglang/zig.git
synced 2026-01-16 04:15:22 +00:00
build system: better default name for ConfigHeaderStep
This commit is contained in:
parent
e895d58214
commit
a7754d219a
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user