-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
100 lines (85 loc) · 4.26 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
const std = @import("std");
const deps = @import("./deps.zig");
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 exe = b.addExecutable(.{
.name = "TaleaZ",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
var flags = [1][]const u8{""};
exe.linkLibC();
// Mac os specific libs to compile with minifb
if (target.isDarwin()) {
exe.addIncludePath(.{ .path = "/usr/local/include" });
exe.addIncludePath(.{ .path = "./src/include" });
exe.addLibraryPath(.{ .path = "/usr/local/lib" });
exe.addObjectFile(.{ .path = "/usr/local/lib/libminifb.a" });
exe.linkFramework("Metal");
exe.linkFramework("MetalKit");
exe.linkFramework("QuartzCore");
exe.linkFramework("Cocoa");
} else if (target.isLinux()) {
exe.addIncludePath(.{ .path = "/usr/local/include" });
exe.addIncludePath(.{ .path = "./src/include" });
exe.addLibraryPath(.{ .path = "/usr/local/lib" });
exe.addObjectFile(.{ .path = "/usr/local/lib/libminifb.a" });
exe.linkSystemLibrary("X11");
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("GLX");
} else if (target.isWindows()) {
exe.addLibraryPath(.{ .path = "/mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/lib/x64" });
exe.addLibraryPath(.{ .path = "/mnt/c/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/ucrt/x64"});
exe.addLibraryPath(.{ .path = "/mnt/c/Program Files (x86)/Windows Kits/10/Lib/10.0.18362.0/um/x64"});
exe.addIncludePath(.{ .path = "./src/include" });
exe.addIncludePath(.{ .path = "/mnt/c/Program Files (x86)/MiniFB/include" });
exe.addIncludePath(.{ .path = "/mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/include/GL"});
exe.addIncludePath(.{ .path = "/mnt/c/Program Files (x86)/Windows Kits/10/Include/"});
exe.linkSystemLibrary("ucrt");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("Opengl32");
exe.linkSystemLibrary("winmm");
exe.addObjectFile(.{ .path = "/mnt/c/Program Files (x86)/MiniFB/lib/minifb.lib" });
//flags[0] = "-D_NO_CRT_STDIO_INLINE";
}
exe.addCSourceFile(.{ .file = .{ .path = "src/peripherals/video.c" }, .flags = &flags });
const arch = b.addModule("arch", .{ .source_file = .{ .path = "src/arch.zig" } });
exe.addModule("arch", arch);
const memory = b.addModule("memory", .{ .source_file = .{ .path = "src/memory.zig" } });
exe.addModule("memory", memory);
deps.addAllTo(exe);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
// This allows the user to pass arguments to the application in the build
// command itself, like this: `zig build run -- arg1 arg2 etc`
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
unit_tests.addModule("arch", arch);
unit_tests.addModule("memory", memory);
deps.addAllTo(unit_tests);
const run_unit_tests = b.addRunArtifact(unit_tests);
// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
}