-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
56 lines (49 loc) · 1.72 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const zap = b.dependency("zap", .{
.target = target,
.optimize = optimize,
.openssl = false, // set to true to enable TLS support
});
inline for ([_]struct {
name: []const u8,
src: []const u8,
}{
.{ .name = "main", .src = "src/main.zig" },
.{ .name = "update", .src = "src/update.zig" },
}) |excfg| {
const ex_name = excfg.name;
const ex_src = excfg.src;
const ex_build_desc = try std.fmt.allocPrint(
b.allocator,
"build the {s} example",
.{ex_name},
);
const ex_run_stepname = try std.fmt.allocPrint(
b.allocator,
"run-{s}",
.{ex_name},
);
const ex_run_stepdesc = try std.fmt.allocPrint(
b.allocator,
"run the {s} example",
.{ex_name},
);
const example_run_step = b.step(ex_run_stepname, ex_run_stepdesc);
const example_step = b.step(ex_name, ex_build_desc);
var example = b.addExecutable(.{
.name = ex_name,
.root_source_file = b.path(ex_src),
.target = target,
.optimize = optimize,
});
example.root_module.addImport("zap", zap.module("zap"));
const example_run = b.addRunArtifact(example);
example_run_step.dependOn(&example_run.step);
// install the artifact - depending on the "example"
const example_build_step = b.addInstallArtifact(example, .{});
example_step.dependOn(&example_build_step.step);
}
}