dotfiles/mzte-nv/build.zig

73 lines
2.5 KiB
Zig
Raw Normal View History

2022-10-20 15:38:12 +02:00
const std = @import("std");
2024-03-20 20:45:59 +01:00
const common = @import("common");
2022-10-20 15:38:12 +02: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
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 });
2024-04-26 16:06:58 +02:00
const common_dep = b.dependency("common", .{});
2023-04-23 18:07:38 +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
2024-04-05 22:56:00 +02:00
nix: struct {
2024-04-14 16:09:11 +02:00
nvim_plugins: ?[:0]u8 = null,
2024-04-05 22:56:00 +02:00
tree_sitter_parsers: ?[:0]u8 = null,
nvim_tools: ?[:0]u8 = null,
2024-04-10 18:03:17 +02:00
jvm: ?[:0]u8 = null,
2024-04-05 22:56:00 +02:00
@"fennel.lua": ?[:0]u8 = null,
},
2024-03-20 20:45:59 +01:00
}, b.allocator);
const opts = b.addOptions();
opts.addOption([]const u8, "font", cg_opt.term_font);
2024-04-14 16:09:11 +02:00
opts.addOption(?[:0]const u8, "nvim_plugins", cg_opt.nix.nvim_plugins);
2024-04-05 22:56:00 +02:00
opts.addOption(?[:0]const u8, "tree_sitter_parsers", cg_opt.nix.tree_sitter_parsers);
opts.addOption(?[:0]const u8, "nvim_tools", cg_opt.nix.nvim_tools);
2024-04-10 18:03:17 +02:00
opts.addOption(?[:0]const u8, "jvm", cg_opt.nix.jvm);
2024-04-05 22:56:00 +02:00
opts.addOption(?[:0]const u8, "fennel.lua", cg_opt.nix.@"fennel.lua");
lib.root_module.addImport("opts", opts.createModule());
2024-04-26 16:06:58 +02:00
lib.root_module.addImport("common", common_dep.module("common"));
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");
lib.root_module.unwind_tables = true;
2022-10-20 15:38:12 +02: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();
compiler.linkSystemLibrary("luajit");
2022-11-19 01:53:49 +01:00
2024-04-05 22:56:00 +02:00
compiler.root_module.addImport("opts", opts.createModule());
compiler.root_module.addImport("common", b.dependency("common", .{}).module("common"));
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
}