-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtutorial_example_build.zig
71 lines (64 loc) · 1.84 KB
/
tutorial_example_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
const std = @import("std");
///
///
///
pub fn create_tutorial_example_binary_and_test_step(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
box2c_lib: *std.Build.Step.Compile,
comptime binary_name: []const u8,
comptime source_filename: []const u8,
) void {
const exe = b.addExecutable(.{
.name = binary_name,
.root_source_file = .{ .path = source_filename },
.target = target,
.optimize = optimize,
});
exe.addIncludePath(.{ .path = "box2c/include" });
exe.linkLibrary(box2c_lib);
exe.linkSystemLibrary("m");
exe.addIncludePath(.{ .path = "raylib/zig-out/include" });
exe.addObjectFile(.{ .path = "raylib/zig-out/lib/libraylib.a" });
exe.linkLibC();
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
// run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run-" ++ binary_name, "Run the " ++ binary_name ++ " demo");
run_step.dependOn(&run_cmd.step);
}
///
/// Compile all demo binaries
///
pub fn build(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
box2c_lib: *std.Build.Step.Compile,
) void {
create_tutorial_example_binary_and_test_step(
b,
target,
optimize,
box2c_lib,
"how-to-draw-images-and-textures",
"src/tutorial_examples/how-to-draw-images-and-textures.zig",
);
create_tutorial_example_binary_and_test_step(
b,
target,
optimize,
box2c_lib,
"how-to-play-audio",
"src/tutorial_examples/how-to-play-audio.zig",
);
create_tutorial_example_binary_and_test_step(
b,
target,
optimize,
box2c_lib,
"how-to-deal-with-fonts",
"src/tutorial_examples/how-to-deal-with-fonts.zig",
);
}