fix build system
This commit is contained in:
parent
619332a96e
commit
54601e4422
1 changed files with 13 additions and 5 deletions
|
@ -47,18 +47,26 @@ fn make(step: *std.Build.Step, _: *std.Progress.Node) !void {
|
||||||
|
|
||||||
// Read input
|
// Read input
|
||||||
const inputPath = self.path.getPath2(b, step);
|
const inputPath = self.path.getPath2(b, step);
|
||||||
const input = try std.fs.cwd().openFile(inputPath, .{});
|
const input = try std.fs.openFileAbsolute(inputPath, .{});
|
||||||
defer input.close();
|
defer input.close();
|
||||||
|
|
||||||
// Get output path or calculate it from the input
|
// Create output file next to input
|
||||||
const name = self.options.filename orelse calculateOutputName(b, std.fs.path.basename(inputPath));
|
// We could create this directly in its final place but the directory usually
|
||||||
const destination = b.getInstallPath(self.options.installDir, name);
|
// does not exist at that time and this saves us some fs.makePath shenanigans
|
||||||
|
const name = calculateOutputName(b, inputPath);
|
||||||
|
|
||||||
// Create output file
|
// Create output file
|
||||||
const output = try std.fs.cwd().createFile(destination, .{});
|
const output = try std.fs.createFileAbsolute(name, .{});
|
||||||
defer output.close();
|
defer output.close();
|
||||||
|
|
||||||
|
// Run conversion
|
||||||
try lib.convert(input, output);
|
try lib.convert(input, output);
|
||||||
|
|
||||||
|
// Copy file to destination
|
||||||
|
const cwd = std.fs.cwd();
|
||||||
|
const finalFilename = self.options.filename orelse std.fs.path.basename(name);
|
||||||
|
const destination = b.getInstallPath(self.options.installDir, finalFilename);
|
||||||
|
_ = try cwd.updateFile(name, cwd, destination, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculateOutputName(b: *std.Build, path: []const u8) []const u8 {
|
fn calculateOutputName(b: *std.Build, path: []const u8) []const u8 {
|
||||||
|
|
Loading…
Reference in a new issue