aboutsummaryrefslogtreecommitdiffstats
path: root/build.zig
blob: 449c82ea98e3c83c96b436bc9701d12211f7cd41 (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
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, "textures", "enable texture/video support (needs ffmpeg)") orelse true;
    const have_hap = have_ffmpeg and b.option(bool, "hap", "enable HAP GPU upload support (need snappy)") orelse true;

    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);
    exe.root_module.addOptions("build_config", options);

    exe.linkLibC();
    exe.linkSystemLibrary("yaml-0.1");
    exe.linkSystemLibrary("glfw3");
    exe.linkSystemLibrary("epoxy");
    exe.linkSystemLibrary("liblo");

    if (have_ffmpeg) {
        exe.linkSystemLibrary("libavcodec");
        exe.linkSystemLibrary("libavformat");
        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");
    }

    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);
}