Rows live in the heap, as in Volatile; each committed transaction is also appended to a log that opening replays, so a store survives a canister upgrade. Generated-by: Claude Code (claude-opus-5-5)
51 lines
2.3 KiB
Zig
51 lines
2.3 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const glowcap = b.dependency("glowcap", .{ .target = target, .optimize = optimize });
|
|
const test_step = b.step("test", "Run the unit tests and the in-memory client/canister round trip");
|
|
for ([_][]const u8{ "src/pair_test.zig", "src/candid.zig", "src/principal.zig", "src/stable_log.zig" }) |root| {
|
|
const t = b.addTest(.{ .root_module = b.createModule(.{
|
|
.root_source_file = b.path(root),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{.{ .name = "glowcap", .module = glowcap.module("glowcap") }},
|
|
}) });
|
|
test_step.dependOn(&b.addRunArtifact(t).step);
|
|
}
|
|
|
|
// The canister: freestanding 32-bit Wasm whose only imports are `ic0`.
|
|
const wasm32 = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
|
|
const canister_glowcap = b.dependency("glowcap", .{ .target = wasm32, .optimize = .ReleaseSmall });
|
|
const canister = b.addExecutable(.{
|
|
.name = "counter",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/canister.zig"),
|
|
.target = wasm32,
|
|
.optimize = .ReleaseSmall,
|
|
.imports = &.{.{ .name = "glowcap", .module = canister_glowcap.module("glowcap") }},
|
|
}),
|
|
});
|
|
canister.entry = .disabled;
|
|
canister.root_module.export_symbol_names = &.{ "canister_init", "canister_update start", "canister_update deliver" };
|
|
const canister_step = b.step("canister", "Build the canister to zig-out/bin/counter.wasm");
|
|
canister_step.dependOn(&b.addInstallArtifact(canister, .{}).step);
|
|
|
|
// The client peer, for a JavaScript host to drive.
|
|
const client = b.addExecutable(.{
|
|
.name = "client",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/client.zig"),
|
|
.target = wasm32,
|
|
.optimize = .ReleaseSmall,
|
|
.imports = &.{.{ .name = "glowcap", .module = canister_glowcap.module("glowcap") }},
|
|
}),
|
|
});
|
|
client.entry = .disabled;
|
|
client.rdynamic = true;
|
|
const client_step = b.step("client", "Build the client peer to zig-out/bin/client.wasm");
|
|
client_step.dependOn(&b.addInstallArtifact(client, .{}).step);
|
|
}
|