-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.zig
91 lines (78 loc) · 3.08 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
84
85
86
87
88
89
90
91
const std = @import("std");
const builtin = @import("builtin");
const vkgen = @import("Aether-Platform/ext/vulkan/generator/index.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const glfw = b.addModule("glfw", .{
.root_source_file = .{ .path = "Aether-Platform/ext/zwin/glfw/src/glfw.zig" },
});
const zwin = b.addModule("zwin", .{
.root_source_file = .{ .path = "Aether-Platform/ext/zwin/src/zwin.zig" },
.imports = &.{
.{ .name = "glfw", .module = glfw },
},
});
const glad = b.addModule("glad", .{
.root_source_file = .{ .path = "Aether-Platform/ext/glad/c.zig" },
});
glad.addIncludePath(.{ .path = "Aether-Platform/ext/glad/include" });
glad.addIncludePath(.{ .path = "Aether-Platform/ext/glad/" });
const stbi = b.addModule("stbi", .{
.root_source_file = .{ .path = "Aether-Platform/ext/stbi/c.zig" },
});
stbi.addIncludePath(.{ .path = "Aether-Platform/ext/stbi/" });
const gen = vkgen.VkGenerateStep.create(b, "Aether-Platform/ext/vk.xml");
const shaders = vkgen.ShaderCompileStep.create(
b,
&[_][]const u8{ "glslc", "--target-env=vulkan1.2" },
"-o",
);
shaders.add("vert", "Aether-Platform/shaders/basic.vert", .{});
shaders.add("frag", "Aether-Platform/shaders/basic.frag", .{});
const platform = b.addModule("platform", .{
.root_source_file = .{ .path = "Aether-Platform/src/platform.zig" },
.imports = &.{
.{ .name = "zwin", .module = zwin },
.{ .name = "glad", .module = glad },
.{ .name = "vulkan", .module = gen.getModule() },
.{ .name = "stbi", .module = stbi },
.{ .name = "shaders", .module = shaders.getModule() },
},
});
const exe = b.addExecutable(.{
.name = "Aether",
.root_source_file = .{ .path = "src/engine.zig" },
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("platform", platform);
exe.linkLibC();
if (builtin.os.tag == .windows) {
exe.addObjectFile(.{ .path = "libglfw3.a" });
exe.linkSystemLibrary("opengl32");
exe.linkSystemLibrary("gdi32");
} else {
exe.linkSystemLibrary("glfw");
}
exe.addCSourceFile(.{
.file = .{ .path = "Aether-Platform/ext/glad/src/gl.c" },
.flags = &[_][]const u8{"-IAether-Platform/ext/glad/include"},
});
exe.addCSourceFile(.{
.file = .{ .path = "Aether-Platform/ext/glad/loader.c" },
.flags = &[_][]const u8{"-IAether-Platform/ext/glad/"},
});
exe.addCSourceFile(.{
.file = .{ .path = "Aether-Platform/ext/stbi/stb_image.c" },
.flags = &[_][]const u8{"-IAether-Platform/ext/stbi/"},
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}