| ... | @@ -51,10 +51,30 @@ pub const Options = struct { | ... | @@ -51,10 +51,30 @@ pub const Options = struct { |
| 51 | | 51 | |
| 52 | pub fn create(builder: *std.Build, options: Options) *ConfigHeaderStep { | 52 | pub 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 | else | 75 | 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), |
| 68 | | 88 | |
| 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 | }; |
| 73 | | 93 | |
| 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 | } | | |
| 87 | | 94 | |
| 88 | return self; | 95 | return self; |
| 89 | } | 96 | } |