-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.zig
57 lines (48 loc) · 2.25 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const std = @import("std");
fn addMupdfDeps(exe: *std.Build.Step.Compile, target: std.Target) void {
if (target.os.tag == .macos and target.cpu.arch == .aarch64) {
exe.addIncludePath(.{ .cwd_relative = "/opt/homebrew/include" });
exe.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" });
} else if (target.os.tag == .macos and target.cpu.arch == .x86_64) {
exe.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
exe.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
} else if (target.os.tag == .linux) {
exe.addIncludePath(.{ .cwd_relative = "/home/linuxbrew/.linuxbrew/include" });
exe.addLibraryPath(.{ .cwd_relative = "/home/linuxbrew/.linuxbrew/lib" });
const linux_libs = [_][]const u8{
"mupdf-third", "harfbuzz",
"freetype", "jbig2dec",
"jpeg", "openjp2",
"gumbo", "mujs",
};
for (linux_libs) |lib| exe.linkSystemLibrary(lib);
}
exe.linkSystemLibrary("mupdf");
exe.linkSystemLibrary("z");
exe.linkLibC();
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "fancy-cat",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.headerpad_max_install_names = true;
const deps = .{
.vaxis = b.dependency("vaxis", .{ .target = target, .optimize = optimize }),
.fzwatch = b.dependency("fzwatch", .{ .target = target, .optimize = optimize }),
.fastb64z = b.dependency("fastb64z", .{ .target = target, .optimize = optimize }),
};
exe.root_module.addImport("fastb64z", deps.fastb64z.module("fastb64z"));
exe.root_module.addImport("vaxis", deps.vaxis.module("vaxis"));
exe.root_module.addImport("fzwatch", deps.fzwatch.module("fzwatch"));
exe.root_module.addImport("config", b.addModule("config", .{ .root_source_file = b.path("src/config.zig") }));
addMupdfDeps(exe, target.result);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
if (b.args) |args| run_cmd.addArgs(args);
b.step("run", "Run the app").dependOn(&run_cmd.step);
}