aboutsummaryrefslogtreecommitdiffstats
path: root/build.zig
blob: 823ba77277925a0f3037154404cca923dd49cd85 (plain)
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
58
59
60
const std = @import("std");

pub fn build(b: *std.Build) void {
    const optimize = b.standardOptimizeOption(.{});
    const target = b.standardTargetOptions(.{});

    const have_ffmpeg = b.option(bool, "ffmpeg", "enable image/video support (needs ffmpeg)") orelse true;
    const have_hap = have_ffmpeg and b.option(bool, "hap", "enable HAP GPU upload support (needs snappy)") orelse true;
    const have_tsv = b.option(bool, "texture-share-vk", "enable GPU image sharing (needs texture-share-vk)") orelse false;
    const have_renderdoc = b.option(bool, "renderdoc", "enable OpenGL dbeugging (needs renderdoc)") orelse false;

    const exe = b.addExecutable(.{
        .name = "glsl-view",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    const options = b.addOptions();
    options.addOption(bool, "have_ffmpeg", have_ffmpeg);
    options.addOption(bool, "have_hap", have_hap);
    options.addOption(bool, "have_tsv", have_tsv);
    options.addOption(bool, "have_renderdoc", have_renderdoc);
    exe.root_module.addOptions("build_config", options);

    exe.linkLibC();
    exe.linkSystemLibrary("glfw3");
    exe.linkSystemLibrary("epoxy");
    exe.linkSystemLibrary("liblo");

    if (have_ffmpeg) {
        exe.linkSystemLibrary("libavcodec");
        exe.linkSystemLibrary("libavformat");
        exe.linkSystemLibrary("libavdevice");
        exe.linkSystemLibrary("libavutil");
        exe.linkSystemLibrary("libswscale");
    }

    if (have_ffmpeg and have_hap) {
        exe.addIncludePath(b.path("lib"));
        exe.addCSourceFile(.{ .file = b.path("lib/hap.c") });
        exe.linkSystemLibrary("snappy");
    }

    if (have_tsv) {
        exe.linkSystemLibrary("texture_share_gl_client");
    }

    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);
    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);
}