-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
98 lines (85 loc) · 2.37 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
var targets = std.ArrayList(*std.Build.CompileStep).init(b.allocator);
const lib = b.addStaticLibrary(.{
.name = "libtui",
.version = .{ .major = 1, .minor = 0, .patch = 0 },
.target = target,
.optimize = optimize,
});
var flags = &.{
"-std=c99",
"-Wextra",
"-Wall",
"-Wfloat-equal",
"-Wundef",
"-Wshadow",
"-Wpointer-arith",
"-Wcast-align",
"-Wstrict-prototypes",
"-Wstrict-prototypes",
"-Wwrite-strings",
"-Waggregate-return",
"-Wcast-qual",
"-Werror",
"-Winit-self",
"-Wno-error=unused-command-line-argument",
"-O1",
"-fsanitize-address-use-after-scope",
"-fsanitize-address-use-odr-indicator",
"-fsanitize-memory-use-after-dtor",
"-fno-omit-frame-pointer",
"-fstack-protector-strong",
};
lib.linkLibC();
lib.addCSourceFile(.{
.file = .{
.path = "lib/libtui_buffer.c",
},
.flags = flags,
});
lib.addCSourceFile(.{
.file = .{
.path = "lib/libtui_renderer.c",
},
.flags = flags,
});
lib.addCSourceFile(.{
.file = .{
.path = "lib/libtui_draw.c",
},
.flags = flags,
});
lib.addCSourceFile(.{
.file = .{
.path = "lib/libtui_keyboard.c",
},
.flags = flags,
});
lib.addCSourceFile(.{
.file = .{
.path = "lib/libtui_term_control.c",
},
.flags = flags,
});
targets.append(lib) catch @panic("OOM");
const example_exe = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "examples/simple.c" },
.target = target,
.optimize = optimize,
});
example_exe.addIncludePath(.{
.path = "lib",
});
example_exe.linkLibC();
example_exe.linkLibrary(lib);
targets.append(example_exe) catch @panic("OOM");
b.installArtifact(example_exe);
const run_cmd = b.addRunArtifact(example_exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}