Skip to content

Commit

Permalink
build.zig: lazily load deps_local
Browse files Browse the repository at this point in the history
  • Loading branch information
archbirdplus committed Apr 27, 2024
1 parent ee8917b commit 6c0bb49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ pub fn build(b: *std.Build) !void {
exe.linkLibCpp();

// For the time being, MacOS cubyz_deps will not have released binaries.
const depsName = if (t.os.tag == .macos) "deps_local" else "deps";
const deps = b.dependency(depsName, .{
const depsName = if (t.os.tag != .macos) "deps_local" else "deps";
const deps = b.lazyDependency(depsName, .{
.target = target,
.optimize = optimize,
});
}) orelse {
// Lazy dependencies with a `url` field will fail here the first time.
// build.zig will restart and try again.
std.log.info("Downloading dependency {s}.", .{depsName});
return;
};

exe.addLibraryPath(deps.path("lib"));
exe.addIncludePath(deps.path("include"));
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
.paths = .{""},
.dependencies = .{
.deps_local = .{
.url = "file:../Cubyz-libs/zig-out.tar.gz", // macos has no official deps release
.hash = "12209f7db8911ff57c69db2097437ad5e00141e862b0e760926c966b8652d09edf43",
.path = "../Cubyz-libs/zig-out", // macos has no official deps release
.lazy = true,
},
.deps = .{
//.url = "file:../Cubyz-libs/zig-out.tar.gz", // fetching the lib from the local folder
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,4 @@ pub fn main() void {

test "abc" {
_ = @import("json.zig");
}
}

0 comments on commit 6c0bb49

Please sign in to comment.