forked from Protryon/Osmium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
84 lines (71 loc) · 1.95 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
const std = @import("std");
fn makeCObjects(b: *std.Build, comptime c_sources: anytype, target: anytype, optimize: anytype, exe: anytype) void {
inline for(c_sources) |source| {
const obj = b.addObject(.{
.name = source,
.target = target,
.optimize = optimize,
});
obj.linkLibC();
obj.addCSourceFile("Osmium/src/" ++ source, &.{"-Wall", "-Wvla"});
exe.addObject(obj);
}
}
fn makeZigObjects(b: *std.Build, comptime sources: anytype, target: anytype, optimize: anytype, exe: anytype) void {
inline for(sources) |source| {
const obj = b.addObject(.{
.name = source,
.target = target,
.optimize = optimize,
.root_source_file = .{.path = "Osmium/src/" ++ source},
});
obj.linkLibC();
obj.addIncludePath("Osmium/src");
exe.addObject(obj);
}
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "osmium",
.target = target,
.optimize = optimize,
});
exe.disable_sanitize_c = false;
const libs = .{
"gl",
"glu",
"glut",
"glfw",
"png",
"z",
};
inline for(libs) |lib| exe.linkSystemLibrary(lib);
exe.linkLibC();
// XXX: add libraries to link
const c_sources = .{
"block.c",
"bmodel.c",
"entity.c",
"gui.c",
"ingame.c",
"inventory.c",
"main.c",
"models.c",
"nbt.c",
"network.c",
"render.c",
"world.c",
"json.c",
"globals.c",
};
const zig_sources = .{
"xstring.zig",
"network.zig",
"models.zig",
};
makeCObjects(b, c_sources, target, optimize, exe);
makeZigObjects(b, zig_sources, target, optimize, exe);
exe.install();
}