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 exe = b.addExecutable(.{ .name = "glsl-view", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .optimize = optimize, .target = target, }), }); 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); exe.root_module.addOptions("build_config", options); exe.linkLibC(); exe.linkSystemLibrary("glfw3"); exe.linkSystemLibrary("epoxy"); exe.linkSystemLibrary("liblo"); if (have_ffmpeg) { exe.linkSystemLibrary("avcodec"); exe.linkSystemLibrary("avformat"); exe.linkSystemLibrary("avdevice"); exe.linkSystemLibrary("avutil"); exe.linkSystemLibrary("swscale"); } 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); const test_options = b.addOptions(); test_options.addOption(bool, "have_ffmpeg", false); test_options.addOption(bool, "have_hap", false); test_options.addOption(bool, "have_tsv", false); const test_step = b.step("test", "Run unit tests"); const test_module = b.createModule(.{ .root_source_file = b.path("src/gl.zig"), .target = target, }); test_module.addOptions("build_config", test_options); const tests = b.addTest(.{ .root_module = test_module, }); tests.linkLibC(); tests.linkSystemLibrary("glfw3"); tests.linkSystemLibrary("epoxy"); const run_unit_tests = b.addRunArtifact(tests); test_step.dependOn(&run_unit_tests.step); }