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 system_sdk = @import("libs/mach-glfw/system_sdk.zig");
|
||||||
const sysjs = @import("libs/mach-sysjs/build.zig");
|
const sysjs = @import("libs/mach-sysjs/build.zig");
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const mode = b.standardReleaseOptions();
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const sysaudio = sysaudio_sdk.Sdk(.{
|
const sysaudio = sysaudio_sdk.Sdk(.{
|
||||||
.system_sdk = system_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");
|
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{
|
inline for ([_][]const u8{
|
||||||
"sine-wave",
|
"sine-wave",
|
||||||
}) |example| {
|
}) |example| {
|
||||||
const example_exe = b.addExecutable("example-" ++ example, "examples/" ++ example ++ ".zig");
|
const example_exe = b.addExecutable(.{
|
||||||
example_exe.setBuildMode(mode);
|
.name = "example-" ++ example,
|
||||||
example_exe.setTarget(target);
|
.root_source_file = .{ .path = "examples/" ++ example ++ ".zig" },
|
||||||
example_exe.addPackage(sysaudio.pkg);
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
example_exe.addModule("sysaudio", sysaudio.module(b));
|
||||||
sysaudio.link(b, example_exe, .{});
|
sysaudio.link(b, example_exe, .{});
|
||||||
example_exe.install();
|
example_exe.install();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@ const std = @import("std");
|
||||||
|
|
||||||
pub fn Sdk(comptime deps: anytype) type {
|
pub fn Sdk(comptime deps: anytype) type {
|
||||||
return struct {
|
return struct {
|
||||||
pub const pkg = std.build.Pkg{
|
|
||||||
.name = "sysaudio",
|
|
||||||
.source = .{ .path = sdkPath("/src/main.zig") },
|
|
||||||
.dependencies = &.{deps.sysjs.pkg},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
install_libs: bool = false,
|
install_libs: bool = false,
|
||||||
|
|
||||||
|
|
@ -15,16 +9,29 @@ pub fn Sdk(comptime deps: anytype) type {
|
||||||
system_sdk: deps.system_sdk.Options = .{},
|
system_sdk: deps.system_sdk.Options = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget) *std.build.RunStep {
|
pub fn module(b: *std.Build) *std.build.Module {
|
||||||
const main_tests = b.addTestExe("sysaudio-tests", sdkPath("/src/main.zig"));
|
return b.createModule(.{
|
||||||
main_tests.setBuildMode(mode);
|
.source_file = .{ .path = sdkPath("/src/main.zig") },
|
||||||
main_tests.setTarget(target);
|
.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, .{});
|
link(b, main_tests, .{});
|
||||||
main_tests.install();
|
main_tests.install();
|
||||||
return main_tests.run();
|
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) {
|
if (step.target.toTarget().cpu.arch != .wasm32) {
|
||||||
// TODO(build-system): pass system SDK options through
|
// TODO(build-system): pass system SDK options through
|
||||||
deps.system_sdk.include(b, step, .{});
|
deps.system_sdk.include(b, step, .{});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue