Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn build(b: *std.Build) void {
.rtcd = b.option(bool, "rtcd", "Enable runtime feature detection") orelse false,
};

const lib, const dynlib, const run_test = buildOpus(b, target, optimize, flags);
const lib, const dynlib, const run_test = buildOpus(b, target, optimize, flags, true);
b.installArtifact(lib);
b.installArtifact(dynlib);
const test_step = b.step("test", "Run unit tests");
Expand All @@ -60,6 +60,7 @@ pub fn buildOpus(
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
flags: BuildFlags,
export_modules: bool,
) struct { *std.Build.Step.Compile, *std.Build.Step.Compile, *std.Build.Step.Run } {
const upstream = b.dependency("upstream", .{});
const arm = target.result.cpu.arch.isArm();
Expand Down Expand Up @@ -151,17 +152,24 @@ pub fn buildOpus(
else
null;

const celt = buildCelt(b, target, optimize, cpu_features, upstream, plc_model, config);
const silk = buildSilk(b, target, optimize, cpu_features, upstream, plc_model, config);
const celt = buildCelt(b, target, optimize, cpu_features, upstream, plc_model, config, export_modules);
const silk = buildSilk(b, target, optimize, cpu_features, upstream, plc_model, config, export_modules);

const tc = b.addTranslateC(.{
.root_source_file = upstream.path("include/opus.h"),
.target = target,
.optimize = optimize,
});
_ = tc.addModule("headers");

const mod = b.addModule("opus", .{
if (export_modules) {
_ = tc.addModule("headers");
}

const mod = if (export_modules) b.addModule("opus", .{
.root_source_file = tc.getOutput(),
.target = target,
.optimize = optimize,
}) else b.createModule(.{
.root_source_file = tc.getOutput(),
.target = target,
.optimize = optimize,
Expand Down Expand Up @@ -426,7 +434,8 @@ pub fn buildOpus(
test_opus_api.root_module.addIncludePath(upstream.path("celt"));

const run_test = b.addRunArtifact(test_opus_api);
run_test.has_side_effects = false;
// run_test.has_side_effects = false;
run_test.expectExitCode(0);

return .{ lib, dynlib, run_test };
}
Expand All @@ -439,8 +448,13 @@ fn buildCelt(
upstream: *std.Build.Dependency,
plc_model: ?*std.Build.Dependency,
config: *std.Build.Step.ConfigHeader,
export_modules: bool,
) *std.Build.Module {
const mod = b.addModule("celt", .{
const mod = if (export_modules) b.addModule("celt", .{
.target = target,
.optimize = optimize,
.link_libc = true,
}) else b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
Expand Down Expand Up @@ -635,8 +649,13 @@ fn buildSilk(
upstream: *std.Build.Dependency,
plc_model: ?*std.Build.Dependency,
config: *std.Build.Step.ConfigHeader,
export_modules: bool,
) *std.Build.Module {
const mod = b.addModule("silk", .{
const mod = if (export_modules) b.addModule("silk", .{
.target = target,
.optimize = optimize,
.link_libc = true,
}) else b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
Expand Down Expand Up @@ -958,15 +977,15 @@ pub fn setupCi(b: *std.Build, target: std.Build.ResolvedTarget) void {
};

for (configs, 0..) |c, idx| {
const native_lib, const native_dynlib, const run_native_test = buildOpus(b, target, .Debug, c);
const native_lib, const native_dynlib, const run_native_test = buildOpus(b, target, .Debug, c, false);
ci.dependOn(&b.addInstallArtifact(native_lib, .{}).step);
ci.dependOn(&b.addInstallArtifact(native_dynlib, .{}).step);
run_native_test.setName(b.fmt("native-test-config #{} - {} ", .{ idx, c }));
ci.dependOn(&run_native_test.step);

for (targets, 0..) |q, qidx| {
const rt = b.resolveTargetQuery(q);
const lib, const dynlib, const run_test = buildOpus(b, rt, .Debug, c);
const lib, const dynlib, const run_test = buildOpus(b, rt, .Debug, c, false);
ci.dependOn(&b.addInstallArtifact(lib, .{}).step);
ci.dependOn(&b.addInstallArtifact(dynlib, .{}).step);
run_test.setName(b.fmt("test-config #{} - target # {} ", .{ idx, qidx }));
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.name = .opus,
.version = "0.0.2",
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0-dev.857+2b2b85c5f",
.fingerprint = 0x8db4fd2c707ee1be,
.dependencies = .{
.upstream = .{
Expand Down
Loading