authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-01-19 02:17:21 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-01-19 02:17:21 -08:00
log88315d01914758e90d95174217fd8b8126ac6e39
tree8bca72b8ab31d7a6b9cfef365a8b971124bd56ee
parentc07a963cfcd351d15dccfe131c1df91a231f3321

final fix for vcpkg support


5 files changed, 13 insertions(+), 11 deletions(-)

docs/zig.mod.md+5
......@@ -54,6 +54,11 @@ Similar to `dependencies` but will only get added to the project if the current
5454- Type: `string`
5555Parsed as a `std.SemanticVersion`, this attribute refers to the minimum compatible Zig version for this package/application and will cause `zig build` to panic if violated.
5656
57#### `vcpkg`
58- Type: `bool`
59- Example: `true`|any
60This attribute is a flag to call `try exe.addVcpkgPaths(.static);` when on Windows. Likely used in conjunction with adding system libraries/C code. `true` is the only value that will enable this flag.
61
5762----
5863
5964### Dep Object
src/cmd/fetch.zig+1-1
......@@ -331,7 +331,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
331331 }
332332 try w.writeAll(" },\n");
333333 }
334 if (mod.has_vcpkg_deps()) {
334 if (mod.vcpkg) {
335335 try w.writeAll(" .vcpkg = true,\n");
336336 }
337337 try w.writeAll(" };\n");
src/common.zig+3
......@@ -60,6 +60,7 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO
6060 .yaml = m.yaml,
6161 .dep = null,
6262 .min_zig_version = m.min_zig_version,
63 .vcpkg = m.vcpkg,
6364 };
6465}
6566
......@@ -91,6 +92,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption
9192 .yaml = m.yaml,
9293 .dep = null,
9394 .min_zig_version = m.min_zig_version,
95 .vcpkg = m.vcpkg,
9496 };
9597}
9698
......@@ -242,6 +244,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
242244 .dep = d.*,
243245 .for_build = d.for_build,
244246 .min_zig_version = null,
247 .vcpkg = false,
245248 };
246249 },
247250 else => {
src/util/modfile.zig+2
......@@ -28,6 +28,7 @@ pub const ModFile = struct {
2828 rootdeps: []zigmod.Dep,
2929 builddeps: []zigmod.Dep,
3030 min_zig_version: ?std.SemanticVersion,
31 vcpkg: bool,
3132
3233 pub fn init(alloc: std.mem.Allocator, mpath: string) !Self {
3334 const file = try std.fs.cwd().openFile(mpath, .{});
......@@ -68,6 +69,7 @@ pub const ModFile = struct {
6869 .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false),
6970 .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true),
7071 .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version")) catch null,
72 .vcpkg = std.mem.eql(u8, "true", mapping.get_string("vcpkg")),
7173 };
7274 }
7375
src/util/module.zig+2-10
......@@ -27,6 +27,7 @@ pub const Module = struct {
2727 dep: ?zigmod.Dep,
2828 for_build: bool = false,
2929 min_zig_version: ?std.SemanticVersion,
30 vcpkg: bool,
3031
3132 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module {
3233 var moddeps = std.ArrayList(Module).init(alloc);
......@@ -54,6 +55,7 @@ pub const Module = struct {
5455 .dep = dep,
5556 .for_build = dep.for_build,
5657 .min_zig_version = null,
58 .vcpkg = dep.vcpkg,
5759 };
5860 }
5961
......@@ -123,16 +125,6 @@ pub const Module = struct {
123125 return false;
124126 }
125127
126 pub fn has_vcpkg_deps(self: Module) bool {
127 for (self.deps) |d| {
128 const dd = d.dep orelse continue;
129 if (dd.vcpkg) {
130 return true;
131 }
132 }
133 return false;
134 }
135
136128 pub fn short_id(self: Module) string {
137129 return u.slice(u8, self.id, 0, 12);
138130 }