Skip to content

Commit

Permalink
use lazyDependency to optimize dependency fetching
Browse files Browse the repository at this point in the history
Helps hexops/mach#1197

Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
emidoots committed Apr 21, 2024
1 parent 8f7ca98 commit 98b4bca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
25 changes: 14 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,27 @@ pub fn build(b: *std.Build) void {

lib.installHeadersDirectory("include/GLFW", "GLFW");
// GLFW headers depend on these headers, so they must be distributed too.
const vulkan_headers_dep = b.dependency("vulkan_headers", .{
if (b.lazyDependency("vulkan_headers", .{
.target = target,
.optimize = optimize,
});
lib.installLibraryHeaders(vulkan_headers_dep.artifact("vulkan-headers"));
})) |dep| {
lib.installLibraryHeaders(dep.artifact("vulkan-headers"));
}
if (target.result.os.tag == .linux) {
const x11_headers_dep = b.dependency("x11_headers", .{
if (b.lazyDependency("x11_headers", .{
.target = target,
.optimize = optimize,
});
const wayland_headers_dep = b.dependency("wayland_headers", .{
})) |dep| {
lib.linkLibrary(dep.artifact("x11-headers"));
lib.installLibraryHeaders(dep.artifact("x11-headers"));
}
if (b.lazyDependency("wayland_headers", .{
.target = target,
.optimize = optimize,
});
lib.linkLibrary(x11_headers_dep.artifact("x11-headers"));
lib.linkLibrary(wayland_headers_dep.artifact("wayland-headers"));
lib.installLibraryHeaders(x11_headers_dep.artifact("x11-headers"));
lib.installLibraryHeaders(wayland_headers_dep.artifact("wayland-headers"));
})) |dep| {
lib.linkLibrary(dep.artifact("wayland-headers"));
lib.installLibraryHeaders(dep.artifact("wayland-headers"));
}
}

if (target.result.isDarwin()) {
Expand Down
3 changes: 3 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
.vulkan_headers = .{
.url = "https://pkg.machengine.org/vulkan-headers/e33f2e482893a90bb36d67649ab30d5236ac21ab.tar.gz",
.hash = "122017098e4ca00dac1a9d30d152a6e6e9522843219c6df4489210fb7c8a6e4c7c1a",
.lazy = true,
},
.wayland_headers = .{
.url = "https://pkg.machengine.org/wayland-headers/4926b8c635aa2f215b0d5382060fc4091aa7b705.tar.gz",
.hash = "12207decf58bee217ae9c5340a6852a62e7f5af9901bef9b1468d93e480798898285",
.lazy = true,
},
.x11_headers = .{
.url = "https://pkg.machengine.org/x11-headers/ad1c4891f70302c61ba956cfd565758dc1ca9d28.tar.gz",
.hash = "1220ce35d8f1556afd5bf4796a7899d459f9c628b989f247eaf6aa00fbad10a88c9f",
.lazy = true,
},
},
}

0 comments on commit 98b4bca

Please sign in to comment.