dotfiles/mzte-nv/build.zig

60 lines
1.7 KiB
Zig
Raw Normal View History

2022-10-20 15:38:12 +02:00
const std = @import("std");
const common = @import("build_common.zig");
2022-10-20 15:38:12 +02:00
pub fn build(b: *std.build.Builder) !void {
2023-02-11 13:24:42 +01:00
const target = b.standardTargetOptions(.{});
2022-10-20 15:38:12 +02:00
2023-02-11 13:24:42 +01:00
if (target.os_tag orelse @import("builtin").os.tag == .windows)
// windows is an error in many ways
return error.Windows;
const mode = b.standardOptimizeOption(.{});
const lib = b.addSharedLibrary(.{
.name = "mzte-nv",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = mode,
});
2022-10-20 15:38:12 +02:00
2023-04-23 18:07:38 +02:00
const znvim_dep = b.dependency("znvim", .{ .target = target, .optimize = mode });
const cg_opt = try common.confgenGet(struct {
2023-06-27 23:20:35 +02:00
term_font: []u8, // TODO: this being non-const is a workaround for an std bug
2023-06-01 16:38:18 +02:00
}, "..", b.allocator);
const opts = b.addOptions();
opts.addOption([]const u8, "font", cg_opt.term_font);
lib.addOptions("opts", opts);
2023-04-23 18:07:38 +02:00
lib.addModule("nvim", znvim_dep.module("nvim_c"));
lib.addModule("znvim", znvim_dep.module("znvim"));
2022-10-20 15:38:12 +02:00
lib.linkLibC();
lib.linkSystemLibrary("luajit");
2023-05-27 01:27:08 +02:00
lib.strip = switch (mode) {
.Debug, .ReleaseSafe => false,
.ReleaseFast, .ReleaseSmall => true,
};
2022-10-20 15:38:12 +02:00
lib.unwind_tables = true;
2023-03-28 00:39:38 +02:00
b.getInstallStep().dependOn(&b.addInstallFile(lib.getOutputSource(), "share/nvim/mzte-nv.so").step);
2022-11-19 01:53:49 +01:00
// this is the install step for the lua config compiler binary
2023-02-11 13:24:42 +01:00
const compiler = b.addExecutable(.{
.name = "mzte-nv-compile",
.root_source_file = .{ .path = "src/compiler.zig" },
.target = target,
.optimize = mode,
});
2022-11-19 01:53:49 +01:00
compiler.linkLibC();
compiler.linkSystemLibrary("luajit");
2022-11-19 01:53:49 +01:00
compiler.strip = mode != .Debug;
compiler.unwind_tables = true;
2022-11-19 01:53:49 +01:00
2023-04-19 22:51:23 +02:00
b.installArtifact(lib);
2022-10-20 15:38:12 +02:00
}