-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.zig
133 lines (121 loc) · 5.6 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const std = @import("std");
const Build = std.Build;
pub const SdkOpts = struct {
build_examples: bool = false,
};
const Example = struct {
description: ?[]const u8,
output: []const u8,
input: []const u8,
pub fn init(output: []const u8, input: []const u8, desc: ?[]const u8) Example {
return Example{
.description = desc,
.output = output,
.input = input,
};
}
};
pub const examples = &[_]Example{
Example.init("simple", "examples/simple.zig", "A simple hello world app"),
Example.init("capi", "examples/capi.zig", "Using the C-api directly"),
Example.init("customwidget", "examples/customwidget.zig", "Custom widget example"),
Example.init("image", "examples/image.zig", "Simple image example"),
Example.init("input", "examples/input.zig", "Simple input example"),
Example.init("mixed", "examples/mixed.zig", "Mixing both c and zig apis"),
Example.init("editor", "examples/editor.zig", "More complex example"),
Example.init("layout", "examples/layout.zig", "Layout example"),
Example.init("valuators", "examples/valuators.zig", "valuators example"),
Example.init("channels", "examples/channels.zig", "Use messages to handle events"),
Example.init("editormsgs", "examples/editormsgs.zig", "Use messages in the editor example"),
Example.init("browser", "examples/browser.zig", "Browser example"),
Example.init("flex", "examples/flex.zig", "Flex example"),
Example.init("threadawake", "examples/threadawake.zig", "Thread awake example"),
Example.init("handle", "examples/handle.zig", "Handle example"),
Example.init("flutterlike", "examples/flutterlike.zig", "Flutter-like example"),
Example.init("glwin", "examples/glwin.zig", "OpenGL window example"),
Example.init("tile", "examples/tile.zig", "Tile group example"),
};
var opts: SdkOpts = undefined;
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
opts = SdkOpts{
.build_examples = b.option(bool, "zfltk-build-examples", "Build zfltk examples") orelse false,
};
const zfltk = b.addModule("zfltk", .{
.root_source_file = b.path("src/zfltk.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.link_libcpp = true,
});
zfltk.linkSystemLibrary("cfltk", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk_images", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk_png", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk_jpeg", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk_z", .{ .preferred_link_mode = .static });
zfltk.linkSystemLibrary("fltk_gl", .{ .preferred_link_mode = .static });
const target_os = try std.zig.system.resolveTargetQuery(.{});
if (target_os.os.tag == .windows) {
zfltk.linkSystemLibrary("ws2_32", .{});
zfltk.linkSystemLibrary("comctl32", .{});
zfltk.linkSystemLibrary("gdi32", .{});
zfltk.linkSystemLibrary("oleaut32", .{});
zfltk.linkSystemLibrary("ole32", .{});
zfltk.linkSystemLibrary("uuid", .{});
zfltk.linkSystemLibrary("shell32", .{});
zfltk.linkSystemLibrary("advapi32", .{});
zfltk.linkSystemLibrary("comdlg32", .{});
zfltk.linkSystemLibrary("winspool", .{});
zfltk.linkSystemLibrary("user32", .{});
zfltk.linkSystemLibrary("kernel32", .{});
zfltk.linkSystemLibrary("odbc32", .{});
zfltk.linkSystemLibrary("gdiplus", .{});
zfltk.linkSystemLibrary("opengl32", .{});
zfltk.linkSystemLibrary("glu32", .{});
} else if (target_os.isDarwin()) {
zfltk.linkFramework("Carbon", .{});
zfltk.linkFramework("Cocoa", .{});
zfltk.linkFramework("ApplicationServices", .{});
zfltk.linkFramework("OpenGL", .{});
zfltk.linkFramework("UniformTypeIdentifiers", .{});
} else {
zfltk.linkSystemLibrary("wayland-client", .{});
zfltk.linkSystemLibrary("wayland-cursor", .{});
zfltk.linkSystemLibrary("xkbcommon", .{});
zfltk.linkSystemLibrary("dbus-1", .{});
zfltk.linkSystemLibrary("EGL", .{});
zfltk.linkSystemLibrary("wayland-egl", .{});
zfltk.linkSystemLibrary("GL", .{});
zfltk.linkSystemLibrary("GLU", .{});
zfltk.linkSystemLibrary("pthread", .{});
zfltk.linkSystemLibrary("X11", .{});
zfltk.linkSystemLibrary("Xext", .{});
zfltk.linkSystemLibrary("Xinerama", .{});
zfltk.linkSystemLibrary("Xcursor", .{});
zfltk.linkSystemLibrary("Xrender", .{});
zfltk.linkSystemLibrary("Xfixes", .{});
zfltk.linkSystemLibrary("Xft", .{});
zfltk.linkSystemLibrary("fontconfig", .{});
zfltk.linkSystemLibrary("pango-1.0", .{});
zfltk.linkSystemLibrary("pangoxft-1.0", .{});
zfltk.linkSystemLibrary("gobject-2.0", .{});
zfltk.linkSystemLibrary("cairo", .{});
zfltk.linkSystemLibrary("pangocairo-1.0", .{});
}
if (opts.build_examples) {
const examples_step = b.step("examples", "build the zfltk examples");
for (examples) |ex| {
const exe = b.addExecutable(.{
.name = ex.output,
.root_source_file = b.path(ex.input),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zfltk", zfltk);
examples_step.dependOn(&exe.step);
b.installArtifact(exe);
}
}
}