-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.zig
114 lines (88 loc) · 3.5 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const std = @import("std");
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const optimize = b.standardOptimizeOption(.{});
const raylib_dep = b.dependency("raylib-zig", .{
.target = target,
.optimize = optimize,
});
const raylib = raylib_dep.module("raylib"); // main raylib module
const raygui = raylib_dep.module("raygui"); // raygui module
const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library
const exe = b.addExecutable(.{
.name = "zfg",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.linkLibrary(raylib_artifact);
exe.root_module.addImport("raylib", raylib);
exe.root_module.addImport("raygui", raygui);
exe.linkLibCpp();
const zgui = b.dependency("zgui", .{
.shared = false,
.with_implot = true,
});
exe.root_module.addImport("zgui", zgui.module("root"));
exe.linkLibrary(zgui.artifact("imgui"));
exe.addIncludePath(zgui.path("libs/imgui"));
const rlimgui_cflags = &.{
"-fno-sanitize=undefined",
"-std=c++11",
"-Wno-deprecated-declarations",
"-DNO_FONT_AWESOME",
};
const rlimgui = b.dependency("rlimgui", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addCSourceFile(.{
.file = rlimgui.path("rlImGui.cpp"),
.flags = rlimgui_cflags,
});
exe.addIncludePath(rlimgui.path("."));
const sfd = b.dependency("sfd", .{
.target = target,
.optimize = optimize,
});
const sfd_cflags = &.{};
exe.root_module.addCSourceFile(.{
.file = sfd.path("src/sfd.c"),
.flags = sfd_cflags,
});
exe.addIncludePath(sfd.path("src/"));
// @todo might use this library for dialogs in the future. chase 2024/7/23
// const tinyfiledialogs = b.dependency("tinyfiledialogs", .{
// .target = target,
// .optimize = optimize,
// });
// const tinyfiledialogs_cflags = &.{};
// exe.root_module.addCSourceFile(.{
// .file = tinyfiledialogs.path("tinyfiledialogs.c"),
// .flags = tinyfiledialogs_cflags,
// });
// exe.addIncludePath(tinyfiledialogs.path("."));
// Windows link for file dialogs. Will add other platforms later. Pull request please orz.
exe.linkSystemLibrary("comdlg32");
// exe.linkSystemLibrary("ole32");
b.installArtifact(exe);
const run_exe = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the application");
run_step.dependOn(&run_exe.step);
// const unit_tests = b.addTest(.{
// .root_source_file = .{ .path = "src/main.zig" },
// .target = target,
// .optimize = optimize,
// });
// const run_unit_tests = b.addRunArtifact(unit_tests);
// const test_step = b.step("test", "Run unit tests");
// test_step.dependOn(&run_unit_tests.step);
}