| author | |
| committer | |
| log | 88315d01914758e90d95174217fd8b8126ac6e39 |
| tree | 8bca72b8ab31d7a6b9cfef365a8b971124bd56ee |
| parent | c07a963cfcd351d15dccfe131c1df91a231f3321 |
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 | ... | @@ -54,6 +54,11 @@ Similar to `dependencies` but will only get added to the project if the current |
| 54 | - Type: `string` | 54 | - Type: `string` |
| 55 | Parsed 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. | 55 | Parsed 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. |
| 56 | 56 | ||
| 57 | #### `vcpkg` | ||
| 58 | - Type: `bool` | ||
| 59 | - Example: `true`|any | ||
| 60 | This 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 | |||
| 57 | ---- | 62 | ---- |
| 58 | 63 | ||
| 59 | ### Dep Object | 64 | ### 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 | ... | @@ -331,7 +331,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul |
| 331 | } | 331 | } |
| 332 | try w.writeAll(" },\n"); | 332 | try w.writeAll(" },\n"); |
| 333 | } | 333 | } |
| 334 | if (mod.has_vcpkg_deps()) { | 334 | if (mod.vcpkg) { |
| 335 | try w.writeAll(" .vcpkg = true,\n"); | 335 | try w.writeAll(" .vcpkg = true,\n"); |
| 336 | } | 336 | } |
| 337 | try w.writeAll(" };\n"); | 337 | 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 | ... | @@ -60,6 +60,7 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO |
| 60 | .yaml = m.yaml, | 60 | .yaml = m.yaml, |
| 61 | .dep = null, | 61 | .dep = null, |
| 62 | .min_zig_version = m.min_zig_version, | 62 | .min_zig_version = m.min_zig_version, |
| 63 | .vcpkg = m.vcpkg, | ||
| 63 | }; | 64 | }; |
| 64 | } | 65 | } |
| 65 | 66 | ||
| ... | @@ -91,6 +92,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption | ... | @@ -91,6 +92,7 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption |
| 91 | .yaml = m.yaml, | 92 | .yaml = m.yaml, |
| 92 | .dep = null, | 93 | .dep = null, |
| 93 | .min_zig_version = m.min_zig_version, | 94 | .min_zig_version = m.min_zig_version, |
| 95 | .vcpkg = m.vcpkg, | ||
| 94 | }; | 96 | }; |
| 95 | } | 97 | } |
| 96 | 98 | ||
| ... | @@ -242,6 +244,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO | ... | @@ -242,6 +244,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 242 | .dep = d.*, | 244 | .dep = d.*, |
| 243 | .for_build = d.for_build, | 245 | .for_build = d.for_build, |
| 244 | .min_zig_version = null, | 246 | .min_zig_version = null, |
| 247 | .vcpkg = false, | ||
| 245 | }; | 248 | }; |
| 246 | }, | 249 | }, |
| 247 | else => { | 250 | else => { |
src/util/modfile.zig+2| ... | @@ -28,6 +28,7 @@ pub const ModFile = struct { | ... | @@ -28,6 +28,7 @@ pub const ModFile = struct { |
| 28 | rootdeps: []zigmod.Dep, | 28 | rootdeps: []zigmod.Dep, |
| 29 | builddeps: []zigmod.Dep, | 29 | builddeps: []zigmod.Dep, |
| 30 | min_zig_version: ?std.SemanticVersion, | 30 | min_zig_version: ?std.SemanticVersion, |
| 31 | vcpkg: bool, | ||
| 31 | 32 | ||
| 32 | pub fn init(alloc: std.mem.Allocator, mpath: string) !Self { | 33 | pub fn init(alloc: std.mem.Allocator, mpath: string) !Self { |
| 33 | const file = try std.fs.cwd().openFile(mpath, .{}); | 34 | const file = try std.fs.cwd().openFile(mpath, .{}); |
| ... | @@ -68,6 +69,7 @@ pub const ModFile = struct { | ... | @@ -68,6 +69,7 @@ pub const ModFile = struct { |
| 68 | .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false), | 69 | .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false), |
| 69 | .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true), | 70 | .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true), |
| 70 | .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version")) catch null, | 71 | .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")), | ||
| 71 | }; | 73 | }; |
| 72 | } | 74 | } |
| 73 | 75 |
src/util/module.zig+2-10| ... | @@ -27,6 +27,7 @@ pub const Module = struct { | ... | @@ -27,6 +27,7 @@ pub const Module = struct { |
| 27 | dep: ?zigmod.Dep, | 27 | dep: ?zigmod.Dep, |
| 28 | for_build: bool = false, | 28 | for_build: bool = false, |
| 29 | min_zig_version: ?std.SemanticVersion, | 29 | min_zig_version: ?std.SemanticVersion, |
| 30 | vcpkg: bool, | ||
| 30 | 31 | ||
| 31 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module { | 32 | pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, modpath: string, options: *common.CollectOptions) !Module { |
| 32 | var moddeps = std.ArrayList(Module).init(alloc); | 33 | var moddeps = std.ArrayList(Module).init(alloc); |
| ... | @@ -54,6 +55,7 @@ pub const Module = struct { | ... | @@ -54,6 +55,7 @@ pub const Module = struct { |
| 54 | .dep = dep, | 55 | .dep = dep, |
| 55 | .for_build = dep.for_build, | 56 | .for_build = dep.for_build, |
| 56 | .min_zig_version = null, | 57 | .min_zig_version = null, |
| 58 | .vcpkg = dep.vcpkg, | ||
| 57 | }; | 59 | }; |
| 58 | } | 60 | } |
| 59 | 61 | ||
| ... | @@ -123,16 +125,6 @@ pub const Module = struct { | ... | @@ -123,16 +125,6 @@ pub const Module = struct { |
| 123 | return false; | 125 | return false; |
| 124 | } | 126 | } |
| 125 | 127 | ||
| 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 | |||
| 136 | pub fn short_id(self: Module) string { | 128 | pub fn short_id(self: Module) string { |
| 137 | return u.slice(u8, self.id, 0, 12); | 129 | return u.slice(u8, self.id, 0, 12); |
| 138 | } | 130 | } |