build.zig (2274B)
1 const std = @import("std"); 2 3 const name = "progress"; 4 5 pub fn build(b: *std.Build) void { 6 const target = b.standardTargetOptions(.{}); 7 const optimize = b.standardOptimizeOption(.{}); 8 9 const mod = b.addModule(name, .{ 10 .root_source_file = b.path("src/root.zig"), 11 .target = target, 12 .optimize = optimize, 13 }); 14 15 const progress = b.addLibrary(.{ 16 .name = name, 17 .root_module = mod, 18 }); 19 20 const docs = b.addInstallDirectory(.{ 21 .source_dir = progress.getEmittedDocs(), 22 .install_dir = .prefix, 23 .install_subdir = "docs", 24 }); 25 26 const docs_step = b.step("docs", "Generate docs"); 27 docs_step.dependOn(&docs.step); 28 29 for ([_][]const u8{ "simple", "complex", "thread", "multibar", "multibar-static" }) |example| { 30 const run_step = b.step(b.fmt("run-bar-{s}", .{example}), b.fmt("Run bar/{s}.zig example", .{example})); 31 const exe = b.addExecutable(.{ 32 .name = example, 33 .root_module = b.createModule(.{ 34 .root_source_file = b.path(b.fmt("examples/bar/{s}.zig", .{example})), 35 .target = target, 36 .optimize = optimize, 37 }), 38 }); 39 exe.root_module.addImport(name, mod); 40 41 const run_cmd = b.addRunArtifact(exe); 42 run_cmd.step.dependOn(&b.addInstallArtifact(exe, .{}).step); 43 44 if (b.args) |args| { 45 run_cmd.addArgs(args); 46 } 47 48 run_step.dependOn(&run_cmd.step); 49 } 50 51 for ([_][]const u8{ "simple", "complex" }) |example| { 52 const run_step = b.step(b.fmt("run-spinner-{s}", .{example}), b.fmt("Run spinner/{s}.zig example", .{example})); 53 const exe = b.addExecutable(.{ 54 .name = example, 55 .root_module = b.createModule(.{ 56 .root_source_file = b.path(b.fmt("examples/spinner/{s}.zig", .{example})), 57 .target = target, 58 .optimize = optimize, 59 }), 60 }); 61 exe.root_module.addImport(name, mod); 62 63 const run_cmd = b.addRunArtifact(exe); 64 run_cmd.step.dependOn(&b.addInstallArtifact(exe, .{}).step); 65 66 if (b.args) |args| { 67 run_cmd.addArgs(args); 68 } 69 70 run_step.dependOn(&run_cmd.step); 71 } 72 }