-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeps.zig
110 lines (100 loc) · 3.68 KB
/
deps.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
// zig fmt: off
const std = @import("std");
const builtin = @import("builtin");
const string = []const u8;
pub const cache = ".zigmod\\deps";
pub fn addAllTo(exe: *std.Build.Step.Compile) void {
checkMinZig(builtin.zig_version, exe);
@setEvalBranchQuota(1_000_000);
for (packages) |pkg| {
const module = pkg.module(exe);
exe.root_module.addImport(pkg.import.?[0], module);
}
}
var link_lib_c = false;
pub const Package = struct {
directory: string,
import: ?struct { string, std.Build.LazyPath } = null,
dependencies: []const *Package,
c_include_dirs: []const string = &.{},
c_source_files: []const string = &.{},
c_source_flags: []const string = &.{},
system_libs: []const string = &.{},
frameworks: []const string = &.{},
module_memo: ?*std.Build.Module = null,
pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
if (self.module_memo) |cached| {
return cached;
}
const b = exe.step.owner;
const result = b.createModule(.{});
const dummy_library = b.addStaticLibrary(.{
.name = "dummy",
.target = exe.root_module.resolved_target orelse b.host,
.optimize = exe.root_module.optimize.?,
});
if (self.import) |capture| {
result.root_source_file = capture[1];
}
for (self.dependencies) |item| {
const module_dep = item.module(exe);
if (module_dep.root_source_file != null) {
result.addImport(item.import.?[0], module_dep);
}
for (module_dep.include_dirs.items) |jtem| {
switch (jtem) {
.path => result.addIncludePath(jtem.path),
.path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {},
}
}
}
for (self.c_include_dirs) |item| {
result.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item })));
dummy_library.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item })));
link_lib_c = true;
}
for (self.c_source_files) |item| {
dummy_library.addCSourceFile(.{ .file = b.path(b.fmt("{s}/{s}", .{ self.directory, item })), .flags = self.c_source_flags });
}
for (self.system_libs) |item| {
dummy_library.linkSystemLibrary(item);
}
for (self.frameworks) |item| {
dummy_library.linkFramework(item);
}
if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) {
dummy_library.linkLibC();
exe.root_module.linkLibrary(dummy_library);
link_lib_c = true;
}
if (link_lib_c) {
result.link_libc = true;
}
self.module_memo = result;
return result;
}
};
fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {
const min = std.SemanticVersion.parse("null") catch return;
if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min}));
}
pub const dirs = struct {
pub const _root = "";
pub const _nbq19hf3uad5 = "C:\\ZigProjects\\ZigWebsocketHTTPServer";
};
pub const package_data = struct {
pub var _root = Package{
.directory = dirs._root,
.dependencies = &.{ &_nbq19hf3uad5 },
};
pub var _nbq19hf3uad5 = Package{
.directory = dirs._nbq19hf3uad5,
.dependencies = &.{ },
};
};
pub const packages = &[_]*Package{
};
pub const pkgs = struct {
};
pub const imports = struct {
};