-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
54 lines (47 loc) · 2.19 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
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.Build) void {
comptime {
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.11.0") catch unreachable; // Merge pull request #16446 from MasterQ32/buildsystem_rename_orgy
if (current_zig.order(min_zig) == .lt) {
@compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
}
// 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 optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{ .name = "zig-worktree", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize });
addPaths(exe, b);
exe.linkSystemLibrary("git2");
exe.linkLibC();
//exe.install();
b.installArtifact(exe);
const exe_tests = b.addTest(.{ .name = "zig-worktree", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize });
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step);
}
// add `include` and `lib` paths
fn addPaths(exe: *std.Build.Step.Compile, b: *std.Build) void {
switch (builtin.target.os.tag) {
.windows => {
exe.addIncludePath(b.path("./deps/include"));
exe.addLibraryPath(b.path("./deps/lib"));
},
.freebsd, .openbsd, .netbsd, .linux => {
// use system paths
},
.macos => {
exe.addIncludePath(.{ .cwd_relative = "/opt/homebrew/include" });
exe.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/lib" });
},
else => {
@compileError("Platform is not supported!");
},
}
}