2023-09-13 00:11:45 -07:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
pub fn build(b: *std.Build) void {
|
2023-09-24 14:45:01 -07:00
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
|
2023-09-13 00:11:45 -07:00
|
|
|
const nice = b.addModule("nice", .{
|
2023-09-24 18:22:12 -07:00
|
|
|
.source_file = .{ .path = "src/nice.zig" },
|
2023-09-13 00:11:45 -07:00
|
|
|
});
|
2023-09-24 14:45:01 -07:00
|
|
|
|
|
|
|
add_examples(b, .{
|
|
|
|
.target = target,
|
|
|
|
.nice_mod = nice,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const ExampleOptions = struct {
|
|
|
|
target: std.zig.CrossTarget,
|
|
|
|
nice_mod: *std.Build.Module,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Example = struct {
|
|
|
|
name: []const u8,
|
|
|
|
file: []const u8,
|
|
|
|
};
|
|
|
|
|
|
|
|
const examples = [_]Example{
|
|
|
|
.{ .name = "parse", .file = "examples/parse.zig" },
|
2023-09-25 01:18:09 -07:00
|
|
|
.{ .name = "stream", .file = "examples/stream.zig" },
|
2023-10-22 15:36:34 -07:00
|
|
|
.{ .name = "reify", .file = "examples/reify.zig" },
|
2023-09-24 14:45:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
pub fn add_examples(b: *std.build, options: ExampleOptions) void {
|
|
|
|
const example_step = b.step("examples", "build examples");
|
|
|
|
|
|
|
|
inline for (examples) |example| {
|
|
|
|
const ex_exe = b.addExecutable(.{
|
|
|
|
.name = example.name,
|
|
|
|
.root_source_file = .{ .path = example.file },
|
|
|
|
.target = options.target,
|
|
|
|
.optimize = .Debug,
|
|
|
|
});
|
|
|
|
|
|
|
|
ex_exe.addModule("nice", options.nice_mod);
|
|
|
|
const install = b.addInstallArtifact(ex_exe, .{});
|
|
|
|
example_step.dependOn(&install.step);
|
|
|
|
}
|
2023-09-13 00:11:45 -07:00
|
|
|
}
|