2022-06-13 23:15:46 +02:00
|
|
|
const std = @import("std");
|
|
|
|
const pkgs = @import("deps.zig").pkgs;
|
|
|
|
|
2022-08-26 01:38:02 +02:00
|
|
|
pub fn build(b: *std.build.Builder) !void {
|
2022-06-13 23:15:46 +02:00
|
|
|
// Standard release options allow the person running `zig build` to select
|
|
|
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
|
|
|
const mode = b.standardReleaseOptions();
|
|
|
|
|
|
|
|
const lib = b.addSharedLibrary("zellij-compact-status", "src/main.zig", .{ .unversioned = {} });
|
|
|
|
lib.setBuildMode(mode);
|
|
|
|
|
|
|
|
lib.target.cpu_arch = .wasm32;
|
|
|
|
lib.target.os_tag = .wasi;
|
2022-12-31 21:00:37 +01:00
|
|
|
lib.rdynamic = true;
|
2022-08-10 00:15:24 +02:00
|
|
|
lib.strip = mode != .Debug;
|
2022-06-13 23:15:46 +02:00
|
|
|
|
|
|
|
pkgs.addAllTo(lib);
|
|
|
|
|
|
|
|
const main_tests = b.addTest("src/main.zig");
|
|
|
|
main_tests.setBuildMode(mode);
|
|
|
|
|
|
|
|
const test_step = b.step("test", "Run library tests");
|
|
|
|
test_step.dependOn(&main_tests.step);
|
2022-08-26 01:38:02 +02:00
|
|
|
|
|
|
|
b.getInstallStep().dependOn(&(try InstallStep.init(b, lib)).step);
|
2022-06-13 23:15:46 +02:00
|
|
|
}
|
2022-08-26 01:38:02 +02:00
|
|
|
|
|
|
|
const InstallStep = struct {
|
|
|
|
builder: *std.build.Builder,
|
|
|
|
step: std.build.Step,
|
|
|
|
lib: *std.build.LibExeObjStep,
|
|
|
|
|
|
|
|
pub fn init(builder: *std.build.Builder, lib: *std.build.LibExeObjStep) !*InstallStep {
|
|
|
|
const self = try builder.allocator.create(InstallStep);
|
|
|
|
self.* = .{
|
|
|
|
.builder = builder,
|
|
|
|
.lib = lib,
|
|
|
|
.step = std.build.Step.init(.custom, "install", builder.allocator, make),
|
|
|
|
};
|
|
|
|
self.step.dependOn(&lib.step);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make(step: *std.build.Step) anyerror!void {
|
|
|
|
const self = @fieldParentPtr(InstallStep, "step", step);
|
|
|
|
|
|
|
|
const plugin_install_dir = std.build.InstallDir{
|
|
|
|
.custom = "share/zellij/plugins",
|
|
|
|
};
|
|
|
|
const plugin_basename = "compact-status.wasm";
|
|
|
|
|
|
|
|
const dest_path = self.builder.getInstallPath(
|
|
|
|
plugin_install_dir,
|
|
|
|
plugin_basename,
|
|
|
|
);
|
|
|
|
|
|
|
|
try self.builder.updateFile(
|
|
|
|
self.lib.getOutputSource().getPath(self.builder),
|
|
|
|
dest_path,
|
|
|
|
);
|
|
|
|
// FIXME: the uninstall step doesn't do anything, despite this
|
|
|
|
self.builder.pushInstalledFile(plugin_install_dir, plugin_basename);
|
|
|
|
}
|
|
|
|
};
|