mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 10:45:48 +08:00
build.zig: metadata dependency on .git/logs/HEAD
This commit is contained in:
1 parent
597306838d
commit
4cfd256330
1 file changed
+3
-2
@@ -272,12 +272,13 @@ pub fn build(b: *std.Build) !void {
|
||||
const io = b.graph.io;
|
||||
const git_file = b.root.openFile(io, ".git", .{ .allow_directory = false }) catch |err| switch (err) {
|
||||
error.IsDir => {
|
||||
b.dependOnFileContents(b.path(".git/logs/HEAD"));
|
||||
b.dependOnFileMetadata(b.path(".git/logs/HEAD"));
|
||||
break :git;
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
defer git_file.close(io);
|
||||
b.dependOnFileContents(b.path(".git"));
|
||||
var line_buffer: ["gitdir: ".len + std.Io.Dir.max_path_bytes + 1]u8 = undefined;
|
||||
var git_file_reader = git_file.reader(io, &line_buffer);
|
||||
if (std.mem.cutPrefix(u8, std.mem.trimEnd(u8, try git_file_reader.interface.allocRemaining(
|
||||
@@ -285,7 +286,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.limited("gitdir: ".len + std.Io.Dir.max_path_bytes + "\r\n".len),
|
||||
), "\r\n"), "gitdir: ")) |git_dir| {
|
||||
const head_file = b.pathJoin(&.{ git_dir, "logs", "HEAD" });
|
||||
b.dependOnFileContents(if (std.Io.Dir.path.isAbsolute(head_file))
|
||||
b.dependOnFileMetadata(if (std.Io.Dir.path.isAbsolute(head_file))
|
||||
b.graph.cwdRelativePath(head_file)
|
||||
else
|
||||
b.path(head_file));
|
||||
|
||||
Reference in new issue
Block a user