-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
117 lines (105 loc) · 4.04 KB
/
Copy pathbuild.zig
File metadata and controls
117 lines (105 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const clap_bindings = b.dependency("clap_bindings", .{});
const lib = b.addSharedLibrary(.{
.name = "tonebender",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true, // faust needs libc
});
lib.root_module.addImport(
"clap-bindings",
clap_bindings.module("clap-bindings"),
);
// Faust and C code
lib.root_module.addIncludePath(b.path("src/c"));
lib.root_module.addCMacro("min(a,b)", "(((a) > (b)) ? (a) : (b))");
lib.root_module.addCMacro("max(a,b)", "(((a) < (b)) ? (a) : (b))");
// NOT wio and yes dvui
{
const dvui_dep = b.dependency("dvui", .{
.target = target,
.optimize = optimize,
.backend = .sdl3,
});
lib.root_module.addImport("dvui", dvui_dep.module("dvui_sdl3"));
lib.root_module.addImport("backend", dvui_dep.module("sdl3"));
}
const package_step = createPackageStep(b, lib);
b.default_step = package_step;
}
// technically you should not need this, but not all daws accept the plugin when
// it's not a package, at least on MacOS. i mainly use a mac and have not yet
// figured out what the requirements are, if there are any, for daws on other
// operating systems but i figure it's nice to rename the lib either way, so it
// does that too.
fn createPackageStep(b: *std.Build, lib: *std.Build.Step.Compile) *std.Build.Step {
const package_step = b.step("package", "package the clap plugin");
const clap_name = b.fmt("{s}.clap", .{lib.name});
switch (lib.rootModuleTarget().os.tag) {
.macos => {
const info_plist = b.fmt(
info_plist_format,
.{
.version = "1.0.0",
.region = "English",
.executable = clap_name,
.identifier = b.fmt("com.bnw.tonebender.{s}", .{lib.name}),
.name = clap_name,
},
);
const write_files = b.addWriteFiles();
write_files.step.dependOn(&lib.step);
write_files.step.name = "MacOS Package";
_ = write_files.add("Contents/Info.plist", info_plist);
_ = write_files.add("Contents/PkgInfo", "BNDL????");
_ = write_files.addCopyFile(
lib.getEmittedBin(),
b.fmt("Contents/MacOS/{s}", .{clap_name}),
);
const install = b.addInstallDirectory(.{
.source_dir = write_files.getDirectory(),
.install_dir = .lib,
.install_subdir = clap_name,
});
package_step.dependOn(&install.step);
},
else => {
const install = b.addInstallLibFile(lib.getEmittedBin(), clap_name);
package_step.dependOn(&install.step);
},
}
return package_step;
}
const info_plist_format =
\\<?xml version="1.0" encoding="UTF-8"?>
\\<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
\\<plist version="1.0">
\\ <dict>
\\ <key>CFBundleShortVersionString</key>
\\ <string>{[version]s}</string>
\\ <key>CFBundleVersion</key>
\\ <string>{[version]s}</string>
\\ <key>CFBundleDevelopmentRegion</key>
\\ <string>{[region]s}</string>
\\ <key>CFBundleExecutable</key>
\\ <string>{[executable]s}</string>
\\ <key>CFBundleIdentifier</key>
\\ <string>{[identifier]s}</string>
\\ <key>CFBundleName</key>
\\ <string>{[name]s}</string>
\\ <key>CFBundlePackageType</key>
\\ <string>BNDL</string>
\\ <key>CFBundleSignature</key>
\\ <string>????</string>
\\ <key>CSResourcesFileMapped</key>
\\ <true/>
\\ <key>NSHumanReadableCopyright</key>
\\ <string></string>
\\ </dict>
\\</plist>
\\
;