-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathawkbuild.zig
64 lines (57 loc) · 2.25 KB
/
awkbuild.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
const std = @import("std");
const GitRepoStep = @import("GitRepoStep.zig");
pub fn addAwk(
b: *std.build.Builder,
target: anytype,
optimize: anytype,
libc_only_std_static: *std.build.LibExeObjStep,
zig_start: *std.build.LibExeObjStep,
zig_posix: *std.build.LibExeObjStep,
) *std.build.LibExeObjStep {
const repo = GitRepoStep.create(b, .{
.url = "https://github.com/onetrueawk/awk",
.sha = "9e248c317b88470fc86aa7c988919dc49452c88c",
.branch = null,
});
// const config_step = b.addWriteFile(
// b.pathJoin(&.{repo.path, "src", "config.h"}),
// "#define VERSION \"1.0\"",
// );
// config_step.step.dependOn(&repo.step);
const exe = b.addExecutable(.{
.name = "awk",
.target = target,
.optimize = optimize,
});
const install = b.addInstallArtifact(exe, .{});
exe.step.dependOn(&repo.step);
// exe.step.dependOn(&config_step.step);
const repo_path = repo.getPath(&exe.step);
var files = std.ArrayList([]const u8).init(b.allocator);
const sources = [_][]const u8{
// "main.c", "cmph.c", "hash.c", "chm.c", "bmz.c", "bmz8.c", "brz.c", "fch.c",
// "bdz.c", "bdz_ph.c", "chd_ph.c", "chd.c", "jenkins_hash.c", "graph.c", "vqueue.c",
// "buffer_manager.c", "fch_buckets.c", "miller_rabin.c", "compressed_seq.c",
// "compressed_rank.c", "buffer_entry.c", "select.c", "cmph_structs.c",
};
for (sources) |src| {
files.append(b.pathJoin(&.{ repo_path, "src", src })) catch unreachable;
}
exe.addCSourceFiles(files.toOwnedSlice() catch unreachable, &[_][]const u8{
"-std=c11",
});
exe.addIncludePath(.{ .path = "inc/libc" });
exe.addIncludePath(.{ .path = "inc/posix" });
exe.addIncludePath(.{ .path = "inc/gnu" });
exe.linkLibrary(libc_only_std_static);
exe.linkLibrary(zig_start);
exe.linkLibrary(zig_posix);
// TODO: should libc_only_std_static and zig_start be able to add library dependencies?
if (target.getOs().tag == .windows) {
exe.linkSystemLibrary("ntdll");
exe.linkSystemLibrary("kernel32");
}
const step = b.step("awk", "build awk");
step.dependOn(&install.step);
return exe;
}