build: add build flag for example
This commit is contained in:
parent
40f80bef0c
commit
b5c2d80f57
1 changed files with 12 additions and 10 deletions
22
build.zig
22
build.zig
|
@ -30,19 +30,21 @@ pub fn build(b: *std.Build) void {
|
||||||
vaxis_mod.addImport("gap_buffer", gap_buffer_dep.module("gap_buffer"));
|
vaxis_mod.addImport("gap_buffer", gap_buffer_dep.module("gap_buffer"));
|
||||||
|
|
||||||
// Examples
|
// Examples
|
||||||
const text_input_step = b.step("examples/text_input", "Run text_input.zig");
|
const Example = enum { image, main, pathological, table, text_input };
|
||||||
|
const example_option = b.option(Example, "example", "Example to run (default: text_input)") orelse .text_input;
|
||||||
const text_input = b.addExecutable(.{
|
const example_step = b.step("example", "Run example");
|
||||||
.name = "text_input",
|
const example = b.addExecutable(.{
|
||||||
// Change this to the example you want to use!
|
.name = "example",
|
||||||
.root_source_file = std.Build.LazyPath.relative("examples/text_input.zig"),
|
// future versions should use b.path, see zig PR #19597
|
||||||
|
.root_source_file = std.Build.LazyPath.relative(
|
||||||
|
b.fmt("examples/{s}.zig", .{@tagName(example_option)}),
|
||||||
|
),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
text_input.root_module.addImport("vaxis", vaxis_mod);
|
example.root_module.addImport("vaxis", vaxis_mod);
|
||||||
|
const example_run = b.addRunArtifact(example);
|
||||||
const text_input_run = b.addRunArtifact(text_input);
|
example_step.dependOn(&example_run.step);
|
||||||
text_input_step.dependOn(&text_input_run.step);
|
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
const tests_step = b.step("test", "Run tests");
|
const tests_step = b.step("test", "Run tests");
|
||||||
|
|
Loading…
Reference in a new issue