wip
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
|||||||
[submodule "3rd/glfw"]
|
|
||||||
path = 3rd/glfw
|
|
||||||
url = https://github.com/glfw/glfw.git
|
|
||||||
[submodule "omt-examples"]
|
[submodule "omt-examples"]
|
||||||
path = omt/3rd/omt-examples
|
path = omt/3rd/omt-examples
|
||||||
url = https://github.com/openmediatransport/Examples.git
|
url = https://github.com/openmediatransport/Examples.git
|
||||||
|
|||||||
1
3rd/glfw
1
3rd/glfw
Submodule 3rd/glfw deleted from 7b6aead9fb
10
build.zig
10
build.zig
@@ -15,10 +15,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const zomt = b.dependency("zomt", .{
|
const zomt_dep = b.dependency("zomt", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
}).module("zomt");
|
});
|
||||||
|
const zomt_mod = zomt_dep.module("zomt");
|
||||||
|
|
||||||
const exe = b.addExecutable((.{
|
const exe = b.addExecutable((.{
|
||||||
.name = "omtoy",
|
.name = "omtoy",
|
||||||
@@ -29,7 +30,10 @@ pub fn build(b: *std.Build) void {
|
|||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
exe.root_module.addImport("zomt", zomt);
|
// exe.root_module.addLibraryPath(zomt_dep.namedLazyPath("output_dir"));
|
||||||
|
exe.root_module.addIncludePath(zomt_dep.namedLazyPath("output_dir"));
|
||||||
|
// exe.root_module.linkSystemLibrary("omt", .{});
|
||||||
|
exe.root_module.addImport("zomt", zomt_mod);
|
||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
|
|||||||
151
omt/build.zig
151
omt/build.zig
@@ -3,8 +3,6 @@
|
|||||||
//
|
//
|
||||||
// Build required OMT parts and link against our code
|
// Build required OMT parts and link against our code
|
||||||
//
|
//
|
||||||
// Run `zig build omt` to build dependencies before anything else.
|
|
||||||
//
|
|
||||||
// I don't know yet how to best create a conditional step to build and install
|
// I don't know yet how to best create a conditional step to build and install
|
||||||
// the dependencies only if they aren't installed yet. Just putting the installs
|
// the dependencies only if they aren't installed yet. Just putting the installs
|
||||||
// as dependencies runs the omt build scripts on every `zig build`.
|
// as dependencies runs the omt build scripts on every `zig build`.
|
||||||
@@ -27,86 +25,89 @@ pub fn build(b: *std.Build) void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This path comes from the libomt build scripts
|
||||||
|
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
||||||
|
const output_dir_path: std.Build.LazyPath = .{
|
||||||
|
.src_path = .{
|
||||||
|
.owner = b,
|
||||||
|
.sub_path = omt_out_path,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
b.addNamedLazyPath("output_dir", output_dir_path);
|
||||||
|
|
||||||
// The output lib and header directories
|
// The output lib and header directories
|
||||||
const lib_output_path: std.Build.LazyPath = .{
|
const lib_output_path: std.Build.LazyPath = .{
|
||||||
.cwd_relative = b.lib_dir,
|
.cwd_relative = b.getInstallPath(.lib, ""),
|
||||||
};
|
};
|
||||||
const include_output_path: std.Build.LazyPath = .{
|
const include_output_path: std.Build.LazyPath = .{
|
||||||
.cwd_relative = b.h_dir,
|
.cwd_relative = b.getInstallPath(.header, ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
const omt_module = b.addModule("zomt", .{
|
std.debug.print("install-path: {s}\n", .{b.getInstallPath(.prefix, "")});
|
||||||
|
std.debug.print("lib_output_path: {s}\n", .{lib_output_path.getDisplayName()});
|
||||||
|
std.debug.print("include_output_path: {s}\n", .{include_output_path.getDisplayName()});
|
||||||
|
|
||||||
|
// zomt module
|
||||||
|
const omt_mod = b.addModule("zomt", .{
|
||||||
.root_source_file = b.path("src/omt.zig"),
|
.root_source_file = b.path("src/omt.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
const omt = b.addLibrary(.{
|
omt_mod.addLibraryPath(output_dir_path);
|
||||||
.name = "zomt",
|
omt_mod.addIncludePath(output_dir_path);
|
||||||
.linkage = .static,
|
omt_mod.linkSystemLibrary("omt", .{});
|
||||||
.root_module = omt_module,
|
|
||||||
});
|
|
||||||
|
|
||||||
omt.root_module.linkSystemLibrary("omt", .{});
|
// Build libomtnet
|
||||||
omt.root_module.addLibraryPath(lib_output_path);
|
const libomtnet_build_script = b.addSystemCommand(&.{"bash"});
|
||||||
omt.root_module.addIncludePath(include_output_path);
|
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
|
||||||
b.installArtifact(omt);
|
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
|
||||||
|
|
||||||
|
// Build libomt
|
||||||
|
const libomt_build_script = b.addSystemCommand(&.{"bash"});
|
||||||
|
libomt_build_script.cwd = b.path("3rd/libomt/build");
|
||||||
|
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
|
||||||
|
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
|
||||||
|
|
||||||
|
// Install libomt
|
||||||
|
const install_omt_h = b.addInstallHeaderFile(
|
||||||
|
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
|
||||||
|
"libomt.h",
|
||||||
|
);
|
||||||
|
install_omt_h.step.dependOn(&libomt_build_script.step);
|
||||||
|
|
||||||
|
const install_omt_so = b.addInstallLibFile(
|
||||||
|
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
|
||||||
|
"libomt.so",
|
||||||
|
);
|
||||||
|
install_omt_so.step.dependOn(&libomt_build_script.step);
|
||||||
|
|
||||||
|
// Build libvmx
|
||||||
|
const libvmx_build = b.addSystemCommand(&.{"bash"});
|
||||||
|
libvmx_build.cwd = b.path("3rd/libvmx/build");
|
||||||
|
libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
|
||||||
|
|
||||||
|
// Install libvmx
|
||||||
|
const install_vmx_so = b.addInstallLibFile(
|
||||||
|
b.path("3rd/libvmx/build/libvmx.so"),
|
||||||
|
"libvmx.so",
|
||||||
|
);
|
||||||
|
install_vmx_so.step.dependOn(&libvmx_build.step);
|
||||||
|
|
||||||
|
// Add object as dependency for module
|
||||||
|
const libomtso_path = b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" }));
|
||||||
|
// Has no discernable effect atm
|
||||||
|
omt_mod.addObjectFile(libomtso_path);
|
||||||
|
|
||||||
{
|
{
|
||||||
// This comes from the libomt build scripts
|
// Manual build step for libomt dependencies
|
||||||
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
||||||
|
build_omt_step.dependOn(&install_omt_h.step);
|
||||||
// Build libomtnet
|
build_omt_step.dependOn(&install_omt_so.step);
|
||||||
const libomtnet_build_script = b.addSystemCommand(&.{"bash"});
|
build_omt_step.dependOn(&install_vmx_so.step);
|
||||||
libomtnet_build_script.cwd = b.path("3rd/libomtnet/build");
|
|
||||||
libomtnet_build_script.addFileArg(b.path("3rd/libomtnet/build/buildall.sh"));
|
|
||||||
|
|
||||||
// Build libomt
|
|
||||||
const libomt_build_script = b.addSystemCommand(&.{"bash"});
|
|
||||||
libomt_build_script.cwd = b.path("3rd/libomt/build");
|
|
||||||
libomt_build_script.addFileArg(b.path("3rd/libomt/build/buildlinuxx64.sh"));
|
|
||||||
libomt_build_script.step.dependOn(&libomtnet_build_script.step);
|
|
||||||
|
|
||||||
// Install libomt
|
|
||||||
const install_omt_h = b.addInstallHeaderFile(
|
|
||||||
b.path(b.pathJoin(&.{ omt_out_path, "libomt.h" })),
|
|
||||||
"libomt.h",
|
|
||||||
);
|
|
||||||
install_omt_h.step.dependOn(&libomt_build_script.step);
|
|
||||||
|
|
||||||
const install_omt_so = b.addInstallLibFile(
|
|
||||||
b.path(b.pathJoin(&.{ omt_out_path, "libomt.so" })),
|
|
||||||
"libomt.so",
|
|
||||||
);
|
|
||||||
install_omt_so.step.dependOn(&libomt_build_script.step);
|
|
||||||
|
|
||||||
// Build libvmx
|
|
||||||
const libvmx_build = b.addSystemCommand(&.{"bash"});
|
|
||||||
libvmx_build.cwd = b.path("3rd/libvmx/build");
|
|
||||||
libvmx_build.addFileArg(b.path("3rd/libvmx/build/buildlinuxx64.sh"));
|
|
||||||
|
|
||||||
// Install libvmx
|
|
||||||
const install_vmx_so = b.addInstallLibFile(
|
|
||||||
b.path("3rd/libvmx/build/libvmx.so"),
|
|
||||||
"libvmx.so",
|
|
||||||
);
|
|
||||||
install_vmx_so.step.dependOn(&libvmx_build.step);
|
|
||||||
|
|
||||||
{
|
|
||||||
// Module dependencies
|
|
||||||
omt.step.dependOn(&install_omt_h.step);
|
|
||||||
omt.step.dependOn(&install_omt_so.step);
|
|
||||||
omt.step.dependOn(&install_vmx_so.step);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Manual build step for libomt dependencies
|
|
||||||
const build_omt_step = b.step("omt", "Build libomtnet, libomt and libvmx");
|
|
||||||
build_omt_step.dependOn(&install_omt_h.step);
|
|
||||||
build_omt_step.dependOn(&install_omt_so.step);
|
|
||||||
build_omt_step.dependOn(&install_vmx_so.step);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test executables
|
||||||
{
|
{
|
||||||
// Define executables
|
// Define executables
|
||||||
const sender_exe = b.addExecutable(.{
|
const sender_exe = b.addExecutable(.{
|
||||||
@@ -117,8 +118,13 @@ pub fn build(b: *std.Build) void {
|
|||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
// sender_exe.root_module.addImport("omt", omt);
|
sender_exe.root_module.addImport("omt", omt_mod);
|
||||||
sender_exe.root_module.linkLibrary(omt);
|
|
||||||
|
// These cause invocations for every zig build command, even tho it's not
|
||||||
|
// usually needed, so prefer to use a manual step
|
||||||
|
sender_exe.step.dependOn(&install_omt_h.step);
|
||||||
|
sender_exe.step.dependOn(&install_omt_so.step);
|
||||||
|
sender_exe.step.dependOn(&install_vmx_so.step);
|
||||||
|
|
||||||
sender_exe.root_module.addLibraryPath(lib_output_path);
|
sender_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
sender_exe.root_module.addIncludePath(include_output_path);
|
sender_exe.root_module.addIncludePath(include_output_path);
|
||||||
@@ -137,8 +143,13 @@ pub fn build(b: *std.Build) void {
|
|||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
receiver_exe.root_module.linkLibrary(omt);
|
receiver_exe.root_module.addImport("omt", omt_mod);
|
||||||
receiver_exe.root_module.addImport("omt", omt.root_module);
|
|
||||||
|
// These cause invocations for every zig build command, even tho it's not
|
||||||
|
// usually needed, so prefer to use a manual step
|
||||||
|
receiver_exe.step.dependOn(&install_omt_h.step);
|
||||||
|
receiver_exe.step.dependOn(&install_omt_so.step);
|
||||||
|
receiver_exe.step.dependOn(&install_vmx_so.step);
|
||||||
|
|
||||||
receiver_exe.root_module.addLibraryPath(lib_output_path);
|
receiver_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
receiver_exe.root_module.addIncludePath(include_output_path);
|
receiver_exe.root_module.addIncludePath(include_output_path);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
// It is redundant to include "zig" in this name because it is already
|
// It is redundant to include "zig" in this name because it is already
|
||||||
// within the Zig package namespace.
|
// within the Zig package namespace.
|
||||||
.name = .omt,
|
.name = .zomt,
|
||||||
// This is a [Semantic Version](https://semver.org/).
|
// This is a [Semantic Version](https://semver.org/).
|
||||||
// In a future version of Zig it will be used for package deduplication.
|
// In a future version of Zig it will be used for package deduplication.
|
||||||
.version = "0.0.1",
|
.version = "0.0.1",
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
// original project's identity. Thus it is recommended to leave the comment
|
// original project's identity. Thus it is recommended to leave the comment
|
||||||
// on the following line intact, so that it shows up in code reviews that
|
// on the following line intact, so that it shows up in code reviews that
|
||||||
// modify the field.
|
// modify the field.
|
||||||
.fingerprint = 0x3bf1f5c0d8810f0f, // Changing this has security and trust implications.
|
.fingerprint = 0xe176b336b44e42a7,
|
||||||
// Tracks the earliest Zig version that the package considers to be a
|
// Tracks the earliest Zig version that the package considers to be a
|
||||||
// supported use case.
|
// supported use case.
|
||||||
.minimum_zig_version = "0.16.0-dev.699+529aa9f27",
|
.minimum_zig_version = "0.16.0-dev.699+529aa9f27",
|
||||||
|
|||||||
27
src/main.zig
27
src/main.zig
@@ -1,6 +1,31 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const omt = @import("omt");
|
const c = @cImport(@cInclude("libomt.h"));
|
||||||
|
|
||||||
|
fn discoverStream() ?[*c]u8 {
|
||||||
|
var discovery_count: i32 = 0;
|
||||||
|
|
||||||
|
while (discovery_count == 0) {
|
||||||
|
const discovered = c.omt_discovery_getaddresses(&discovery_count);
|
||||||
|
std.log.info("Found {} streams:", .{discovery_count});
|
||||||
|
|
||||||
|
const count: usize = @intCast(discovery_count);
|
||||||
|
for (0..count) |i| {
|
||||||
|
const name = discovered[i];
|
||||||
|
std.log.info(" {s}", .{name});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (discovery_count > 0) {
|
||||||
|
return discovered[0];
|
||||||
|
}
|
||||||
|
std.Thread.sleep(1000 * 1000 * 1000);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
std.log.info("Starting omtoy...", .{});
|
std.log.info("Starting omtoy...", .{});
|
||||||
|
c.omt_setloggingfilename("omtoy-omt.log");
|
||||||
|
|
||||||
|
// _ = discoverStream() orelse undefined;
|
||||||
|
std.log.info("Exiting omtoy!", .{});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user