add(examples/demo): application to showcase a more complex application
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 53s

Further improvements for example applications; Demo example is now
default build target (when not providing example configuration).
This commit is contained in:
2025-02-21 22:57:14 +01:00
parent c634e1affc
commit 6ccab74c94
11 changed files with 172 additions and 28 deletions

View File

@@ -5,6 +5,7 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const Examples = enum {
demo,
// elements:
button,
input,
@@ -21,7 +22,7 @@ pub fn build(b: *std.Build) void {
errors,
};
const example = b.option(Examples, "example", "Example to build and/or run. (default: vertical)") orelse .vertical;
const example = b.option(Examples, "example", "Example to build and/or run. (default: demo)") orelse .demo;
const options = b.addOptions();
options.addOption(Examples, "example", example);
@@ -42,6 +43,15 @@ pub fn build(b: *std.Build) void {
//--- Examples ---
// demo:
const demo = b.addExecutable(.{
.name = "demo",
.root_source_file = b.path("examples/demo.zig"),
.target = target,
.optimize = optimize,
});
demo.root_module.addImport("zterm", lib);
// elements:
const button = b.addExecutable(.{
.name = "button",
@@ -128,6 +138,7 @@ pub fn build(b: *std.Build) void {
// mapping of user selected example to compile step
const exe = switch (example) {
.demo => demo,
// elements:
.button => button,
.input => input,