authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-10 15:22:27 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-10 15:22:27 -08:00
logbdf9c970a56132a60d67f10f632bfe19a30b4d74
treead149eacb3d287000769c662e75d772746489a13
parentcee55e13da2262f794f77e3848b2e564e58130b0

commit missing fetch update


4 files changed, 42 insertions(+), 15 deletions(-)

README.md+8
......@@ -16,6 +16,14 @@ A package manager for the Zig programming language.
1616## Download
1717- https://github.com/nektro/zigmod/releases
1818
190.11.0-dev.389+e35f297ae ArrayList.toOwnedSlice
200.11.0-dev.874+40ed6ae84 field_type -> type, layout field
210.11.0-dev.692+023b597ab ascii rename
220.11.0-dev.632+d69e97ae1 compileError is comptime
230.11.0-dev.67+1d6804591 .i386 -> .x86
240.11.0-dev.1570+693b12f8e std.build.Pkg removed, updated to new system
250.11.0-dev.1567+60935decd std.zig.Ast.parse
26
1927## Built With
2028- Zig master (at least `0.11.0-dev.1570+693b12f8e`)
2129- See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock)
build.zig+1-6
......@@ -10,12 +10,7 @@ pub fn build(b: *std.build.Builder) void {
1010 const use_full_name = b.option(bool, "use-full-name", "") orelse false;
1111 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) });
1212 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
13 const exe = b.addExecutable(.{
14 .name = exe_name,
15 .root_source_file = .{ .path = "src/main.zig" },
16 .target = target,
17 .optimize = optimize,
18 });
13 const exe = b.addExecutable(.{ .name = exe_name, .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize });
1914
2015 const exe_options = b.addOptions();
2116 exe.addOptions("build_options", exe_options);
src/cmd/fetch.zig+24-3
......@@ -41,8 +41,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
4141 try w.writeAll("// zig fmt: off\n");
4242 try w.writeAll("const std = @import(\"std\");\n");
4343 try w.writeAll("const builtin = @import(\"builtin\");\n");
44 try w.writeAll("const Pkg = std.build.Pkg;\n");
4544 try w.writeAll("const string = []const u8;\n");
45 try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n");
4646 try w.writeAll("\n");
4747 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
4848 try w.writeAll("\n");
......@@ -51,7 +51,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
5151 \\ checkMinZig(builtin.zig_version, exe);
5252 \\ @setEvalBranchQuota(1_000_000);
5353 \\ for (packages) |pkg| {
54 \\ exe.addPackage(pkg.pkg.?);
54 \\ const moddep = pkg.pkg.?.zp(exe.builder);
55 \\ exe.addModule(moddep.name, moddep.module);
5556 \\ }
5657 \\ var llc = false;
5758 \\ var vcpkg = false;
......@@ -91,6 +92,26 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
9192 \\ vcpkg: bool = false,
9293 \\};
9394 \\
95 \\pub const Pkg = struct {
96 \\ name: string,
97 \\ source: std.build.FileSource,
98 \\ dependencies: []const Pkg,
99 \\
100 \\ pub fn zp(self: *const Pkg, b: *std.build.Builder) ModuleDependency {
101 \\ var temp: [100]ModuleDependency = undefined;
102 \\ for (self.dependencies) |item, i| {
103 \\ temp[i] = item.zp(b);
104 \\ }
105 \\ return .{
106 \\ .name = self.name,
107 \\ .module = b.createModule(.{
108 \\ .source_file = self.source,
109 \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.dependencies.len]) catch @panic("oom"),
110 \\ }),
111 \\ };
112 \\ }
113 \\};
114 \\
94115 \\
95116 );
96117
......@@ -290,7 +311,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
290311 mod.main,
291312 });
292313 if (mod.has_no_zig_deps()) {
293 try w.writeAll(" null },\n");
314 try w.writeAll(" &.{} },\n");
294315 } else {
295316 try w.writeAll(" &.{");
296317 for (mod.deps) |moddep, j| {
src/cmd/generate.zig+9-6
......@@ -39,7 +39,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
3939 try w.writeAll("// zig fmt: off\n");
4040 try w.writeAll("const std = @import(\"std\");\n");
4141 try w.writeAll("const builtin = @import(\"builtin\");\n");
42 try w.writeAll("const Pkg = std.build.Pkg;\n");
42 try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n");
4343 try w.writeAll("const string = []const u8;\n");
4444 try w.writeAll("\n");
4545 try w.writeAll(
......@@ -122,7 +122,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
122122 \\ const b = exe.builder;
123123 \\ @setEvalBranchQuota(1_000_000);
124124 \\ for (packages) |pkg| {
125 \\ exe.addPackage(pkg.zp(b));
125 \\ const moddep = pkg.zp(b);
126 \\ exe.addModule(moddep.name, moddep.module);
126127 \\ }
127128 \\ var llc = false;
128129 \\ var vcpkg = false;
......@@ -164,15 +165,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
164165 \\ frameworks: []const string = &.{},
165166 \\ vcpkg: bool = false,
166167 \\
167 \\ pub fn zp(self: *const Package, b: *std.build.Builder) Pkg {
168 \\ var temp: [100]Pkg = undefined;
168 \\ pub fn zp(self: *const Package, b: *std.build.Builder) ModuleDependency {
169 \\ var temp: [100]ModuleDependency = undefined;
169170 \\ for (self.deps) |item, i| {
170171 \\ temp[i] = item.zp(b);
171172 \\ }
172173 \\ return .{
173174 \\ .name = self.name,
174 \\ .source = .{ .path = self.entry.? },
175 \\ .dependencies = b.allocator.dupe(Pkg, temp[0..self.deps.len]) catch @panic("oom"),
175 \\ .module = b.createModule(.{
176 \\ .source_file = .{ .path = self.entry.? },
177 \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"),
178 \\ }),
176179 \\ };
177180 \\ }
178181 \\};