-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
69 lines (61 loc) · 2.71 KB
/
build.zig
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("wio", .{
.root_source_file = b.path("src/wio.zig"),
.target = target,
.optimize = optimize,
});
switch (target.result.os.tag) {
.windows => {
if (b.lazyDependency("win32", .{ .target = target, .optimize = optimize })) |win32| {
module.addImport("win32", win32.module("win32"));
}
},
.macos => {
module.addCSourceFile(.{ .file = b.path("src/macos.m"), .flags = &.{ "-fobjc-arc", "-Wno-deprecated-declarations" } });
if (b.lazyDependency("xcode_frameworks", .{})) |xcode_frameworks| {
module.addSystemFrameworkPath(xcode_frameworks.path("Frameworks"));
module.addSystemIncludePath(xcode_frameworks.path("include"));
module.addLibraryPath(xcode_frameworks.path("lib"));
}
module.linkFramework("Cocoa", .{});
module.linkFramework("IOKit", .{});
module.linkFramework("CoreAudio", .{});
module.linkFramework("AudioUnit", .{});
module.linkFramework("AudioToolbox", .{});
},
.linux, .openbsd, .netbsd, .freebsd, .dragonfly => |tag| {
module.link_libc = true;
if (b.lazyDependency("unix_headers", .{})) |unix_headers| {
module.addIncludePath(unix_headers.path("."));
}
module.addCSourceFile(.{ .file = b.path("src/unix/wayland.c") });
if (tag == .openbsd) module.linkSystemLibrary("sndio", .{});
},
else => {
if (target.result.isWasm()) {
module.export_symbol_names = &.{ "wioLoop", "wioJoystick" };
}
},
}
if (b.option(bool, "win32_manifest", "Embed application manifest (default: true)") orelse true) {
module.addWin32ResourceFile(.{ .file = b.path("src/win32.rc") });
}
const options = b.addOptions();
options.addOption([]const u8, "unix_backends", b.option([]const u8, "unix_backends", "Comma-separated list of backends (default: x11,wayland)") orelse "x11,wayland");
module.addOptions("build_options", options);
const exe = b.addExecutable(.{
.name = "wio",
.root_source_file = b.path("example/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("wio", module);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}