Skip to content

Commit afbfa67

Browse files
committed
std.Build.Step.ConfigHeader: fix C and NASM
1 parent 9562dcc commit afbfa67

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/std/Build/Step/ConfigHeader.zig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ pub const Style = union(enum) {
1515
cmake: std.Build.LazyPath,
1616
/// Start with input file and replace occurrences of names with their values.
1717
custom: std.Build.LazyPath,
18+
/// Start with input file like custom, and output a nasm .asm file.
19+
custom_nasm: std.Build.LazyPath,
1820
/// Instead of starting with an input file, start with nothing.
1921
blank,
2022
/// Start with nothing, like blank, and output a nasm .asm file.
2123
nasm,
2224

2325
pub fn getPath(style: Style) ?std.Build.LazyPath {
2426
switch (style) {
25-
.autoconf_undef, .autoconf_at, .cmake, .custom => |s| return s,
27+
.autoconf_undef, .autoconf_at, .cmake, .custom, .custom_nasm => |s| return s,
2628
.blank, .nasm => return null,
2729
}
2830
}
@@ -240,7 +242,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
240242
try render_nasm(bw, config_header.values);
241243
},
242244
.custom => |file_source| {
243-
try bw.writeAll(asm_generated_line);
245+
try bw.writeAll(c_generated_line);
244246
const src_path = file_source.getPath2(b, step);
245247
const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
246248
return step.fail("unable to read custom input file '{s}': {s}", .{
@@ -249,6 +251,16 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
249251
};
250252
try render_custom(step, contents, bw, config_header.values);
251253
},
254+
.custom_nasm => |file_source| {
255+
try bw.writeAll(asm_generated_line);
256+
const src_path = file_source.getPath2(b, step);
257+
const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
258+
return step.fail("unable to read custom NASM input file '{s}': {s}", .{
259+
src_path, @errorName(err),
260+
});
261+
};
262+
try render_custom(step, contents, bw, config_header.values);
263+
},
252264
}
253265

254266
const output = aw.written();

0 commit comments

Comments
 (0)