From ad7313db50a6bd29121d587effb3b308e21a20fd Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 20 Apr 2024 09:23:44 -0700 Subject: [PATCH] use lazyDependency to optimize dependency fetching Helps hexops/mach#1197 Signed-off-by: Stephen Gutekanst --- build.zig | 7 ++++--- build.zig.zon | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 7bf31c193..5002b49b4 100644 --- a/build.zig +++ b/build.zig @@ -7,8 +7,6 @@ pub fn build(b: *std.Build) void { const use_system_zlib = b.option(bool, "use_system_zlib", "Use system zlib") orelse false; const enable_brotli = b.option(bool, "enable_brotli", "Build Brotli") orelse true; - const brotli_dep = b.dependency("brotli", .{ .target = target, .optimize = optimize }); - const lib = b.addStaticLibrary(.{ .name = "freetype", .target = target, @@ -24,7 +22,10 @@ pub fn build(b: *std.Build) void { if (enable_brotli) { lib.defineCMacro("FT_CONFIG_OPTION_USE_BROTLI", "1"); - lib.linkLibrary(brotli_dep.artifact("brotli")); + if (b.lazyDependency("brotli", .{ + .target = target, + .optimize = optimize, + })) |dep| lib.linkLibrary(dep.artifact("brotli")); } lib.defineCMacro("HAVE_UNISTD_H", "1"); diff --git a/build.zig.zon b/build.zig.zon index 09ef4eb10..9b05a4e00 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,6 +15,7 @@ .brotli = .{ .url = "https://pkg.machengine.org/brotli/538f4c5b085bb53c84e39860305442abd0436be5.tar.gz", .hash = "12202a0f156a1d5d25a97468de318a99451a77b930f584d4edeff152259a875a4a75", + .lazy = true, }, }, }