Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ Used to generate precompiled-binaries of the C libraries used in Cubyz:
- [glad](https://gen.glad.sh/)
- [portaudio](https://github.com/PortAudio/portaudio)
- [stb_image, stb_image_write, stb_vorbis](https://github.com/nothings/stb)
- [cgltf](https://github.com/jkuhlmann/cgltf)

Issues are tracked on the [main repository](https://github.com/PixelGuys/Cubyz).
18 changes: 13 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,18 @@ pub inline fn addGLFWSources(b: *std.Build, c_lib: *std.Build.Step.Compile, targ
}
}

pub inline fn addHeaderOnlyLibs(b: *std.Build, c_lib: *std.Build.Step.Compile, flags: []const []const u8) void {
const cgltf = b.dependency("cgltf", .{});

c_lib.addIncludePath(cgltf.path(""));
c_lib.installHeader(cgltf.path("cgltf.h"), "cgltf.h");
c_lib.installHeader(b.path("include/stb/stb_image_write.h"), "stb/stb_image_write.h");
c_lib.installHeader(b.path("include/stb/stb_image.h"), "stb/stb_image.h");
c_lib.installHeader(b.path("include/stb/stb_vorbis.h"), "stb/stb_vorbis.h");
c_lib.installHeader(b.path("include/miniaudio.h"), "miniaudio.h");
c_lib.addCSourceFiles(.{.files = &[_][]const u8{"lib/cgltf.c", "lib/stb_image.c", "lib/stb_image_write.c", "lib/stb_vorbis.c", "lib/miniaudio.c"}, .flags = flags});
}

pub inline fn makeCubyzLibs(b: *std.Build, step: *std.Build.Step, name: []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, flags: []const []const u8, replace_tool: *std.Build.Step.Compile) !*std.Build.Step.Compile {
const c_lib = b.addLibrary(.{.name = name, .root_module = b.createModule(.{
.target = target,
Expand All @@ -539,10 +551,7 @@ pub inline fn makeCubyzLibs(b: *std.Build, step: *std.Build.Step, name: []const
c_lib.installHeader(b.path("include/vk_platform.h"), "vk_platform.h");
}

c_lib.installHeader(b.path("include/stb/stb_image_write.h"), "stb/stb_image_write.h");
c_lib.installHeader(b.path("include/stb/stb_image.h"), "stb/stb_image.h");
c_lib.installHeader(b.path("include/stb/stb_vorbis.h"), "stb/stb_vorbis.h");
c_lib.installHeader(b.path("include/miniaudio.h"), "miniaudio.h");
addHeaderOnlyLibs(b, c_lib, flags);
addFreetypeAndHarfbuzz(b, c_lib, target, flags);
if(target.result.os.tag == .macos) {
try addVulkanApple(b, step, c_lib, name, target, flags, replace_tool);
Expand All @@ -555,7 +564,6 @@ pub inline fn makeCubyzLibs(b: *std.Build, step: *std.Build.Step, name: []const
c_lib.addCSourceFile(.{.file = b.path("lib/vulkan.c"), .flags = flags});
}

c_lib.addCSourceFiles(.{.files = &[_][]const u8{"lib/stb_image.c", "lib/stb_image_write.c", "lib/stb_vorbis.c", "lib/miniaudio.c"}, .flags = flags});
const glslang = b.dependency("glslang", .{
.target = target,
.optimize = optimize,
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@
.url = "https://github.com/KhronosGroup/Vulkan-ValidationLayers/archive/refs/tags/v1.4.330.tar.gz",
.hash = "N-V-__8AAHvZ7QLIOvinD_aUpUBYF-rgwHYY6ZQXNHcltRfd",
},
.cgltf = .{
.url = "https://github.com/jkuhlmann/cgltf/archive/refs/tags/v1.15.tar.gz",
.hash = "N-V-__8AAKFjBABZzn84N4iiLQyNQSMVsv5XBJSvZTPcQL2H",
},
},
}
2 changes: 2 additions & 0 deletions lib/cgltf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define CGLTF_IMPLEMENTATION
#include <cgltf.h>