fix: make built artifact lazy dep

This commit is contained in:
Nurul Huda (Apon) 2026-03-14 19:53:32 +06:00
parent 06499cdb3e
commit 68554d0e3b
No known key found for this signature in database
GPG key ID: 5D3F1DE2855A2F79
2 changed files with 14 additions and 11 deletions

View file

@ -21,22 +21,24 @@ pub fn build(b: *std.Build) !void {
const prebuilt_lib_path = b.fmt("{s}/{s}", .{ target_triple, lib_name }); const prebuilt_lib_path = b.fmt("{s}/{s}", .{ target_triple, lib_name });
// --- Pre-built resolution --- // // --- Pre-built resolution --- //
const libtemporal_dep = b.lazyDependency("libtemporal", .{});
var prebuilt_lib_file: ?std.Build.LazyPath = null; var prebuilt_lib_file: ?std.Build.LazyPath = null;
var selected_lib_file: std.Build.LazyPath = undefined;
if (libtemporal_dep) |dep| { if (!force_build_rust) {
const lib_file_candidate = dep.path(prebuilt_lib_path); const libtemporal_dep = b.lazyDependency("libtemporal", .{});
const lib_full_path = lib_file_candidate.getPath(b); if (libtemporal_dep) |dep| {
if (std.Io.Dir.cwd().openFile(b.graph.io, lib_full_path, .{})) |lib_check_file| { const lib_file_candidate = dep.path(prebuilt_lib_path);
lib_check_file.close(b.graph.io); const lib_full_path = lib_file_candidate.getPath(b);
prebuilt_lib_file = lib_file_candidate; if (std.Io.Dir.cwd().openFile(b.graph.io, lib_full_path, .{})) |lib_check_file| {
} else |_| {} lib_check_file.close(b.graph.io);
prebuilt_lib_file = lib_file_candidate;
} else |_| {}
}
} }
var selected_lib_file: std.Build.LazyPath = undefined; if (prebuilt_lib_file) |plf| {
if (prebuilt_lib_file != null and !force_build_rust) {
// std.debug.print("Using pre-built temporal_capi library from downloaded artifact at: {s}\n", .{prebuilt_lib_path}); // std.debug.print("Using pre-built temporal_capi library from downloaded artifact at: {s}\n", .{prebuilt_lib_path});
selected_lib_file = prebuilt_lib_file.?; selected_lib_file = plf;
} else { } else {
// std.debug.print("building from source: {s}\n", .{prebuilt_lib_path}); // std.debug.print("building from source: {s}\n", .{prebuilt_lib_path});
const build_crab = @import("build_crab"); const build_crab = @import("build_crab");

View file

@ -11,6 +11,7 @@
.libtemporal = .{ .libtemporal = .{
.url = "https://github.com/nurulhudaapon/temporalz/releases/download/v0.2.0/libtemporal.tar.gz", .url = "https://github.com/nurulhudaapon/temporalz/releases/download/v0.2.0/libtemporal.tar.gz",
.hash = "N-V-__8AAHgP2AWLC4ZLTr_3hWf6xtgtBI5moBrWDWg5kzSD", .hash = "N-V-__8AAHgP2AWLC4ZLTr_3hWf6xtgtBI5moBrWDWg5kzSD",
.lazy = true,
}, },
.build_crab = .{ .build_crab = .{
.url = "git+https://github.com/nurulhudaapon/build.crab?ref=zig-dev#1aabc836472d318e9756a43b17853aadc4599800", .url = "git+https://github.com/nurulhudaapon/build.crab?ref=zig-dev#1aabc836472d318e9756a43b17853aadc4599800",