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
slimsag committed Apr 20, 2024
1 parent a62aa64 commit ad7313d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.brotli = .{
.url = "https://pkg.machengine.org/brotli/538f4c5b085bb53c84e39860305442abd0436be5.tar.gz",
.hash = "12202a0f156a1d5d25a97468de318a99451a77b930f584d4edeff152259a875a4a75",
.lazy = true,
},
},
}

0 comments on commit ad7313d

Please sign in to comment.