2020-06-03 00:42:26 +00:00
|
|
|
const std = @import("std");
|
2019-07-05 19:59:45 +00:00
|
|
|
|
2024-06-01 18:46:37 +00:00
|
|
|
fn setupLinks(step: *std.Build.Step.Compile) void {
|
2019-09-30 02:57:24 +00:00
|
|
|
step.linkSystemLibrary("c");
|
|
|
|
|
2019-08-08 19:48:31 +00:00
|
|
|
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
|
|
|
|
2019-08-08 19:48:31 +00:00
|
|
|
step.linkSystemLibrary("GraphicsMagickWand");
|
|
|
|
step.linkSystemLibrary("GraphicsMagick");
|
|
|
|
|
2023-08-05 00:50:59 +00:00
|
|
|
step.addIncludePath(.{ .path = "/usr/include/GraphicsMagick" });
|
|
|
|
step.addIncludePath(.{ .path = "/usr/include" });
|
2020-06-03 00:42:26 +00:00
|
|
|
|
|
|
|
const possible_lilv_include_dirs = [_][]const u8{
|
|
|
|
"/usr/include/lilv-0/lilv",
|
2020-06-03 00:54:39 +00:00
|
|
|
"/usr/include/lilv-0",
|
2020-06-03 00:42:26 +00:00
|
|
|
};
|
2020-06-03 01:24:43 +00:00
|
|
|
|
2020-06-03 00:42:26 +00:00
|
|
|
var found_any_lilv = false;
|
|
|
|
|
|
|
|
for (possible_lilv_include_dirs) |possible_lilv_dir| {
|
2020-06-03 00:54:39 +00:00
|
|
|
var possible_dir = std.fs.cwd().openDir(possible_lilv_dir, .{}) catch |err| {
|
2022-10-08 18:05:15 +00:00
|
|
|
std.debug.print("possible lilv {s} fail: {s}\n", .{ possible_lilv_dir, @errorName(err) });
|
2020-06-03 00:42:26 +00:00
|
|
|
continue;
|
|
|
|
};
|
2020-06-03 00:54:39 +00:00
|
|
|
|
2020-06-03 00:42:26 +00:00
|
|
|
possible_dir.close();
|
|
|
|
found_any_lilv = true;
|
2020-06-03 00:54:39 +00:00
|
|
|
|
2022-04-27 23:01:09 +00:00
|
|
|
std.debug.print("found lilv at '{s}'\n", .{possible_lilv_dir});
|
2023-08-05 00:50:59 +00:00
|
|
|
step.addIncludePath(.{ .path = possible_lilv_dir });
|
2020-06-03 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!found_any_lilv) {
|
2022-04-27 23:01:09 +00:00
|
|
|
std.debug.print("No LILV library was found :(\n", .{});
|
2020-06-03 00:42:26 +00:00
|
|
|
@panic("no lilv found");
|
|
|
|
}
|
2019-08-08 19:48:31 +00:00
|
|
|
}
|
|
|
|
|
2024-06-01 18:46:37 +00:00
|
|
|
pub fn build(b: *std.Build) void {
|
2023-08-05 00:50:59 +00:00
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "scritcher",
|
2024-06-01 18:46:37 +00:00
|
|
|
.root_source_file = b.path("src/main.zig"),
|
2023-08-05 00:50:59 +00:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2019-08-08 19:48:31 +00:00
|
|
|
setupLinks(exe);
|
2023-08-05 00:50:59 +00:00
|
|
|
b.installArtifact(exe);
|
2019-07-22 22:28:55 +00:00
|
|
|
|
2023-08-05 00:50:59 +00:00
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
2019-07-07 05:26:05 +00:00
|
|
|
|
2023-08-05 00:50:59 +00:00
|
|
|
if (b.args) |args| {
|
|
|
|
run_cmd.addArgs(args);
|
|
|
|
}
|
2019-07-05 19:59:45 +00:00
|
|
|
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
|
|
run_step.dependOn(&run_cmd.step);
|
2019-08-08 19:48:31 +00:00
|
|
|
|
2023-08-05 00:50:59 +00:00
|
|
|
const test_step = b.addTest(.{
|
2024-06-01 18:46:37 +00:00
|
|
|
.root_source_file = b.path("src/main.zig"),
|
2023-08-05 00:50:59 +00:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
setupLinks(test_step);
|
|
|
|
const run_unit_tests = b.addRunArtifact(test_step);
|
|
|
|
const test_cmd = b.step("test", "run unit tests");
|
|
|
|
test_cmd.dependOn(&run_unit_tests.step);
|
2019-07-05 19:59:45 +00:00
|
|
|
}
|