added zig-gobject dep and build fails

This commit is contained in:
Nicholas Young 2024-10-22 18:36:15 -07:00
parent 20d3767031
commit 1fbbd80dc9
3 changed files with 40 additions and 6 deletions

View file

@ -15,6 +15,7 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize. // set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const gobject = b.dependency("gobject", .{});
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "zig-gst", .name = "zig-gst",
@ -51,6 +52,11 @@ pub fn build(b: *std.Build) void {
} }
exe.linkSystemLibrary("c"); exe.linkSystemLibrary("c");
exe.root_module.addImport("glib", gobject.module("glib2"));
exe.root_module.addImport("gobject", gobject.module("gobject2"));
exe.root_module.addImport("gst", gobject.module("gst1"));
exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0", .{gst_dev_path.?}) }); // not sure why both are needed, but exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0", .{gst_dev_path.?}) }); // not sure why both are needed, but
exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0/gst", .{gst_dev_path.?}) }); // it won't compile without them exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0/gst", .{gst_dev_path.?}) }); // it won't compile without them
exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0", .{gst_plugins_base_dev_path.?}) }); // needed for header resolution of below dep exe.addIncludePath(.{ .cwd_relative = b.fmt("{s}/include/gstreamer-1.0", .{gst_plugins_base_dev_path.?}) }); // needed for header resolution of below dep

17
build.zig.zon Normal file
View file

@ -0,0 +1,17 @@
.{
.name = "HailoImageProcessor",
.version = "0.0.0",
.paths = .{
"src",
"flake.nix",
"flake.lock",
"build.nix",
"README.md",
},
.dependencies = .{
.gobject = .{
.url = "https://github.com/ianprime0509/zig-gobject/releases/download/v0.2.2/bindings-gnome47.tar.zst",
.hash = "12208d70ee791d7ef7e16e1c3c9c1127b57f1ed066a24f87d57fc9f730c5dc394b9d",
},
}
}

View file

@ -1,12 +1,23 @@
const std = @import("std"); const std = @import("std");
const gst = @cImport({ // glib-object for g_object_* functions const hlo = @cImport({
@cInclude("glib-object.h"); @cInclude("hailort.h");
@cInclude("glib.h"); // and glib for other g_* functions });
@cInclude("gst.h"); const gst_app = @cImport({ // glib-object for g_object_* functions
@cInclude("gst/app/gstappsrc.h"); // because I don't want two include paths for header file name resolution @cInclude("gstappsrc.h");
}); });
pub fn main() void { const gst = @import("gst");
const glib = @import("glib");
const gobject = @import("gobject");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const hef_file = "yolov7.hef";
const max_edge_layers = 32;
pub fn main() !void {
// This allows me to utilize the same command line args and gstreamer // This allows me to utilize the same command line args and gstreamer
gst.gst_init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr)); gst.gst_init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr));