Skip to content

Commit

Permalink
examples: Fix examples/build.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Phan committed Dec 10, 2022
1 parent b5806e7 commit 79bae72
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions examples/build.zig
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
const std = @import("std");

const pkg_name = "getty";
const pkg_path = "../src/getty.zig";

const examples = .{
"bool-serializer",
"bool-deserializer",
"seq-serializer",
"seq-deserializer",
};

pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();

inline for (.{
"bool-serializer",
"bool-deserializer",
"seq-serializer",
"seq-deserializer",
}) |example| {
const exe = b.addExecutable("examples", example ++ "/main.zig");
inline for (examples) |e| {
const example_path = e ++ "/main.zig";
const exe_name = "example-" ++ e;
const run_name = "run-" ++ e;
const run_desc = "Run the " ++ e ++ " example";

const exe = b.addExecutable(exe_name, example_path);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.addPackagePath("getty", "../src/getty.zig");
exe.addPackagePath(pkg_name, pkg_path);
exe.install();

const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run-" ++ example, "Run the " ++ example ++ " example");
const run_step = b.step(run_name, run_desc);
run_step.dependOn(&run_cmd.step);
}
}

0 comments on commit 79bae72

Please sign in to comment.