forked from mattnite/gyro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
119 lines (102 loc) · 2.89 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const std = @import("std");
const libgit2 = @import("libs/libgit2/libgit2.zig");
const mbedtls = @import("libs/mbedtls/mbedtls.zig");
const libssh2 = @import("libs/libssh2/libssh2.zig");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Pkg = std.build.Pkg;
const clap = .{
.name = "clap",
.path = .{ .path = "libs/zig-clap/clap.zig" },
};
const zfetch = .{
.name = "zfetch",
.path = .{ .path = "libs/zfetch/src/main.zig" },
.dependencies = &[_]Pkg{
.{
.name = "iguanaTLS",
.path = .{ .path = "libs/iguanaTLS/src/main.zig" },
},
.{
.name = "network",
.path = .{ .path = "libs/zig-network/network.zig" },
},
.{
.name = "uri",
.path = .{ .path = "libs/zig-uri/uri.zig" },
},
.{
.name = "hzzp",
.path = .{ .path = "libs/hzzp/src/main.zig" },
},
},
};
const zzz = .{
.name = "zzz",
.path = .{ .path = "libs/zzz/src/main.zig" },
};
const glob = .{
.name = "glob",
.path = .{ .path = "libs/glob/src/main.zig" },
};
const tar = .{
.name = "tar",
.path = .{ .path = "libs/tar/src/main.zig" },
};
const version = .{
.name = "version",
.path = .{ .path = "libs/version/src/main.zig" },
.dependencies = &[_]Pkg{
.{
.name = "mecha",
.path = .{ .path = "libs/mecha/mecha.zig" },
},
},
};
const uri = .{
.name = "uri",
.path = .{ .path = "libs/zig-uri/uri.zig" },
};
const known_folders = .{
.name = "known-folders",
.path = .{ .path = "libs/known-folders/known-folders.zig" },
};
fn addAllPkgs(lib: *LibExeObjStep) void {
lib.addPackage(clap);
lib.addPackage(version);
lib.addPackage(tar);
lib.addPackage(zzz);
lib.addPackage(glob);
lib.addPackage(zfetch);
lib.addPackage(uri);
lib.addPackage(known_folders);
}
pub fn build(b: *Builder) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const gyro = b.addExecutable("gyro", "src/main.zig");
gyro.setTarget(target);
gyro.setBuildMode(mode);
gyro.install();
addAllPkgs(gyro);
try libgit2.link(b, gyro);
try libssh2.link(b, gyro);
mbedtls.link(gyro);
// release-* builds for windows end up missing a _tls_index symbol, turning
// off lto fixes this *shrug*
if (target.isWindows())
gyro.want_lto = false;
const tests = b.addTest("src/main.zig");
tests.setBuildMode(mode);
tests.setTarget(target);
addAllPkgs(tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests.step);
const run_cmd = gyro.run();
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);
}