2021-11-04 22:37:18 +00:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
pub fn build(b: *std.build.Builder) void {
|
|
|
|
// Standard target options allows the person running `zig build` to choose
|
|
|
|
// what target to build for. Here we do not override the defaults, which
|
|
|
|
// means any target is allowed, and the default is native. Other options
|
|
|
|
// for restricting supported target set are available.
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
|
|
|
|
// Standard release options allow the person running `zig build` to select
|
|
|
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
|
|
|
const mode = b.standardReleaseOptions();
|
|
|
|
|
2021-11-17 18:56:09 +00:00
|
|
|
const exe = switch (target.getOs().tag) {
|
|
|
|
.linux => b.addExecutable("clipboard", "src/main-linux.zig"),
|
|
|
|
.windows => b.addExecutable("clipboard", "src/main-windows.zig"),
|
|
|
|
else => std.os.exit(1),
|
|
|
|
};
|
|
|
|
|
2021-11-04 22:37:18 +00:00
|
|
|
exe.setTarget(target);
|
|
|
|
exe.setBuildMode(mode);
|
2021-11-17 18:56:09 +00:00
|
|
|
exe.linkLibC();
|
2021-11-09 18:43:25 +00:00
|
|
|
if (target.getOs().tag == .linux) {
|
2021-11-09 04:47:48 +00:00
|
|
|
// LibX11 1.7.2: https://gitlab.freedesktop.org/xorg/lib/libx11/-/archive/libX11-1.7.2/libx11-libX11-1.7.2.tar.gz
|
|
|
|
// LibXfixes 5.0.3: https://gitlab.freedesktop.org/xorg/lib/libxfixes/-/archive/libXfixes-5.0.3/libxfixes-libXfixes-5.0.3.tar.gz
|
|
|
|
// XOrg Proto: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/archive/xorgproto-2021.5/xorgproto-xorgproto-2021.5.tar.gz
|
|
|
|
// We can download the above by taking each url and processing in a
|
|
|
|
// command e.g.:
|
|
|
|
// curl <url> | tar xz --wildcards '*.h'
|
|
|
|
exe.addIncludeDir("libx11-libX11-1.7.2/include");
|
|
|
|
exe.addIncludeDir("libxfixes-libXfixes-5.0.3/include");
|
|
|
|
exe.addIncludeDir("xorgproto-xorgproto-2021.5/include");
|
|
|
|
|
|
|
|
// More than a little messy. We're grabbing libX11 and libXfixes from
|
|
|
|
// the host, while using downloaded headers. This assumes debian
|
|
|
|
// bullseye host, and also means you can't cross-compile from Windows.
|
|
|
|
// TODO: Make this better
|
|
|
|
const dependent_objects = .{
|
|
|
|
"/usr/lib/x86_64-linux-gnu/libX11.so.6",
|
|
|
|
"/usr/lib/x86_64-linux-gnu/libXfixes.so.3",
|
|
|
|
};
|
|
|
|
inline for (dependent_objects) |obj|
|
|
|
|
exe.addObjectFile(obj);
|
2021-11-04 22:37:18 +00:00
|
|
|
}
|
2021-11-09 18:43:25 +00:00
|
|
|
if (target.getOs().tag == .windows) {
|
2021-11-04 22:37:18 +00:00
|
|
|
// exe.linkLibC();
|
|
|
|
// exe.addIncludeDir("/usr/include/");
|
|
|
|
// exe.linkSystemLibrary("X11");
|
|
|
|
}
|
|
|
|
exe.install();
|
|
|
|
|
|
|
|
const run_cmd = exe.run();
|
|
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
if (b.args) |args| {
|
|
|
|
run_cmd.addArgs(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
}
|