Backlog/lib/theoratest/build.zig

130 lines
4.0 KiB
Zig

const std = @import("std");
const bh = @import("bh");
pub fn build(b: *std.Build) void {
const opts = bh.declareOptions(b);
const theorafile = b.addModule(
"theorafile",
.{
.optimize = opts.optimize,
.target = opts.target,
.root_source_file = b.path("theorafile.zig"),
.link_libc = true,
},
);
const sdl_dep = b.dependency("sdl", .{
.target = opts.target,
.optimize = opts.optimize,
});
const sdl_lib = sdl_dep.artifact("SDL3");
theorafile.linkLibrary(sdl_lib);
theorafile.addIncludePath(b.path("../sdl3/SDL/include"));
theorafile.addIncludePath(b.path("lib/ogg"));
theorafile.addIncludePath(b.path("lib/theora"));
theorafile.addIncludePath(b.path("lib/vorbis"));
theorafile.addIncludePath(b.path("lib"));
theorafile.addIncludePath(b.path("."));
theorafile.addCSourceFiles(.{
.files = &.{
"theorafile.c",
"lib/ogg/bitwise.c",
"lib/ogg/framing.c",
"lib/vorbis/analysis.c",
"lib/vorbis/bitrate.c",
"lib/vorbis/block.c",
"lib/vorbis/codebook.c",
"lib/vorbis/envelope.c",
"lib/vorbis/floor0.c",
"lib/vorbis/floor1.c",
"lib/vorbis/vinfo.c",
"lib/vorbis/lookup.c",
"lib/vorbis/lpc.c",
"lib/vorbis/lsp.c",
"lib/vorbis/mapping0.c",
"lib/vorbis/mdct.c",
"lib/vorbis/psy.c",
"lib/vorbis/registry.c",
"lib/vorbis/res0.c",
"lib/vorbis/sharedbook.c",
"lib/vorbis/smallft.c",
"lib/vorbis/synthesis.c",
"lib/vorbis/window.c",
"lib/theora/apiwrapper.c",
"lib/theora/bitpack.c",
"lib/theora/decapiwrapper.c",
"lib/theora/decinfo.c",
"lib/theora/decode.c",
"lib/theora/dequant.c",
"lib/theora/fragment.c",
"lib/theora/huffdec.c",
"lib/theora/idct.c",
"lib/theora/tinfo.c",
"lib/theora/internal.c",
"lib/theora/quant.c",
"lib/theora/state.c",
},
.flags = &.{
"-fno-sanitize=undefined",
},
});
theorafile.addCSourceFiles(.{
.files = &.{
"lib/theora/x86/mmxfrag.c",
"lib/theora/x86/mmxidct.c",
"lib/theora/x86/mmxstate.c",
"lib/theora/x86/sse2idct.c",
"lib/theora/x86/x86cpu.c",
"lib/theora/x86/x86state.c",
},
.flags = &.{
"-fno-sanitize=undefined",
},
});
// TFSRC_ARCH_X86 ="
// lib/theora/x86/mmxfrag.c \
// lib/theora/x86/mmxidct.c \
// lib/theora/x86/mmxstate.c \
// lib/theora/x86/sse2idct.c \
// lib/theora/x86/x86cpu.c \
// lib/theora/x86/x86state.c
// link theorafile
const test_step = b.step("test", "run unit tests for sdl3");
const tests = b.addExecutable(.{
.name = "test",
.root_module = b.createModule(.{
.target = opts.target,
.optimize = opts.optimize,
.link_libc = true,
.root_source_file = b.path("sdl3test/sdl3test.zig"),
}),
});
tests.addCSourceFile(.{
.file = b.path("sdl3test/sdl3test.c"),
.flags = &.{
"-fno-sanitize=undefined",
},
});
tests.root_module.addImport("theorafile", theorafile);
tests.root_module.addIncludePath(b.path("../sdl3/SDL/include"));
tests.root_module.addIncludePath(b.path("lib/ogg"));
tests.root_module.addIncludePath(b.path("lib/theora"));
tests.root_module.addIncludePath(b.path("lib/vorbis"));
tests.root_module.addIncludePath(b.path("lib"));
tests.root_module.addIncludePath(b.path("."));
tests.root_module.addIncludePath(b.path("sdl3test"));
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
b.installArtifact(tests);
}