srf-lsp/build.zig
Emil Lerch 16bc787738
All checks were successful
Generic zig build / build (push) Successful in 55s
nix flake + ci
2026-09-01 16:23:31 -07:00

51 lines
1.5 KiB
Zig

const std = @import("std");
/// Single source of truth for the version. `serverInfo.version` in the LSP
/// handshake reads it through the generated `build_options` module below, so the
/// number cannot drift from the package metadata.
const build_zon = @import("build.zig.zon");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const srf_dep = b.dependency("srf", .{
.target = target,
});
const options = b.addOptions();
options.addOption([]const u8, "version", build_zon.version);
const exe = b.addExecutable(.{
.name = "srf-lsp",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "srf", .module = srf_dep.module("srf") },
.{ .name = "build_options", .module = options.createModule() },
},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Run the LSP server");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const exe_tests = b.addTest(.{
.root_module = exe.root_module,
});
const run_exe_tests = b.addRunArtifact(exe_tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_exe_tests.step);
}