diff --git a/Makefile b/Makefile index 2b1d4d8..87d697f 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,9 @@ GITEPOCH=$(shell git log -1 --format="%at") TODAY=$(shell date +%Y.%m.%d -d @${GITEPOCH}) DIST=zootdeck-linux-`uname -i`-${TODAY} -build: ragel/lang.c +build: zig build -freference-trace -ragel/lang.c: ragel/lang.c.rl - ragel -o ragel/lang.c ragel/lang.c.rl - format: zig fmt src diff --git a/build.zig b/build.zig index b33661d..e599abe 100644 --- a/build.zig +++ b/build.zig @@ -20,16 +20,20 @@ pub fn build(b: *std.Build) void { // running `zig build`). // b.installArtifact(lib); + const gen_ragel = b.addSystemCommand(&.{ "ragel", "-o", "ragel/lang.c", "ragel/lang.c.rl" }); + const exe = b.addExecutable(.{ .name = "zootdeck", - .root_source_file = .{ .src_path = .{ .sub_path = "src/main.zig", .owner = b } }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe.linkLibC(); - exe.addIncludePath(.{ .cwd_relative = "." }); + exe.addIncludePath(b.path(".")); + exe.linkSystemLibrary("curl"); exe.linkSystemLibrary("lmdb"); - exe.addCSourceFile(.{ .file = .{ .cwd_relative = "ragel/lang.c" } }); + exe.addCSourceFile(.{ .file = b.path("ragel/lang.c") }); + exe.step.dependOn(&gen_ragel.step); // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default diff --git a/src/config.zig b/src/config.zig index 1787bd2..0b1c2ef 100644 --- a/src/config.zig +++ b/src/config.zig @@ -190,7 +190,7 @@ pub fn writefile(settings: Settings, filename: []const u8) void { if (std.fs.cwd().createFile(filename, .{ .truncate = true })) |*file| { warn("config.write toJson\n", .{}); //std.json.stringify(configFile, std.json.StringifyOptions{}, file.writer()) catch unreachable; - warn("config saved. {s} {} bytes\n", .{ filename, file.getPos() }); + warn("config saved. {s} {} bytes\n", .{ filename, file.getPos() catch unreachable }); file.close(); } else |err| { warn("config save fail. {!}\n", .{err});