feat: build.zig can now install the plugin; removed justfile
This commit is contained in:
parent
bcb37654c4
commit
654c3690e7
3 changed files with 42 additions and 17 deletions
44
build.zig
44
build.zig
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const pkgs = @import("deps.zig").pkgs;
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
// Standard release options allow the person running `zig build` to select
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
@ -16,11 +16,49 @@ pub fn build(b: *std.build.Builder) void {
|
|||
|
||||
pkgs.addAllTo(lib);
|
||||
|
||||
lib.install();
|
||||
|
||||
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);
|
||||
|
||||
b.getInstallStep().dependOn(&(try InstallStep.init(b, lib)).step);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
13
justfile
13
justfile
|
@ -1,13 +0,0 @@
|
|||
release:
|
||||
gyro build -Drelease-fast
|
||||
|
||||
run: release
|
||||
zellij --layout-path plugin.yaml
|
||||
|
||||
install: release
|
||||
cp -f \
|
||||
zig-out/lib/zellij-compact-status.wasm \
|
||||
~/.local/share/zellij/plugins/compact-status.wasm
|
||||
|
||||
uninstall:
|
||||
rm ~/.local/share/zellij/plugins/compact-status.wasm
|
|
@ -17,6 +17,6 @@ template:
|
|||
Fixed: 1
|
||||
run:
|
||||
plugin:
|
||||
location: "file:zig-out/lib/zellij-compact-status.wasm"
|
||||
location: "file:zig-out/share/zellij/plugins/compact-status.wasm"
|
||||
tabs:
|
||||
- direction: Vertical
|
||||
|
|
Loading…
Reference in a new issue