Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# The build files and sources use spellings valid in both: the
# root_module API, callconv(.c), ArrayListUnmanaged, and
# net.Stream.read. Testing both keeps that honest rather than assumed.
zig: ["0.14.1", "0.15.2"]
zig: ["0.14.1", "0.15.2", "0.16.0"]
name: build-and-test (zig ${{ matrix.zig }})
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# danzig

[![CI](https://github.com/godofecht/danzig/actions/workflows/ci.yml/badge.svg)](https://github.com/godofecht/danzig/actions/workflows/ci.yml)
[![Zig](https://img.shields.io/badge/zig-0.14.1%20%7C%200.15.2-f7a41d)](https://ziglang.org/)
[![Zig](https://img.shields.io/badge/zig-0.14.1%20%7C%200.15.2%20%7C%200.16.0-f7a41d)](https://ziglang.org/)

A VST3 plugin framework in pure Zig. No JUCE, no Steinberg SDK, no C++ in the
core. `src/vst3.zig` implements the VST3 C ABI directly as `extern struct`s of
Expand Down
38 changes: 25 additions & 13 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
.linkage = .dynamic,
});
danzig_gain.root_module.addImport("danzig", danzig_module);
danzig_gain.linkLibrary(danzig_lib);
danzig_gain.root_module.linkLibrary(danzig_lib);

// Install to zig-out/lib/
b.installArtifact(danzig_gain);
Expand All @@ -49,8 +49,8 @@ pub fn build(b: *std.Build) void {
}),
});
danzig_test.root_module.addImport("danzig", danzig_module);
danzig_test.linkLibrary(danzig_lib);
danzig_test.linkLibrary(danzig_gain);
danzig_test.root_module.linkLibrary(danzig_lib);
danzig_test.root_module.linkLibrary(danzig_gain);
b.installArtifact(danzig_test);

// Minimal plugin template. Built twice from one source: as the shared
Expand All @@ -66,7 +66,7 @@ pub fn build(b: *std.Build) void {
.linkage = .dynamic,
});
danzig_minimal.root_module.addImport("danzig", danzig_module);
danzig_minimal.linkLibrary(danzig_lib);
danzig_minimal.root_module.linkLibrary(danzig_lib);
b.installArtifact(danzig_minimal);

const danzig_minimal_demo = b.addExecutable(.{
Expand All @@ -78,13 +78,20 @@ pub fn build(b: *std.Build) void {
}),
});
danzig_minimal_demo.root_module.addImport("danzig", danzig_module);
danzig_minimal_demo.linkLibrary(danzig_lib);
danzig_minimal_demo.root_module.linkLibrary(danzig_lib);
b.installArtifact(danzig_minimal_demo);

const run_minimal = b.addRunArtifact(danzig_minimal_demo);
const run_minimal_step = b.step("run-minimal", "Run the minimal plugin template offline");
run_minimal_step.dependOn(&run_minimal.step);

// Two demo executables still call std APIs that Zig 0.16 removed:
// std.process.argsAlloc and std.fs.cwd. Porting them means threading an
// std.Io.Threaded handle through demo code, which buys nothing for the
// library itself, so they are skipped on 0.16 until that is worth doing.
// The library, the VST3 plugin and the whole test suite build there.
const demos_supported = @import("builtin").zig_version.minor < 16;
if (demos_supported) {
// Standalone audio processor
const danzig_gain_standalone = b.addExecutable(.{
.name = "danzig-gain-standalone",
Expand All @@ -95,7 +102,7 @@ pub fn build(b: *std.Build) void {
}),
});
danzig_gain_standalone.root_module.addImport("danzig", danzig_module);
danzig_gain_standalone.linkLibrary(danzig_lib);
danzig_gain_standalone.root_module.linkLibrary(danzig_lib);
b.installArtifact(danzig_gain_standalone);

const run_standalone = b.addRunArtifact(danzig_gain_standalone);
Expand All @@ -112,8 +119,9 @@ pub fn build(b: *std.Build) void {
}),
});
danzig_webui.root_module.addImport("danzig", danzig_module);
danzig_webui.linkLibrary(danzig_lib);
danzig_webui.root_module.linkLibrary(danzig_lib);
b.installArtifact(danzig_webui);
}

