e37af094
Gregory Mullen
const std = @import("std");
e37af094
Gregory Mullen
e37af094
Gregory Mullen
// Although this function looks imperative, note that its job is to
e37af094
Gregory Mullen
// declaratively construct a build graph that will be executed by an external
e37af094
Gregory Mullen
// runner.
e37af094
Gregory Mullen
pub fn build(b: *std.Build) void {
e37af094
Gregory Mullen
const target = b.standardTargetOptions(.{});
e37af094
Gregory Mullen
const optimize = b.standardOptimizeOption(.{});
e37af094
Gregory Mullen
82a613e3
Gregory Mullen
const lib = b.addSharedLibrary(.{
82a613e3
Gregory Mullen
.name = "obs-sway-focus",
82a613e3
Gregory Mullen
.root_source_file = .{ .path = "src/root.zig" },
3d83e7dd
Gregory Mullen
.target = target,
3d83e7dd
Gregory Mullen
.optimize = optimize,
3d83e7dd
Gregory Mullen
});
3d83e7dd
Gregory Mullen
82a613e3
Gregory Mullen
const obs = b.dependency("obzig-plugin", .{
e37af094
Gregory Mullen
.target = target,
e37af094
Gregory Mullen
.optimize = optimize,
e37af094
Gregory Mullen
});
82a613e3
Gregory Mullen
82a613e3
Gregory Mullen
lib.root_module.addImport("OBS", obs.module("OBS"));
82a613e3
Gregory Mullen
lib.linkLibrary(obs.artifact("obzig-plugin"));
82a613e3
Gregory Mullen
e37af094
Gregory Mullen
b.getInstallStep().dependOn(
e37af094
Gregory Mullen
&b.addInstallArtifact(lib, .{
e37af094
Gregory Mullen
.dest_dir = .{ .override = std.Build.InstallDir{ .custom = "" } },
e37af094
Gregory Mullen
.dest_sub_path = "obs-sway-focus/bin/64bit/obs-sway-focus.so",
e37af094
Gregory Mullen
}).step,
e37af094
Gregory Mullen
);
e37af094
Gregory Mullen
e37af094
Gregory Mullen
const lib_unit_tests = b.addTest(.{
e37af094
Gregory Mullen
.root_source_file = .{ .path = "src/root.zig" },
e37af094
Gregory Mullen
.target = target,
e37af094
Gregory Mullen
.optimize = optimize,
e37af094
Gregory Mullen
});
c0e2dddb
Gregory Mullen
lib_unit_tests.linkLibC();
e37af094
Gregory Mullen
e37af094
Gregory Mullen
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
e37af094
Gregory Mullen
e37af094
Gregory Mullen
const test_step = b.step("test", "Run unit tests");
e37af094
Gregory Mullen
test_step.dependOn(&run_lib_unit_tests.step);
e37af094
Gregory Mullen
}