grace/htmlua

HTML Templating Engine

git clone https://git.gae.moe/grace/htmlua

Grace Yoder55a1697

1.0.0-alpha
3.0 KiB112 linesraw
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4    const target = b.standardTargetOptions(.{});
5    const optimize = b.standardOptimizeOption(.{});
6
7    const ezts = b.dependency("eazy_zig_tree_sitter", .{
8        .target = target,
9        .optimize = optimize,
10        .use_all_langs = true,
11        .use_third_party = true,
12    });
13
14    const ts = b.dependency("tree_sitter", .{
15        .target = target,
16        .optimize = optimize,
17    });
18
19    const mod = b.addModule("htmlua", .{
20        .root_source_file = b.path("src/root.zig"),
21        .target = target,
22        .imports = &.{
23            .{ .name = "easy-zig-tree-sitter", .module = ezts.module("eazy_zig_tree_sitter") },
24            .{ .name = "tree-sitter", .module = ts.module("tree_sitter") },
25        },
26    });
27
28    // Debug bin
29    const exe = b.addExecutable(.{
30        .name = "htmlua",
31        .root_module = b.createModule(.{
32            .root_source_file = b.path("src/main.zig"),
33            .target = target,
34            .optimize = optimize,
35            .imports = &.{
36                .{ .name = "htmlua", .module = mod },
37            },
38        }),
39    });
40
41    b.installArtifact(exe);
42
43    const run_step = b.step("run", "Run the app");
44
45    const run_cmd = b.addRunArtifact(exe);
46    run_step.dependOn(&run_cmd.step);
47
48    run_cmd.step.dependOn(b.getInstallStep());
49
50    if (b.args) |args| {
51        run_cmd.addArgs(args);
52    }
53
54    // CGI bin
55    const cgi = b.addExecutable(.{
56        .name = "htmlua-cgi",
57        .root_module = b.createModule(.{
58            .root_source_file = b.path("src/cgi.zig"),
59            .target = target,
60            .optimize = optimize,
61            .imports = &.{
62                .{ .name = "htmlua", .module = mod },
63            },
64        }),
65    });
66
67    b.installArtifact(cgi);
68
69    const mod_tests = b.addTest(.{
70        .root_module = mod,
71    });
72
73    const run_mod_tests = b.addRunArtifact(mod_tests);
74
75    const exe_tests = b.addTest(.{
76        .root_module = exe.root_module,
77    });
78
79    const run_exe_tests = b.addRunArtifact(exe_tests);
80
81    const test_step = b.step("test", "Run tests");
82    test_step.dependOn(&run_mod_tests.step);
83    test_step.dependOn(&run_exe_tests.step);
84
85    // https://zigtools.org/zls/guides/build-on-save/
86    const exe_check = b.addExecutable(.{
87        .name = "htmlua",
88        .root_module = b.createModule(.{
89            .root_source_file = b.path("src/main.zig"),
90            .target = target,
91            .optimize = optimize,
92            .imports = &.{
93                .{ .name = "htmlua", .module = mod },
94            },
95        }),
96    });
97    const cgi_check = b.addExecutable(.{
98        .name = "htmlua-cgi",
99        .root_module = b.createModule(.{
100            .root_source_file = b.path("src/cgi.zig"),
101            .target = target,
102            .optimize = optimize,
103            .imports = &.{
104                .{ .name = "htmlua", .module = mod },
105            },
106        }),
107    });
108
109    const check = b.step("check", "Check if htmlua compiles");
110    check.dependOn(&exe_check.step);
111    check.dependOn(&cgi_check.step);
112}