chore: update to new Zig build API
This commit is contained in:
parent
6471c35ea5
commit
476ff897be
49
build.zig
49
build.zig
|
@ -1,32 +1,32 @@
|
|||
const std = @import("std");
|
||||
const pkgs = @import("deps.zig").pkgs;
|
||||
|
||||
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();
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const lib = b.addSharedLibrary("rofi_nheko", "src/main.zig", .unversioned);
|
||||
lib.setBuildMode(mode);
|
||||
const lib = b.addSharedLibrary(.{
|
||||
.name = "rofi_nheko",
|
||||
.root_source_file = .{ .path = "src/main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
lib.linkLibC();
|
||||
lib.linkSystemLibrary("glib-2.0");
|
||||
lib.linkSystemLibrary("gio-unix-2.0");
|
||||
lib.linkSystemLibrary("rofi");
|
||||
lib.linkSystemLibrary("cairo");
|
||||
pkgs.addAllTo(lib);
|
||||
|
||||
lib.strip = mode != .Debug;
|
||||
lib.addModule("glib-log", b.dependency("glib_log", .{}).module("zig-glib-log"));
|
||||
|
||||
lib.install();
|
||||
lib.strip = optimize != .Debug;
|
||||
|
||||
const install_step = b.addInstallArtifact(lib);
|
||||
install_step.dest_dir = .{ .custom = "lib/rofi" };
|
||||
|
||||
b.getInstallStep().dependOn(&install_step.step);
|
||||
|
||||
lib.step.dependOn(&(try NhdbusGen.init(lib)).step);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
const NhdbusGen = struct {
|
||||
|
@ -34,31 +34,36 @@ const NhdbusGen = struct {
|
|||
lib: *std.build.LibExeObjStep,
|
||||
|
||||
pub fn init(lib: *std.build.LibExeObjStep) !*NhdbusGen {
|
||||
const self = try lib.builder.allocator.create(NhdbusGen);
|
||||
const self = try lib.step.owner.allocator.create(NhdbusGen);
|
||||
self.* = .{
|
||||
.step = std.build.Step.init(.custom, "nhdbus-gen", lib.builder.allocator, make),
|
||||
.step = std.build.Step.init(.{
|
||||
.id = .custom,
|
||||
.name = "nhdbus-gen",
|
||||
.owner = lib.step.owner,
|
||||
.makeFn = make,
|
||||
}),
|
||||
.lib = lib,
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
fn make(step: *std.build.Step) !void {
|
||||
fn make(step: *std.build.Step, _: *std.Progress.Node) !void {
|
||||
const self = @fieldParentPtr(NhdbusGen, "step", step);
|
||||
const b = self.lib.builder;
|
||||
const b = self.lib.step.owner;
|
||||
|
||||
const c_basename = "nhdbus";
|
||||
|
||||
const nhdbus_path = try std.fmt.allocPrint(
|
||||
b.allocator,
|
||||
"{s}/c/{s}.c",
|
||||
.{ b.cache_root, c_basename },
|
||||
.{ b.cache_root.path.?, c_basename },
|
||||
);
|
||||
defer b.allocator.free(nhdbus_path);
|
||||
|
||||
const include_path = nhdbus_path[0..nhdbus_path.len - c_basename.len - ".c".len];
|
||||
const include_path = nhdbus_path[0 .. nhdbus_path.len - c_basename.len - ".c".len];
|
||||
|
||||
try std.fs.cwd().makePath(include_path);
|
||||
|
||||
|
||||
self.lib.addIncludePath(include_path);
|
||||
self.lib.addCSourceFile(nhdbus_path, &.{});
|
||||
|
||||
|
|
10
build.zig.zon
Normal file
10
build.zig.zon
Normal file
|
@ -0,0 +1,10 @@
|
|||
.{
|
||||
.name = "rofi-nheko",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.glib_log = .{
|
||||
.url = "https://mzte.de/git/LordMZTE/zig-glib-log/archive/aaea1cd24ede4ae5caa8b906fbdc5e767de21b7b.tar.gz",
|
||||
.hash = "122084bf49477b71d539c03bb5e211de9f5c753f4f6d93848cab76d651d6e9bb247b",
|
||||
},
|
||||
},
|
||||
}
|
6
gyro.zzz
6
gyro.zzz
|
@ -1,6 +0,0 @@
|
|||
deps:
|
||||
glib-log:
|
||||
git:
|
||||
url: "https://mzte.de/git/LordMZTE/zig-glib-log.git"
|
||||
ref: master
|
||||
root: src/main.zig
|
|
@ -8,9 +8,11 @@ const State = @import("State.zig");
|
|||
const Room = @import("Room.zig");
|
||||
const IconStore = @import("IconStore.zig");
|
||||
|
||||
pub const log = @import("glib-log").log(c, "rofi-nheko", 512);
|
||||
// log levels are handled by glib, so zig shouldn't filter
|
||||
pub const log_level = .debug;
|
||||
pub const std_options = struct {
|
||||
pub const logFn = @import("glib-log").log(c, "rofi-nheko", 512);
|
||||
// log levels are handled by glib, so zig shouldn't filter
|
||||
pub const log_level = .debug;
|
||||
};
|
||||
|
||||
export var mode: Mode = .{
|
||||
.abi_version = c.ABI_VERSION,
|
||||
|
|
Loading…
Reference in a new issue