aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-03-05 17:12:36 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-05 17:35:57 +0000
commita514ba9eebd9316136c45ae6396b4ca6984b6859 (patch)
tree06bf0f85c721a4c954a563fdc4bb6a7d540f58e6
parentfix shader reloading wrt Textures (diff)
downloadglsl-view-a514ba9eebd9316136c45ae6396b4ca6984b6859.tar.gz
glsl-view-a514ba9eebd9316136c45ae6396b4ca6984b6859.zip
allow disabling texture/ffmpeg support at build time
-rw-r--r--build.zig19
-rw-r--r--src/c.zig12
-rw-r--r--src/control.zig2
3 files changed, 25 insertions, 8 deletions
diff --git a/build.zig b/build.zig
index db0145c..9c842a6 100644
--- a/build.zig
+++ b/build.zig
@@ -4,21 +4,32 @@ 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 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);
+ exe.root_module.addOptions("build_config", options);
+
exe.linkLibC();
exe.linkSystemLibrary("yaml-0.1");
exe.linkSystemLibrary("glfw3");
exe.linkSystemLibrary("epoxy");
exe.linkSystemLibrary("liblo");
- exe.linkSystemLibrary("libavcodec");
- exe.linkSystemLibrary("libavformat");
- exe.linkSystemLibrary("libavutil");
- exe.linkSystemLibrary("libswscale");
+
+ if (have_ffmpeg) {
+ exe.linkSystemLibrary("libavcodec");
+ exe.linkSystemLibrary("libavformat");
+ exe.linkSystemLibrary("libavutil");
+ exe.linkSystemLibrary("libswscale");
+ }
+
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
diff --git a/src/c.zig b/src/c.zig
index b46d0f4..7b46914 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -1,10 +1,14 @@
+const build_config = @import("build_config");
+
pub usingnamespace @cImport({
@cInclude("epoxy/gl.h");
@cInclude("GLFW/glfw3.h");
@cInclude("yaml.h");
@cInclude("lo/lo.h");
- @cInclude("lo/lo.h");
- @cInclude("libavcodec/avcodec.h");
- @cInclude("libavformat/avformat.h");
- @cInclude("libswscale/swscale.h");
+
+ if (build_config.have_ffmpeg) {
+ @cInclude("libavcodec/avcodec.h");
+ @cInclude("libavformat/avformat.h");
+ @cInclude("libswscale/swscale.h");
+ }
});
diff --git a/src/control.zig b/src/control.zig
index 3331d4c..0449b3d 100644
--- a/src/control.zig
+++ b/src/control.zig
@@ -3,6 +3,7 @@ const gl = @import("gl.zig");
const video = @import("video.zig");
const std = @import("std");
const cfg = @import("config.zig");
+const build_config = @import("build_config");
fn verify_args(expected: u8, got: []const u8) !void {
for (got) |typ| {
@@ -95,6 +96,7 @@ fn set_texture(
argv: [*c][*c]c.lo_arg,
types: []const u8,
) !void {
+ if (!build_config.have_ffmpeg) return error.texturesDisabled;
if (argc != 1 or types[0] != 's') return error.invalidType;
if (dest.*) |old| {