const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const strip = b.option(bool, "strip", "Omit debug info (default: on unless Debug)") orelse (optimize != .debug); const version = b.option([]const u8, "version", "Build version reported by /api/version") orelse "dev"; const options = b.addOptions(); options.addOption([]const u8, "version", version); // SQLite is the official amalgamation, compiled here as C. const sqlite_dep = b.dependency("sqlite", .{}); const sqlite_h = b.addTranslateC(.{ .root_source_file = sqlite_dep.path("sqlite3.h"), .target = target, .optimize = optimize, }); const mod = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .strip = strip, .link_libc = true, .imports = &.{ .{ .name = "sqlite", .module = sqlite_h.createModule() }, }, }); mod.addOptions("build_options", options); mod.addCSourceFile(.{ .file = sqlite_dep.path("sqlite3.c"), .flags = &.{ "-DSQLITE_DQS=0", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", "-DSQLITE_OMIT_DEPRECATED", "-DSQLITE_OMIT_LOAD_EXTENSION", "-DSQLITE_OMIT_SHARED_CACHE", "-DSQLITE_USE_ALLOCA", "-DSQLITE_THREADSAFE=1", }, }); // The TodoMVC stylesheets are served byte for byte from the repo's // shared/ directory, so they are embedded from there, not copied. mod.addAnonymousImport("base.css", .{ .root_source_file = b.path("../../shared/base.css") }); mod.addAnonymousImport("index.css", .{ .root_source_file = b.path("../../shared/index.css") }); mod.addAnonymousImport("app.css", .{ .root_source_file = b.path("static/app.css") }); mod.addAnonymousImport("app.js", .{ .root_source_file = b.path("static/app.js") }); const exe = b.addExecutable(.{ .name = "app", .root_module = mod, .linkage = .static }); b.installArtifact(exe); const tests = b.addTest(.{ .root_module = mod }); const run_tests = b.addRunArtifact(tests); b.step("test", "Run unit tests").dependOn(&run_tests.step); }