mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
std.Build.Step.ConfigHeader: fix C and NASM
This commit is contained in:
parent
9562dcc99b
commit
afbfa67c9a
1 changed files with 14 additions and 2 deletions
|
|
@ -15,6 +15,8 @@ pub const Style = union(enum) {
|
||||||
cmake: std.Build.LazyPath,
|
cmake: std.Build.LazyPath,
|
||||||
/// Start with input file and replace occurrences of names with their values.
|
/// Start with input file and replace occurrences of names with their values.
|
||||||
custom: std.Build.LazyPath,
|
custom: std.Build.LazyPath,
|
||||||
|
/// Start with input file like custom, and output a nasm .asm file.
|
||||||
|
custom_nasm: std.Build.LazyPath,
|
||||||
/// Instead of starting with an input file, start with nothing.
|
/// Instead of starting with an input file, start with nothing.
|
||||||
blank,
|
blank,
|
||||||
/// Start with nothing, like blank, and output a nasm .asm file.
|
/// Start with nothing, like blank, and output a nasm .asm file.
|
||||||
|
|
@ -22,7 +24,7 @@ pub const Style = union(enum) {
|
||||||
|
|
||||||
pub fn getPath(style: Style) ?std.Build.LazyPath {
|
pub fn getPath(style: Style) ?std.Build.LazyPath {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
.autoconf_undef, .autoconf_at, .cmake, .custom => |s| return s,
|
.autoconf_undef, .autoconf_at, .cmake, .custom, .custom_nasm => |s| return s,
|
||||||
.blank, .nasm => return null,
|
.blank, .nasm => return null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -240,7 +242,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
||||||
try render_nasm(bw, config_header.values);
|
try render_nasm(bw, config_header.values);
|
||||||
},
|
},
|
||||||
.custom => |file_source| {
|
.custom => |file_source| {
|
||||||
try bw.writeAll(asm_generated_line);
|
try bw.writeAll(c_generated_line);
|
||||||
const src_path = file_source.getPath2(b, step);
|
const src_path = file_source.getPath2(b, step);
|
||||||
const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
|
const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
|
||||||
return step.fail("unable to read custom input file '{s}': {s}", .{
|
return step.fail("unable to read custom input file '{s}': {s}", .{
|
||||||
|
|
@ -249,6 +251,16 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
||||||
};
|
};
|
||||||
try render_custom(step, contents, bw, config_header.values);
|
try render_custom(step, contents, bw, config_header.values);
|
||||||
},
|
},
|
||||||
|
.custom_nasm => |file_source| {
|
||||||
|
try bw.writeAll(asm_generated_line);
|
||||||
|
const src_path = file_source.getPath2(b, step);
|
||||||
|
const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| {
|
||||||
|
return step.fail("unable to read custom NASM input file '{s}': {s}", .{
|
||||||
|
src_path, @errorName(err),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
try render_custom(step, contents, bw, config_header.values);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = aw.written();
|
const output = aw.written();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue