-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig
More file actions
116 lines (106 loc) · 3.93 KB
/
Copy pathbuild.zig
File metadata and controls
116 lines (106 loc) · 3.93 KB
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
115
116
//!zig-autodoc-section: BaseChipmunk2D.Build
//! BaseChipmunk2D\\build.zig :
//! Build Template for Chipmunk2D physics.
// Build using Zig 0.16.0
//=============================================================================
//#region MARK: GLOBAL
//=============================================================================
const std = @import("std");
pub fn build(b: *std.Build) void {
//#endregion ==================================================================
//#region MARK: INSTALL
//=============================================================================
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const projectname = "BaseChipmunk2D";
const mainfile = "main.zig";
const exe = b.addExecutable(.{
.name = projectname,
.root_module = b.createModule(.{
.root_source_file = b.path(mainfile),
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
exe.root_module.addWin32ResourceFile(.{
.file = b.path(projectname ++ ".rc"),
.flags = &.{"/c65001"}, // UTF-8 codepage
});
exe.root_module.addIncludePath( b.path(".") );
exe.root_module.addIncludePath( b.path("lib/chipmunk/include") );
const c_srcs = .{
"lib/chipmunk/src/chipmunk.c",
"lib/chipmunk/src/cpArbiter.c",
"lib/chipmunk/src/cpArray.c",
"lib/chipmunk/src/cpBBTree.c",
"lib/chipmunk/src/cpBody.c",
"lib/chipmunk/src/cpCollision.c",
"lib/chipmunk/src/cpConstraint.c",
"lib/chipmunk/src/cpDampedRotarySpring.c",
"lib/chipmunk/src/cpDampedSpring.c",
"lib/chipmunk/src/cpGearJoint.c",
"lib/chipmunk/src/cpGrooveJoint.c",
"lib/chipmunk/src/cpHashSet.c",
"lib/chipmunk/src/cpHastySpace.c",
"lib/chipmunk/src/cpMarch.c",
"lib/chipmunk/src/cpPinJoint.c",
"lib/chipmunk/src/cpPivotJoint.c",
"lib/chipmunk/src/cpPolyline.c",
"lib/chipmunk/src/cpPolyShape.c",
"lib/chipmunk/src/cpRatchetJoint.c",
"lib/chipmunk/src/cpRobust.c",
"lib/chipmunk/src/cpRotaryLimitJoint.c",
"lib/chipmunk/src/cpShape.c",
"lib/chipmunk/src/cpSimpleMotor.c",
"lib/chipmunk/src/cpSlideJoint.c",
"lib/chipmunk/src/cpSpace.c",
"lib/chipmunk/src/cpSpaceComponent.c",
"lib/chipmunk/src/cpSpaceDebug.c",
"lib/chipmunk/src/cpSpaceHash.c",
"lib/chipmunk/src/cpSpaceQuery.c",
"lib/chipmunk/src/cpSpaceStep.c",
"lib/chipmunk/src/cpSpatialIndex.c",
"lib/chipmunk/src/cpSweep1D.c",
};
inline for (c_srcs) |c_cpp| {
exe.root_module.addCSourceFile(.{
.file = b.path(c_cpp),
.flags = &.{ "-DNDEBUG" }
});
}
switch (optimize) {
.Debug => b.exe_dir = "bin/Debug",
.ReleaseSafe => b.exe_dir = "bin/ReleaseSafe",
.ReleaseFast => b.exe_dir = "bin/ReleaseFast",
.ReleaseSmall => b.exe_dir = "bin/ReleaseSmall"
//else => b.exe_dir = "bin/Else",
}
b.installArtifact(exe);
//#endregion ==================================================================
//#region MARK: RUN
//=============================================================================
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);
//#endregion ==================================================================
//#region MARK: TEST
//=============================================================================
const unit_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path(mainfile),
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
}
//#endregion ==================================================================
//=============================================================================