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
|
const std = @import("std");
const name = "minimgui";
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const emit_exe = b.option(bool, "emit-exe", "emit executable file") orelse false;
const emit_lib = b.option(bool, "emit-lib", "emit shared object file") orelse false;
const strip = b.option(bool, "strip", "strip debug symbols") orelse true;
const mod = b.createModule(.{
.root_source_file = b.path(switch (target.result.os.tag) {
.linux => "src/linux.zig",
else => return error.UnsupportedOs,
}),
.target = target,
.optimize = optimize,
.link_libc = true,
.strip = strip,
});
mod.linkSystemLibrary("x11", .{});
mod.linkSystemLibrary("xext", .{});
mod.addIncludePath(b.path("lib/stb_image/"));
mod.addCSourceFile(.{.file = b.path("lib/stb_image/stb_image.c"), .flags = &.{}});
mod.addIncludePath(b.path("lib/stb_truetype/"));
mod.addCSourceFile(.{.file = b.path("lib/stb_truetype/stb_truetype.c"), .flags = &.{}});
const use_llvm = !strip or optimize != .Debug;
if (emit_exe) {
const exe = b.addExecutable(.{
.name = name,
.root_module = mod,
.use_llvm = use_llvm,
});
b.installArtifact(exe);
}
if (emit_lib) {
const lib = b.addLibrary(.{
.name = name,
.root_module = mod,
.linkage = .dynamic,
.use_llvm = use_llvm,
});
b.installArtifact(lib);
}
}
|