Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
190 lines (153 loc) · 5.86 KB
/
Copy pathbuild.zig
File metadata and controls
190 lines (153 loc) · 5.86 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimise = b.standardOptimizeOption(.{});
//dependencies
const zip = b.dependency("zip", .{});
//common
const common_module = b.createModule(.{
.root_source_file = b.path("src/common.zig"),
.target = target,
.optimize = optimise,
});
common_module.addImport("zip", zip.module("zip"));
//root
const root_module = b.addModule("modlib", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimise,
});
root_module.addImport("common", common_module);
//test step
const test_module = b.createModule(.{
.root_source_file = b.path("test/tests.zig"),
.target = target,
.optimize = optimise,
});
test_module.addImport("modlib", root_module);
test_module.addImport("common", common_module);
const tests = b.addTest(.{
.root_module = test_module,
});
const test_artifact = b.addRunArtifact(tests);
const test_step = b.step("test", "Run Tests");
test_step.dependOn(&test_artifact.step);
//bind step
const bind_module = b.createModule(.{
.root_source_file = b.path("bind/bind.zig"),
.target = target,
.optimize = optimise,
});
bind_module.addImport("modlib", root_module);
const bind_lib_dynamic = b.addLibrary(.{
.name = "haze_mod_lib",
.linkage = .dynamic,
.root_module = bind_module,
});
const bind_lib_static = b.addLibrary(.{
.name = "haze_mod_lib_static",
.linkage = .static,
.root_module = bind_module,
});
const bind_dynamic_artifact = b.addInstallArtifact(bind_lib_dynamic, .{});
const bind_static_artifact = b.addInstallArtifact(bind_lib_static, .{});
const bind_step = b.step("bind", "Generate bindings.");
bind_step.dependOn(&bind_dynamic_artifact.step);
bind_step.dependOn(&bind_static_artifact.step);
const release_step = b.step("release", "Compile Bindings");
const java_bind_module = b.createModule(.{
.root_source_file = b.path("bind/bind.zig"),
.link_libcpp = true,
.target = target,
.optimize = optimise,
});
java_bind_module.addImport("modlib", root_module);
java_bind_module.addCSourceFile(.{
.file = b.path(".out/wrap/java/haze_mod_lib_wrap.cxx"),
.flags = &.{ "-std=c++23", "-DJNICALL=" },
});
const os_tag = target.result.os.tag;
if (os_tag == .windows) {
java_bind_module.addIncludePath(b.path("bind/include/jni/win32/"));
} else if (os_tag == .linux) {
java_bind_module.addIncludePath(b.path("bind/include/jni/linux/"));
}
java_bind_module.addIncludePath(b.path("bind/"));
const java_dll = b.addLibrary(.{
.name = "haze_mod_lib_java",
.linkage = .dynamic,
.root_module = java_bind_module,
});
const java_bind_artifact = b.addInstallArtifact(java_dll, .{});
const csharp_bind_module = b.createModule(.{
.root_source_file = b.path("bind/bind.zig"),
.link_libcpp = true,
.target = target,
.optimize = optimise,
});
csharp_bind_module.addImport("modlib", root_module);
csharp_bind_module.addCSourceFile(.{
.file = b.path(".out/wrap/csharp/haze_mod_lib_wrap.cxx"),
.flags = &.{ "-std=c++23" },
});
csharp_bind_module.addIncludePath(b.path("bind/"));
const csharp_dll = b.addLibrary(.{
.name = "haze_mod_lib_csharp",
.linkage = .dynamic,
.root_module = csharp_bind_module,
});
const csharp_bind_artifact = b.addInstallArtifact(csharp_dll, .{});
const python_bind_module = b.createModule(.{
.root_source_file = b.path("bind/bind.zig"),
.link_libcpp = true,
.target = target,
.optimize = optimise,
});
python_bind_module.addImport("modlib", root_module);
python_bind_module.addCSourceFile(.{
.file = b.path(".out/wrap/python/haze_mod_lib_wrap.cxx"),
.flags = &.{ "-std=c++23" },
});
python_bind_module.addIncludePath(b.path("bind/"));
if (os_tag == .windows) {
python_bind_module.addIncludePath(b.path("bind/include/python/win32/headers/"));
python_bind_module.addLibraryPath(b.path("bind/include/python/win32/libs/"));
python_bind_module.linkSystemLibrary("python314", .{
.preferred_link_mode = .static,
});
} else if (os_tag == .linux) {
python_bind_module.addIncludePath(b.path("bind/include/python/linux/headers/"));
python_bind_module.addLibraryPath(b.path("bind/include/python/linux/libs/"));
python_bind_module.linkSystemLibrary("python3.14", .{
.preferred_link_mode = .dynamic,
});
}
const python_dll = b.addLibrary(.{
.name = "haze_mod_lib_python",
.linkage = .dynamic,
.root_module = python_bind_module,
});
const python_bind_artifact = b.addInstallArtifact(python_dll, .{});
const go_bind_module = b.createModule(.{
.root_source_file = b.path("bind/bind.zig"),
.link_libcpp = true,
.target = target,
.optimize = optimise,
});
go_bind_module.addImport("modlib", root_module);
go_bind_module.addCSourceFile(.{
.file = b.path(".out/wrap/csharp/haze_mod_lib_wrap.cxx"),
.flags = &.{ "-std=c++23" },
});
go_bind_module.addIncludePath(b.path("bind/"));
const go_dll = b.addLibrary(.{
.name = "haze_mod_lib_go",
.linkage = .dynamic,
.root_module = go_bind_module,
});
const go_bind_artifact = b.addInstallArtifact(go_dll, .{});
release_step.dependOn(&java_bind_artifact.step);
release_step.dependOn(&csharp_bind_artifact.step);
release_step.dependOn(&python_bind_artifact.step);
release_step.dependOn(&go_bind_artifact.step);
}