scritcher/build.zig

63 lines
1.8 KiB
Zig
Raw Normal View History

2020-06-03 00:42:26 +00:00
const std = @import("std");
const builds = std.build;
const Builder = std.build.Builder;
2019-07-05 19:59:45 +00:00
fn setupLinks(step: *builds.LibExeObjStep) void {
2019-09-30 02:57:24 +00:00
step.linkSystemLibrary("c");
step.linkSystemLibrary("lilv-0");
step.linkSystemLibrary("sndfile");
2019-10-06 13:53:09 +00:00
step.linkSystemLibrary("readline");
2019-08-27 17:40:41 +00:00
step.linkSystemLibrary("GraphicsMagickWand");
step.linkSystemLibrary("GraphicsMagick");
step.addIncludeDir("/usr/include/GraphicsMagick");
step.addIncludeDir("/usr/include");
2020-06-03 00:42:26 +00:00
const possible_lilv_include_dirs = [_][]const u8{
"/usr/include/lilv-0/lilv",
"/usr/include/lilv-0",
2020-06-03 00:42:26 +00:00
};
var found_any_lilv = false;
for (possible_lilv_include_dirs) |possible_lilv_dir| {
var possible_dir = std.fs.cwd().openDir(possible_lilv_dir, .{}) catch |err| {
std.debug.warn("possible lilv {} fail: {}\n", .{ possible_lilv_dir, err });
2020-06-03 00:42:26 +00:00
continue;
};
2020-06-03 00:42:26 +00:00
possible_dir.close();
found_any_lilv = true;
std.debug.warn("found lilv at '{}'\n", .{possible_lilv_dir});
step.addIncludeDir(possible_lilv_dir);
2020-06-03 00:42:26 +00:00
}
if (!found_any_lilv) {
std.debug.warn("No LILV library was found :(\n", .{});
2020-06-03 00:42:26 +00:00
@panic("no lilv found");
}
}
2019-07-05 19:59:45 +00:00
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("scritcher", "src/main.zig");
exe.setBuildMode(mode);
exe.install();
setupLinks(exe);
2019-07-22 22:28:55 +00:00
const test_obj_step = b.addTest("src/main.zig");
setupLinks(test_obj_step);
2019-07-07 05:26:05 +00:00
2019-07-05 19:59:45 +00:00
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&test_obj_step.step);
2019-07-05 19:59:45 +00:00
}