diff --git a/.gitignore b/.gitignore index a2bcaac..93c1b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -build/ -build-win32/ -build-win64/ +/zig-cache +/zig-out diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..6e224fb --- /dev/null +++ b/build.zig @@ -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"); +} diff --git a/build.zig.ini b/build.zig.ini new file mode 100644 index 0000000..31c7e59 --- /dev/null +++ b/build.zig.ini @@ -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 diff --git a/src/config.h.in b/src/config.h.in index ff22769..b371366 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -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