kiloz

Following through https://viewsourcecode.org/snaptoken/kilo/index.html in Zig
git clone git://code.mfashby.net:/kiloz
Log | Files | Refs | README

build.zig (1673B)


      1 const std = @import("std");
      2 const builtin = @import("builtin");
      3 
      4 pub fn build(b: *std.Build) void {
      5     const target = b.standardTargetOptions(.{});
      6     const optimize = b.standardOptimizeOption(.{});
      7 
      8     const lib = b.addStaticLibrary(.{
      9         .name = "kiloz",
     10         .root_source_file = .{ .path = "src/root.zig" },
     11         .target = target,
     12         .optimize = optimize,
     13     });
     14 
     15     b.installArtifact(lib);
     16 
     17     const exe = b.addExecutable(.{
     18         .name = "kiloz",
     19         .root_source_file = .{ .path = "src/main.zig" },
     20         .target = target,
     21         .optimize = optimize,
     22     });
     23 
     24     b.installArtifact(exe);
     25 
     26     var opts = b.addOptions();
     27     opts.addOption([]const u8, "version", "0.0.0"); // TODO figure out how to get this from build.zig.zon
     28     exe.root_module.addOptions("options", opts);
     29 
     30     const run_cmd = b.addRunArtifact(exe);
     31 
     32     run_cmd.step.dependOn(b.getInstallStep());
     33 
     34     if (b.args) |args| {
     35         run_cmd.addArgs(args);
     36     }
     37 
     38     const run_step = b.step("run", "Run the app");
     39     run_step.dependOn(&run_cmd.step);
     40 
     41     const lib_unit_tests = b.addTest(.{
     42         .root_source_file = .{ .path = "src/root.zig" },
     43         .target = target,
     44         .optimize = optimize,
     45     });
     46 
     47     const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
     48 
     49     const exe_unit_tests = b.addTest(.{
     50         .root_source_file = .{ .path = "src/main.zig" },
     51         .target = target,
     52         .optimize = optimize,
     53     });
     54 
     55     const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
     56 
     57     const test_step = b.step("test", "Run unit tests");
     58     test_step.dependOn(&run_lib_unit_tests.step);
     59     test_step.dependOn(&run_exe_unit_tests.step);
     60 }