robin/cdl

cute fetch client written in zig

git clone https://git.robinwobin.dev/robin/cdl

robinwip: init4a5e316

main
1.5 KiB57 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 mod = b.addModule("cdl", .{
8        .root_source_file = b.path("src/root.zig"),
9        .target = target,
10        .optimize = optimize,
11    });
12
13    const exe = b.addExecutable(.{
14        .name = "cdl",
15        .root_module = b.createModule(.{
16            .root_source_file = b.path("src/main.zig"),
17            .target = target,
18            .optimize = optimize,
19        }),
20    });
21
22    exe.root_module.addImport("cdl", mod);
23
24    b.installArtifact(exe);
25
26    // deps ===================================================================
27
28    const c_wchar = b.addTranslateC(.{
29        .root_source_file = b.path("src/wchar.h"),
30        .target = target,
31        .optimize = optimize,
32    });
33
34    mod.addImport("wchar", c_wchar.createModule());
35
36    // run ====================================================================
37
38    const run_step = b.step("run", "Run");
39
40    const run_cmd = b.addRunArtifact(exe);
41    run_step.dependOn(&run_cmd.step);
42
43    run_cmd.step.dependOn(b.getInstallStep());
44
45    if (b.args) |args| {
46        run_cmd.addArgs(args);
47    }
48
49    // test ===================================================================
50
51    const test_step = b.step("test", "Test");
52
53    const test_step_run = b.addRunArtifact(b.addTest(.{
54        .root_module = mod,
55    }));
56    test_step.dependOn(&test_step_run.step);
57}