-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
134 lines (112 loc) · 3.26 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
134
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const qt_module = b.addModule("qt", .{
.root_source_file = b.path("lib/qt.zig"),
});
qt_module.addIncludePath(b.path("include"));
const exe = b.addExecutable(.{
.name = "qt-zig",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("qt", qt_module);
// const lib_dynamic_shim = try buildLibQt6DynamicShim(b, .{
// .name = "Qt6DynamicShim",
// .target = target,
// .optimize = optimize,
// });
// _ = &lib_dynamic_shim;
//
// exe.linkLibrary(lib_dynamic_shim);
const lib = try buildLibQtC6(b, .{
.name = "QtC6",
.target = target,
.optimize = optimize,
});
exe.linkLibrary(lib);
exe.linkSystemLibrary("Qt6Core");
exe.linkSystemLibrary("Qt6Widgets");
exe.linkSystemLibrary("Qt6Gui");
b.installArtifact(lib);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
pub fn buildLibQt6DynamicShim(
b: *std.Build,
options: std.Build.ExecutableOptions,
) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{
.name = "Qt6DynamicShim",
.target = options.target,
.optimize = options.optimize,
.strip = options.strip orelse false,
});
lib.addCSourceFiles(.{
.root = b.path("."),
.files = &.{
"lib/cppmangle/qt6_shim.cpp",
},
.flags = &.{
"-DQT_NO_VERSION_TAGGING",
// "-Wall",
// "-Werror",
},
});
lib.linkLibC();
return lib;
}
pub fn buildLibQtC6(
b: *std.Build,
options: std.Build.ExecutableOptions,
) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{
.name = "QtC6",
.target = options.target,
.optimize = options.optimize,
.strip = options.strip orelse false,
});
lib.addIncludePath(b.path("include"));
lib.addCSourceFiles(.{
.root = b.path("."),
.files = &.{
"lib/string.cpp",
"lib/object.cpp",
"lib/widget.cpp",
"lib/application.cpp",
"lib/layout.cpp",
"lib/boxlayout.cpp",
"lib/pushbutton.cpp",
"lib/label.cpp",
"lib/lineedit.cpp",
"lib/listview.cpp",
"lib/listwidget.cpp",
"lib/pixmap.cpp",
"lib/menubar.cpp",
"lib/mainwindow.cpp",
"lib/progressbar.cpp",
"lib/columnview.cpp",
"lib/treeview.cpp",
"lib/treewidget.cpp",
"lib/treewidgetitem.cpp",
"lib/stringlist.cpp",
},
.flags = &.{
"-Wall",
"-Werror",
},
});
lib.linkLibCpp();
lib.linkSystemLibrary("Qt6Core");
lib.linkSystemLibrary("Qt6Widgets");
lib.linkSystemLibrary("Qt6Gui");
return lib;
}