-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
83 lines (71 loc) · 2.36 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const std = @import("std");
const find_build_sources = @import("find-build-sources.zig");
fn isCppFile(path: []const u8) bool {
return std.mem.endsWith(u8, path, ".cpp");
}
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const engine = b.addStaticLibrary(.{
.name = "galaxy-engine-cpp",
.target = target,
.optimize = optimize,
});
engine.linkLibCpp();
const glfw = b.dependency("glfw", .{
.target = target,
.optimize = optimize,
});
const glfm = b.addStaticLibrary(.{
.name = "glfm",
.target = target,
.optimize = optimize,
});
glfm.linkLibC();
const glfm_file: ?[]const u8 = (
if (target.result.os.tag == .ios)
"vendored/GLFM/glfm_platform_ios.m"
else if (target.result.os.tag == .emscripten)
"vendored/GLFM/glfm_platform_emscripten.c"
else if (target.result.abi == .android)
"vendored/GLFM/glfm_platform_android.c"
else
null
);
if (glfm_file) |file| {
glfm.addCSourceFile(.{
.file = b.path(file),
});
engine.linkLibrary(glfm);
} else {
engine.linkLibrary(glfw.artifact("glfw"));
}
engine.linkSystemLibrary("OpenAL");
const cpp_sources = try find_build_sources.find(b, "src", isCppFile);
engine.addCSourceFiles(.{
.root = cpp_sources.directory,
.files = cpp_sources.inner,
.flags = &.{ "-std=c++26", "-Wall", "-Wextra", "-Wpedantic" },
});
engine.addCSourceFile(.{
.file = b.path("vendored/stb_image_init.cpp"),
});
if (target.result.os.tag == .ios) {
engine.addCSourceFile(.{
.file = b.path("vendored/GLFM/glfm_platform_ios.m"),
});
}
if (target.result.os.tag == .emscripten) {
engine.addCSourceFile(.{
.file = b.path("vendored/GLFM/glfm_platform_emscripten.c"),
});
}
engine.addIncludePath(glfw.artifact("glfw").getEmittedIncludeTree());
engine.addIncludePath(b.path("src"));
engine.addIncludePath(b.path("include"));
engine.addIncludePath(b.path("vendored"));
engine.installHeadersDirectory(b.path("include/Galaxy"), "Galaxy", .{
.include_extensions = &.{ ".hpp", ".inl" },
});
b.installArtifact(engine);
}