2022-10-20 15:38:12 +02:00
|
|
|
const std = @import("std");
|
2023-06-01 15:58:51 +02:00
|
|
|
const common = @import("build_common.zig");
|
2022-10-20 15:38:12 +02:00
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
pub fn build(b: *std.Build) !void {
|
2023-02-11 13:24:42 +01:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2022-10-20 15:38:12 +02:00
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
if (target.result.os.tag == .windows)
|
2023-02-11 13:24:42 +01:00
|
|
|
// 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 });
|
|
|
|
|
2023-06-01 15:58:51 +02:00
|
|
|
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);
|
2023-06-01 15:58:51 +02:00
|
|
|
|
|
|
|
const opts = b.addOptions();
|
|
|
|
opts.addOption([]const u8, "font", cg_opt.term_font);
|
2024-01-08 17:40:08 +01:00
|
|
|
lib.root_module.addImport("opts", opts.createModule());
|
2023-06-01 15:58:51 +02:00
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
lib.root_module.addImport("nvim", znvim_dep.module("nvim_c"));
|
|
|
|
lib.root_module.addImport("znvim", znvim_dep.module("znvim"));
|
2023-04-23 18:07:38 +02:00
|
|
|
|
2022-10-20 15:38:12 +02:00
|
|
|
lib.linkLibC();
|
|
|
|
lib.linkSystemLibrary("luajit");
|
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
lib.root_module.unwind_tables = true;
|
2022-10-20 15:38:12 +02:00
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
b.getInstallStep().dependOn(&b.addInstallFile(lib.getEmittedBin(), "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();
|
2023-01-03 22:31:20 +01:00
|
|
|
compiler.linkSystemLibrary("luajit");
|
2022-11-19 01:53:49 +01:00
|
|
|
|
2024-01-08 17:40:08 +01:00
|
|
|
compiler.root_module.unwind_tables = true;
|
2022-11-19 01:53:49 +01:00
|
|
|
|
2023-08-26 15:37:32 +02:00
|
|
|
b.installArtifact(compiler);
|
2022-10-20 15:38:12 +02:00
|
|
|
}
|