support linux arm64, riscv64, and x86_64
This commit is contained in:
parent
9afbdb5958
commit
4b9f838328
2 changed files with 29 additions and 8 deletions
24
build.zig
24
build.zig
|
@ -4,8 +4,13 @@ pub fn build(b: *std.Build) void {
|
|||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const vosk_dep = b.dependency("vosk_linux_x86_64", .{});
|
||||
const alsa_dep = b.dependency("alsa", .{});
|
||||
// Select Vosk dependency based on target
|
||||
const vosk_dep_name = selectVoskDependency(target.result);
|
||||
const vosk_dep = b.dependency(vosk_dep_name, .{});
|
||||
const alsa_dep = b.dependency("alsa", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// We need to use curl for this as the domain doesn't work with zig TLS
|
||||
const model_step = ModelDownloadStep.create(b);
|
||||
|
@ -31,12 +36,10 @@ pub fn build(b: *std.Build) void {
|
|||
exe.linkLibC();
|
||||
exe.addIncludePath(vosk_dep.path(""));
|
||||
exe.addLibraryPath(vosk_dep.path(""));
|
||||
exe.linkSystemLibrary("vosk"); // comes from dependency, which is binary blob from gh releases
|
||||
exe.linkSystemLibrary("vosk");
|
||||
|
||||
const alsa_lib = alsa_dep.artifact("asound");
|
||||
exe.linkLibrary(alsa_lib); // use our built alsa-lib
|
||||
|
||||
// Use the installed headers from the alsa dependency
|
||||
exe.linkLibrary(alsa_lib);
|
||||
exe.addIncludePath(alsa_dep.path("zig-out/include"));
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
@ -67,6 +70,15 @@ pub fn build(b: *std.Build) void {
|
|||
test_step.dependOn(&run_exe_unit_tests.step);
|
||||
}
|
||||
|
||||
fn selectVoskDependency(target: std.Target) []const u8 {
|
||||
return switch (target.cpu.arch) {
|
||||
.x86_64 => "vosk_linux_x86_64",
|
||||
.aarch64 => "vosk_linux_aarch64",
|
||||
.riscv64 => "vosk_linux_riscv64",
|
||||
else => @panic("Unsupported architecture - only x86_64, aarch64, and riscv64 are supported"),
|
||||
};
|
||||
}
|
||||
|
||||
const ModelDownloadStep = struct {
|
||||
step: std.Build.Step,
|
||||
builder: *std.Build,
|
||||
|
|
|
@ -8,14 +8,23 @@
|
|||
.url = "https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-x86_64-0.3.45.zip",
|
||||
.hash = "N-V-__8AAF22jAFTSU4AVxFCNWtotf7OD8gM33Y_ScIrCeu7",
|
||||
},
|
||||
.vosk_linux_aarch64 = .{
|
||||
.url = "https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-aarch64-0.3.45.zip",
|
||||
.hash = "N-V-__8AAP2ScgCM0x0ArHmAEi8p5ldT-6soT1_d7VXVs1vZ",
|
||||
},
|
||||
.vosk_linux_riscv64 = .{
|
||||
.url = "https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-riscv64-0.3.45.zip",
|
||||
.hash = "N-V-__8AAJ2aagCdvMMhvyldsHAklmUNkOSEayqFeZRTGzXx",
|
||||
},
|
||||
.alsa = .{
|
||||
.url = "git+https://git.lerch.org/lobo/aycb-alsa-lib/#41600d4ef511629e7c77cec3e08f7e8ca9021723",
|
||||
.hash = "alsa-1.2.14-jevBFmKjAACg9m2jKphsZtsrjpWRjgM6A5Wrt7K85WBl",
|
||||
.url = "git+https://git.lerch.org/lobo/aycb-alsa-lib/#da2b0913746c531f381c2f791f327de6a7c44a57",
|
||||
.hash = "alsa-1.2.14-jevBFuqjAAApBlAeXikP0ksRBJjAAzyxXcJ4lC6U6pda",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
"alsa.conf",
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue