-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
71 lines (56 loc) · 2.36 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
const std = @import("std");
const zmath = @import("libs/zmath/build.zig");
const zmesh = @import("libs/zmesh/build.zig");
const zigargs = @import("libs/zig-args/build.zig");
const sdl_sdk = @import("libs/SDL.zig/Sdk.zig");
const options_pkg_name = "build_options";
const use_32bit_indices = false;
pub fn build(b: *std.build.Builder) 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 sdk = sdl_sdk.init(b, null);
const exe = b.addExecutable(.{
.name = "rayzigger",
.root_source_file = .{ .path = "./src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(std.Build.LibExeObjStep.CSourceFile{
.file = std.Build.FileSource.relative("libs/stb_image/stb_image_impl.c"),
.flags = &[_][]const u8{"-std=c99"},
});
exe.addIncludePath(std.Build.FileSource.relative("libs/stb_image"));
sdk.link(exe, .dynamic);
const exe_options = b.addOptions();
exe.addOptions(options_pkg_name, exe_options);
const zmesh_pkg = zmesh.package(b, target, optimize, .{});
//exe.addModule("zmesh", zmesh_pkg.zmesh);
zmesh_pkg.link(exe);
const zmath_pkg = zmath.package(b, target, optimize, .{
.options = .{ .enable_cross_platform_determinism = true },
});
//exe.addModule("zmath", zmath_pkg.zmath);
zmath_pkg.link(exe);
exe.addModule("sdl2", sdk.getWrapperModule());
const zigargs_mod = b.createModule(.{
.source_file = .{ .path = "./libs/zig-args/args.zig" },
.dependencies = &.{},
});
exe.addModule("args", zigargs_mod);
b.installArtifact(exe);
//exe.installArtifact();
//const run_cmd = exe.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);
}