-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
118 lines (112 loc) · 4.01 KB
/
build.zig
File metadata and controls
118 lines (112 loc) · 4.01 KB
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
const std = @import("std");
const os = @import("builtin").os.tag;
const version = @import("version.zig");
const Builder = std.Build;
pub fn build(b: *Builder) void {
const current_zig_version = @import("builtin").zig_version;
if (current_zig_version.major != 0 or current_zig_version.minor < 16) {
std.debug.print("This project does not compile with a Zig version <0.16.x. Exiting.", .{});
std.os.exit(1);
}
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const basename = addExe(b, target, "basename", false);
const chgrp = addExe(b, target,"chgrp", true);
const chmod = addExe(b,target, "chmod", true);
const chown = addExe(b, target,"chown", true);
const cksum = addExe(b,target, "cksum", false);
const dircolors = addExe(b,target, "dircolors", false);
const dirname = addExe(b,target, "dirname", false);
const echo = addExe(b,target, "echo", false);
const expand = addExe(b, target, "expand", false);
const false_app = addExe(b,target, "false", false);
const fold = addExe(b, target,"fold", false);
const groups = addExe(b, target,"groups", true);
const hostid = addExe(b,target, "hostid", true);
const hostname = addExe(b, target,"hostname", false);
const id = addExe(b,target, "id", true);
const kill = addExe(b,target, "kill", false);
const link = addExe(b, target,"link", false);
const logname = addExe(b, target,"logname", true);
const md5sum = addExe(b,target, "md5sum", false);
const mkdir = addExe(b, target,"mkdir", true);
const mkfifo = addExe(b, target,"mkfifo", true);
const mktemp = addExe(b, target,"mktemp", false);
const nice = addExe(b,target, "nice", true);
const nproc = addExe(b, target,"nproc", true);
const printenv = addExe(b,target, "printenv", true);
const pwd = addExe(b,target, "pwd", false);
const readlink = addExe(b,target, "readlink", false);
const realpath = addExe(b, target,"realpath", false);
const rmdir = addExe(b,target, "rmdir", false);
const sleep = addExe(b,target, "sleep", false);
const sum = addExe(b, target,"sum", false);
const sync = addExe(b, target,"sync", false);
const touch = addExe(b,target, "true", false);
const true_app = addExe(b,target, "true", false);
const truncate = addExe(b, target, "truncate", false);
const tty = addExe(b,target, "tty", true);
const unlink = addExe(b,target, "unlink", false);
const uname = addExe(b, target,"uname", false);
const uptime = addExe(b,target, "uptime", true);
const users = addExe(b, target,"users", false);
const whoami = addExe(b,target, "whoami", true);
const yes = addExe(b, target,"yes", false);
_ = basename;
_ = cksum;
_ = dircolors;
_ = dirname;
_ = echo;
_ = expand;
_ = false_app;
_ = fold;
_ = hostname;
_ = kill;
_ = link;
_ = md5sum;
_ = mktemp;
_ = pwd;
_ = readlink;
_ = realpath;
_ = rmdir;
_ = sleep;
_ = sum;
_ = sync;
_ = touch;
_ = true_app;
_ = truncate;
_ = unlink;
_ = uname;
_ = users;
_ = yes;
_ = chgrp;
_ = chmod;
_ = chown;
_ = groups;
_ = hostid;
_ = id;
_ = logname;
_ = mkdir;
_ = mkfifo;
_ = nice;
_ = nproc;
_ = printenv;
_ = tty;
_ = uptime;
_ = whoami;
}
fn addExe(b: *Builder, target: std.Build.ResolvedTarget, comptime name: []const u8, link_c: bool) *Builder.Step.Compile {
const module = b.createModule(.{
.root_source_file = b.path("src/" ++ name ++ ".zig"),
.optimize = .ReleaseSafe,
.target = target
});
if (link_c) {
module.linkSystemLibrary("c", .{});
}
const exe = b.addExecutable(.{ .name = name, .root_module = module, .version = .{ .major = version.major, .minor = version.minor, .patch = version.patch } });
b.default_step.dependOn(&exe.step);
b.installArtifact(exe);
return exe;
}