-
Notifications
You must be signed in to change notification settings - Fork 0
/
deps.zig
140 lines (121 loc) · 3.85 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
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
const std = @import("std");
const builtin = @import("builtin");
const Pkg = std.build.Pkg;
const string = []const u8;
pub const cache = ".zigmod/deps";
pub fn addAllTo(
exe: *std.build.LibExeObjStep,
b: *std.build.Builder,
target: std.zig.CrossTarget,
mode: std.builtin.Mode,
) *std.build.LibExeObjStep {
@setEvalBranchQuota(1_000_000);
exe.setTarget(target);
exe.setBuildMode(mode);
// lazy
if (c_libs[0] == null) resolveCLibs(b, target, mode);
for (c_libs) |c_lib| exe.linkLibrary(c_lib.?);
for (packages) |pkg| {
exe.addPackage(pkg.pkg.?);
}
inline for (std.meta.declarations(package_data)) |decl| {
const pkg = @as(Package, @field(package_data, decl.name));
inline for (pkg.system_libs) |item| {
exe.linkSystemLibrary(item);
}
inline for (pkg.c_include_dirs) |item| {
exe.addIncludeDir(@field(dirs, decl.name) ++ "/" ++ item);
}
inline for (pkg.c_source_files) |item| {
exe.addCSourceFile(@field(dirs, decl.name) ++ "/" ++ item, pkg.c_source_flags);
}
}
exe.linkLibC();
return exe;
}
pub const CLib = struct {
name: string,
idx: usize,
pub fn getStep(self: *CLib) ?*std.build.LibExeObjStep {
return c_libs[self.idx];
}
};
pub const Package = struct {
directory: string,
pkg: ?Pkg = null,
c_include_dirs: []const string = &.{},
c_libs: []const CLib = &.{},
c_source_files: []const string = &.{},
c_source_flags: []const string = &.{},
system_libs: []const string = &.{},
vcpkg: bool = false,
};
pub const dirs = struct {
pub const _root = "";
pub const _u8xgq6eugih6 = ".";
pub const _f3itt0eg63fb = cache ++ "/v/git/github.com/zpplibs/zpp/branch-master";
};
const zero_deps_map = std.ComptimeStringMap(string, .{ .{ "", "" } });
pub const dep_dirs = struct {
pub const _root = std.ComptimeStringMap(string, .{
.{ "zpp-snappy", dirs._u8xgq6eugih6 },
.{ "zpp", dirs._f3itt0eg63fb },
});
pub const _u8xgq6eugih6 = std.ComptimeStringMap(string, .{
.{ "zpp", dirs._f3itt0eg63fb },
});
pub const _f3itt0eg63fb = zero_deps_map;
};
pub const package_data = struct {
pub const _f3itt0eg63fb = Package{
.directory = dirs._f3itt0eg63fb,
.pkg = Pkg{ .name = "zpp", .path = .{ .path = dirs._f3itt0eg63fb ++ "/src/lib.zig" }, .dependencies = null },
.c_include_dirs = &.{ "include" },
.c_libs = &.{
.{ .name = "zpp", .idx = 0 },
},
};
pub const _u8xgq6eugih6 = Package{
.directory = dirs._u8xgq6eugih6,
.pkg = Pkg{ .name = "zpp-snappy", .path = .{ .path = dirs._u8xgq6eugih6 ++ "/src/lib.zig" }, .dependencies = &.{ _f3itt0eg63fb.pkg.? } },
.c_include_dirs = &.{ "include", "snappy" },
.c_libs = &.{
.{ .name = "snappy", .idx = 1 },
},
};
pub const _root = Package{
.directory = dirs._root,
};
};
pub const packages = &[_]Package{
package_data._u8xgq6eugih6,
package_data._f3itt0eg63fb,
};
pub const pkgs = struct {
pub const zpp_snappy = package_data._u8xgq6eugih6;
pub const zpp = package_data._f3itt0eg63fb;
};
// lazy
var c_libs = std.mem.zeroes([2]?*std.build.LibExeObjStep);
fn resolveCLibs(
b: *std.build.Builder,
target: std.zig.CrossTarget,
mode: std.builtin.Mode,
) void {
c_libs[0] = @import(".zigmod/deps/v/git/github.com/zpplibs/zpp/branch-master/zpp_lib.zig").configure(
dirs._f3itt0eg63fb,
dep_dirs._f3itt0eg63fb,
dep_dirs._root,
b.allocator,
b.addStaticLibrary("zpp", null),
target, mode,
);
c_libs[1] = @import("snappy_lib.zig").configure(
dirs._u8xgq6eugih6,
dep_dirs._u8xgq6eugih6,
dep_dirs._root,
b.allocator,
b.addStaticLibrary("snappy", null),
target, mode,
);
}