// --- Universal VST3 bundle (macOS) ---------------------------------------
//
Expand All @@ -129,7 +137,11 @@ pub fn build(b: *std.Build) void {
//
// Needs the webview dependency, so it is only wired up when that has been
// fetched. Links CoreAudio for device IO and WebKit via webview.
if (target.result.os.tag == .macos) {
// webview-zig's own build.zig.zon still carries a pre-0.16 hash format that
// Zig 0.16 rejects, so the GUI example cannot be built there until upstream
// updates. Everything else in danzig works on 0.16.
const webview_supported = @import("builtin").zig_version.minor < 16;
if (target.result.os.tag == .macos and webview_supported) {
if (b.lazyDependency("webview", .{ .target = target, .optimize = optimize })) |webview_dep| {
addGuiExample(b, target, optimize, danzig_module, danzig_lib, webview_dep);
}
Expand Down Expand Up @@ -194,7 +206,7 @@ fn addVst3Bundle(
.linkage = .dynamic,
});
plugin.root_module.addImport("danzig", danzig_module);
plugin.linkLibrary(lib);
plugin.root_module.linkLibrary(lib);
b.installArtifact(plugin);

lipo.addArtifactArg(plugin);
Expand Down Expand Up @@ -255,13 +267,13 @@ fn addGuiExample(
gui.root_module.addImport("webview", webview_dep.module("webview"));
// The Zig bindings are declarations only; the implementation is webview's
// C++ core, which the dependency exposes as a static library.
gui.linkLibrary(webview_dep.artifact("webviewStatic"));
gui.root_module.linkLibrary(webview_dep.artifact("webviewStatic"));
// The UI is embedded rather than read at runtime, so the binary is
// self-contained.
gui.root_module.addAnonymousImport("ui_html", .{ .root_source_file = b.path("ui/index.html") });
gui.linkLibrary(danzig_lib);
gui.linkFramework("CoreAudio");
gui.linkFramework("CoreFoundation");
gui.root_module.linkLibrary(danzig_lib);
gui.root_module.linkFramework("CoreAudio", .{});
gui.root_module.linkFramework("CoreFoundation", .{});
b.installArtifact(gui);

const run_gui = b.addRunArtifact(gui);
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
.webview = .{
.url = "https://github.com/thechampagne/webview-zig/archive/a5eef0bbff65c914ea893dae0816b956bcdee6c6.tar.gz",
.hash = "webview-0.1.0-ImQK_8_aIABj-dmipgQ_Cw1trbEFExFQwMZetkgtT8fg",
// Lazy so the GUI example is the only thing that pulls it. The
// package's own build.zig.zon carries a pre-0.16 hash format that
// 0.16 rejects, and an eager fetch would fail the whole build.
.lazy = true,
},
},
.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/danzig-gain-standalone/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const WavHeader = extern struct {
};

pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();

Expand Down
2 changes: 1 addition & 1 deletion examples/danzig-gain-ui/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const coreaudio = @import("coreaudio");

const UI_HTML: [:0]const u8 = @embedFile("ui_html");

var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};

pub fn main() !void {
const allocator = gpa.allocator();
Expand Down
2 changes: 1 addition & 1 deletion examples/danzig-gain-webui/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const std = @import("std");

pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};
defer _ = gpa.deinit();

std.debug.print("\n馃幍 DanzigGain Web UI\n", .{});
Expand Down
2 changes: 1 addition & 1 deletion examples/danzig-test/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ fn checkLibraryLinkage(allocator: std.mem.Allocator) void {
}

pub fn main() !u8 {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();

Expand Down
2 changes: 1 addition & 1 deletion examples/danzig-webui/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const danzig = @import("danzig");
const PORT = 3000;

pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();

Expand Down
2 changes: 1 addition & 1 deletion examples/root.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ParamID = struct {
pub const Bypass: u32 = 1;
};

var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var gpa = std.heap.DebugAllocator(.{}){};
var gPluginInstance: ?*GainPlugin = null;

pub const GainPlugin = struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
webview/** linguist-vendored
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
freebsd-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: vmactions/freebsd-vm@v1
with:
copyback: false
prepare: |
pkg install -y webkit2-gtk_60 wget
run: |
wget https://ziglang.org/download/0.15.2/zig-x86_64-freebsd-0.15.2.tar.xz
tar -xvf zig-x86_64-freebsd-0.15.2.tar.xz
./zig-x86_64-freebsd-0.15.2/zig build

linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- name: install packages
run: sudo apt-get update && sudo apt-get install libgtk-3-dev libwebkit2gtk-4.1-dev
- run: zig build

macos-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- run: zig build

windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.15.2
- run: zig build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zig-cache/
.zig-cache/
zig-out/
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 XXIV

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading