sysaudio: update to latest Zig build API
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
ddb728d74d
commit
46a805bc90
2 changed files with 28 additions and 18 deletions
|
|
@ -3,8 +3,8 @@ const sysaudio_sdk = @import("sdk.zig");
|
|||
const system_sdk = @import("libs/mach-glfw/system_sdk.zig");
|
||||
const sysjs = @import("libs/mach-sysjs/build.zig");
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
pub fn build(b: *std.Build) void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const sysaudio = sysaudio_sdk.Sdk(.{
|
||||
.system_sdk = system_sdk,
|
||||
|
|
@ -12,15 +12,18 @@ pub fn build(b: *std.build.Builder) void {
|
|||
});
|
||||
|
||||
const test_step = b.step("test", "Run library tests");
|
||||
test_step.dependOn(&sysaudio.testStep(b, mode, target).step);
|
||||
test_step.dependOn(&sysaudio.testStep(b, optimize, target).step);
|
||||
|
||||
inline for ([_][]const u8{
|
||||
"sine-wave",
|
||||
}) |example| {
|
||||
const example_exe = b.addExecutable("example-" ++ example, "examples/" ++ example ++ ".zig");
|
||||
example_exe.setBuildMode(mode);
|
||||
example_exe.setTarget(target);
|
||||
example_exe.addPackage(sysaudio.pkg);
|
||||
const example_exe = b.addExecutable(.{
|
||||
.name = "example-" ++ example,
|
||||
.root_source_file = .{ .path = "examples/" ++ example ++ ".zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
example_exe.addModule("sysaudio", sysaudio.module(b));
|
||||
sysaudio.link(b, example_exe, .{});
|
||||
example_exe.install();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@ const std = @import("std");
|
|||
|
||||
pub fn Sdk(comptime deps: anytype) type {
|
||||
return struct {
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "sysaudio",
|
||||
.source = .{ .path = sdkPath("/src/main.zig") },
|
||||
.dependencies = &.{deps.sysjs.pkg},
|
||||
};
|
||||
|
||||
pub const Options = struct {
|
||||
install_libs: bool = false,
|
||||
|
||||
|
|
@ -15,16 +9,29 @@ pub fn Sdk(comptime deps: anytype) type {
|
|||
system_sdk: deps.system_sdk.Options = .{},
|
||||
};
|
||||
|
||||
pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget) *std.build.RunStep {
|
||||
const main_tests = b.addTestExe("sysaudio-tests", sdkPath("/src/main.zig"));
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = sdkPath("/src/main.zig") },
|
||||
.dependencies = &.{
|
||||
.{ .name = "sysjs", .module = deps.sysjs.module(b) },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
pub fn testStep(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *std.build.RunStep {
|
||||
const main_tests = b.addTest(.{
|
||||
.name = "sysaudio-tests",
|
||||
.kind = .test_exe,
|
||||
.root_source_file = .{ .path = sdkPath("/src/main.zig") },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
link(b, main_tests, .{});
|
||||
main_tests.install();
|
||||
return main_tests.run();
|
||||
}
|
||||
|
||||
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
||||
pub fn link(b: *std.Build, step: *std.build.CompileStep, options: Options) void {
|
||||
if (step.target.toTarget().cpu.arch != .wasm32) {
|
||||
// TODO(build-system): pass system SDK options through
|
||||
deps.system_sdk.include(b, step, .{});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue