aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 15:33:46 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 15:33:46 +0200
commit02582cc490fc0d753dd153211cc172eb28fbee5d (patch)
tree4add149d5e1ecf28cf20ecb497626fef85cdbd75 /build.zig
parent2f3199622d9e7a97da4b5c31a2d81b170b7cdaa6 (diff)
first sketch of wasm environment
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig50
1 files changed, 22 insertions, 28 deletions
diff --git a/build.zig b/build.zig
index 989f6c4..11ab41b 100644
--- a/build.zig
+++ b/build.zig
@@ -1,9 +1,15 @@
const std = @import("std");
+const AppBundle = @import("src/z/AppBundle.zig");
+
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
+ const site: AppBundle = .init(b, .{
+ .root_source_file = b.path("src/app/root.zig"),
+ });
+
const sqlite_c = b.addTranslateC(.{
.root_source_file = b.path("src/db/sqlite.h"),
.target = target,
@@ -27,12 +33,6 @@ pub fn build(b: *std.Build) void {
.target = target,
});
- const z_mod = b.addModule("z", .{
- .root_source_file = b.path("src/z/root.zig"),
- .target = target,
- });
- z_mod.addImport("html", html_mod);
-
const http_mod = b.addModule("http", .{
.root_source_file = b.path("src/http/root.zig"),
.target = target,
@@ -40,6 +40,14 @@ pub fn build(b: *std.Build) void {
api_mod.addImport("http", http_mod);
+ const z_mod = b.addModule("z", .{
+ .root_source_file = b.path("src/z/root.zig"),
+ .target = target,
+ });
+ z_mod.addImport("html", html_mod);
+
+ site.mod.addImport("z", z_mod);
+
const exe = b.addExecutable(.{
.name = "memora",
.root_module = b.createModule(.{
@@ -49,18 +57,21 @@ pub fn build(b: *std.Build) void {
.imports = &.{
.{ .name = "db", .module = db_mod },
.{ .name = "api", .module = api_mod },
- .{ .name = "z", .module = z_mod },
.{ .name = "html", .module = html_mod },
.{ .name = "http", .module = http_mod },
- }
+ .{ .name = "z", .module = z_mod },
+ },
}),
});
+ exe.root_module.addAnonymousImport("wasm", .{
+ .root_source_file = site.getEmittedWasm(),
+ });
+
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
-
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
@@ -76,7 +87,6 @@ pub fn build(b: *std.Build) void {
const db_test_step = b.step("test-db", "Run database tests");
db_test_step.dependOn(&run_db_tests.step);
-
const api_tests = b.addTest(.{
.root_module = api_mod,
});
@@ -84,14 +94,6 @@ pub fn build(b: *std.Build) void {
const api_test_step = b.step("test-api", "Run api tests");
api_test_step.dependOn(&run_api_tests.step);
-
- const z_tests = b.addTest(.{
- .root_module = z_mod,
- });
- const run_z_tests = b.addRunArtifact(z_tests);
- const z_test_step = b.step("test-z", "Run z tests");
- z_test_step.dependOn(&run_z_tests.step);
-
const html_tests = b.addTest(.{
.root_module = html_mod,
});
@@ -99,7 +101,6 @@ pub fn build(b: *std.Build) void {
const html_test_step = b.step("test-html", "Run html tests");
html_test_step.dependOn(&run_html_tests.step);
-
const http_tests = b.addTest(.{
.root_module = http_mod,
});
@@ -107,37 +108,31 @@ pub fn build(b: *std.Build) void {
const http_test_step = b.step("test-http", "Run http tests");
http_test_step.dependOn(&run_http_tests.step);
-
const exe_tests = b.addTest(.{
.root_module = exe.root_module,
});
const run_exe_tests = b.addRunArtifact(exe_tests);
-
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&run_db_tests.step);
test_step.dependOn(&run_api_tests.step);
- test_step.dependOn(&run_z_tests.step);
test_step.dependOn(&run_html_tests.step);
test_step.dependOn(&run_http_tests.step);
test_step.dependOn(&run_exe_tests.step);
-
const fmt_step = b.step("fmt", "Format");
const do_fmt = b.addFmt(.{
- .paths = &.{ "src" },
+ .paths = &.{"src"},
});
fmt_step.dependOn(&do_fmt.step);
-
const check_fmt_step = b.step("check", "Check format and syntax");
const do_check_fmt = b.addFmt(.{
- .paths = &.{ "src" },
+ .paths = &.{"src"},
.check = true,
});
check_fmt_step.dependOn(&do_check_fmt.step);
-
const docs_step = b.step("docs", "Emit documentation");
const docs_install = b.addInstallDirectory(.{
.install_dir = .prefix,
@@ -146,7 +141,6 @@ pub fn build(b: *std.Build) void {
});
docs_step.dependOn(&docs_install.step);
-
const hot_cmd = b.addSystemCommand(&.{
"sh",
"-c",