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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
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);
}
|