package for zig

This commit is contained in:
Andrew Kelley 2023-01-17 00:28:17 -07:00
parent a24148e15f
commit c57e089977
4 changed files with 62 additions and 7 deletions

5
.gitignore vendored
View file

@ -1,3 +1,2 @@
build/
build-win32/
build-win64/
/zig-cache
/zig-out

48
build.zig Normal file
View file

@ -0,0 +1,48 @@
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const pulseaudio_dep = b.dependency("pulseaudio", .{});
const lib = b.addStaticLibrary("soundio", null);
lib.setTarget(target);
lib.setBuildMode(mode);
lib.linkLibC();
lib.linkLibrary(pulseaudio_dep.artifact("pulse"));
lib.addIncludePath(".");
lib.addConfigHeader(b.addConfigHeader(.{ .path = "src/config.h.in" }, .cmake, .{
.SOUNDIO_HAVE_JACK = null,
.SOUNDIO_HAVE_PULSEAUDIO = {},
.SOUNDIO_HAVE_ALSA = null,
.SOUNDIO_HAVE_COREAUDIO = null,
.SOUNDIO_HAVE_WASAPI = null,
.SOUNDIO_VERSION_MAJOR = 2,
.SOUNDIO_VERSION_MINOR = 0,
.SOUNDIO_VERSION_PATCH = 0,
.SOUNDIO_VERSION_STRING = "2.0.0",
}));
lib.addCSourceFiles(&.{
"src/soundio.c",
"src/util.c",
"src/os.c",
"src/dummy.c",
"src/channel_layout.c",
"src/ring_buffer.c",
"src/pulseaudio.c",
}, &.{
"-std=c11",
"-fvisibility=hidden",
"-Wall",
"-Werror=strict-prototypes",
"-Werror=old-style-definition",
"-Werror=missing-prototypes",
"-D_REENTRANT",
"-D_POSIX_C_SOURCE=200809L",
"-Wno-missing-braces",
});
lib.install();
lib.installHeadersDirectory("soundio", "soundio");
}

8
build.zig.ini Normal file
View file

@ -0,0 +1,8 @@
[package]
name=libsoundio
version=2.0.0
[dependency]
name=pulseaudio
url=https://github.com/andrewrk/pulseaudio/archive/fd22dc75f38a48553e4f8954a95101740d90080f.tar.gz
hash=4c0760508159154501b98f849e18c70b9888129924c834180360c6ac46f1bf91

View file

@ -8,10 +8,10 @@
#ifndef SOUNDIO_CONFIG_H
#define SOUNDIO_CONFIG_H
#define SOUNDIO_VERSION_MAJOR @LIBSOUNDIO_VERSION_MAJOR@
#define SOUNDIO_VERSION_MINOR @LIBSOUNDIO_VERSION_MINOR@
#define SOUNDIO_VERSION_PATCH @LIBSOUNDIO_VERSION_PATCH@
#define SOUNDIO_VERSION_STRING "@LIBSOUNDIO_VERSION@"
#cmakedefine SOUNDIO_VERSION_MAJOR @LIBSOUNDIO_VERSION_MAJOR@
#cmakedefine SOUNDIO_VERSION_MINOR @LIBSOUNDIO_VERSION_MINOR@
#cmakedefine SOUNDIO_VERSION_PATCH @LIBSOUNDIO_VERSION_PATCH@
#cmakedefine SOUNDIO_VERSION_STRING "@LIBSOUNDIO_VERSION@"
#cmakedefine SOUNDIO_HAVE_JACK
#cmakedefine SOUNDIO_HAVE_PULSEAUDIO