summaryrefslogtreecommitdiff
path: root/tools/gltf_bindings.zig
blob: 59695d824fb64a51505b2e9b3f5202e3ab65f9cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Host build tool: input glTF/GLB -> output Zig source, before app compilation.
const std = @import("std");
const gltf = @import("gltf");

pub fn main(init: std.process.Init) !void {
    var args = init.minimal.args.iterate();
    _ = args.skip();
    const input = args.next() orelse return error.ExpectedGltfPath;
    const output = args.next() orelse return error.ExpectedZigPath;
    const a = init.arena.allocator();
    const bytes = try std.Io.Dir.cwd().readFileAlloc(init.io, input, a, .limited(64 << 20));
    const source = try gltf.generate(a, bytes, input);
    try std.Io.Dir.cwd().writeFile(init.io, .{ .sub_path = output, .data = source });
}