summaryrefslogtreecommitdiff
path: root/src/abi_hash.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:00:19 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit5b8cf6f66e367192090350c9129fa341edfc9343 (patch)
tree48a5e6229aca31c4a44473343d47fb7fcc63a32f /src/abi_hash.zig
parent88c04dd6c392c6d8fc3a02408506e85d86f476d5 (diff)
downloadsketchbook-5b8cf6f66e367192090350c9129fa341edfc9343.tar.gz
sketchbook-5b8cf6f66e367192090350c9129fa341edfc9343.zip
Compute abi.hash's layout half once per abi change, not in every compile
The comptime walk over the shared types cost about half a second of every sketch library's compile. abi_hash.zig runs it at build time, once per change of the abi sources (watched like any input), and build.zig hands the number to host and sketches as the module abi_hash; abi.hash folds in the build as before. The value is the walk's own, computed for the build machine in Debug.
Diffstat (limited to 'src/abi_hash.zig')
-rw-r--r--src/abi_hash.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/abi_hash.zig b/src/abi_hash.zig
new file mode 100644
index 0000000..9cd01cf
--- /dev/null
+++ b/src/abi_hash.zig
@@ -0,0 +1,9 @@
+//! Prints `abi.layout_hash` as Zig source: build.zig runs this once per change
+//! of the abi sources and hands the result to host and sketches as the module
+//! `abi_hash`.
+const std = @import("std");
+const abi = @import("abi");
+
+pub fn main(init: std.process.Init) !void {
+ try std.Io.File.stdout().writeStreamingAll(init.io, std.fmt.comptimePrint("pub const layout: u64 = 0x{x};\n", .{abi.layout_hash}));
+}