Skip to content

Commit

Permalink
search upwards from header installation to "include" folder
Browse files Browse the repository at this point in the history
  • Loading branch information
the-argus committed Sep 4, 2023
1 parent 3f23a93 commit cd49dda
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions compile_commands.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,26 @@ fn extractHeaderDirsFromStep(allocator: std.mem.Allocator, step: *std.Build.Comp
install_file.dir,
install_file.dest_rel_path,
);
// get the dirname, specifically the one called "include"
var dir = file;
{
const max_depth = 20;
var success = false;
for (0..max_depth) |_| {
dir = if (std.fs.path.dirname(file)) |dirname| dirname else {
std.log.warn("Unable to get directory name for installed header file {s} ", .{file});
continue;
};
success = std.mem.eql(std.fs.path.basename(dir), "include");
if (success) break;
}
if (!success) {
std.log.warn("Header file installed in a directory that is not within an \"include\" directory, ignoring: {s} ", .{file});
continue;
}
}
// just add the directory of that file. often creates duplicates
dirs.append(if (std.fs.path.dirname(file)) |dirname| dirname else {
std.log.warn("Unable to get directory name for installed header file {s} ", .{file});
continue;
}) catch @panic("OOM");
dirs.append(dir) catch @panic("OOM");
}
}
return dirs;
Expand Down

0 comments on commit cd49dda

Please sign in to comment.