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....@@ -16,6 +16,14 @@ A package manager for the Zig programming language.
16## Download16## Download
17- https://github.com/nektro/zigmod/releases17- 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
19## Built With27## Built With
20- Zig master (at least `0.11.0-dev.1570+693b12f8e`)28- Zig master (at least `0.11.0-dev.1570+693b12f8e`)
21- See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock)29- 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 {...@@ -10,12 +10,7 @@ pub fn build(b: *std.build.Builder) void {
10 const use_full_name = b.option(bool, "use-full-name", "") orelse false;10 const use_full_name = b.option(bool, "use-full-name", "") orelse false;
11 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) });11 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) });
12 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });12 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
13 const exe = b.addExecutable(.{13 const exe = b.addExecutable(.{ .name = exe_name, .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize });
14 .name = exe_name,
15 .root_source_file = .{ .path = "src/main.zig" },
16 .target = target,
17 .optimize = optimize,
18 });
1914
20 const exe_options = b.addOptions();15 const exe_options = b.addOptions();
21 exe.addOptions("build_options", exe_options);16 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...@@ -41,8 +41,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
41 try w.writeAll("// zig fmt: off\n");41 try w.writeAll("// zig fmt: off\n");
42 try w.writeAll("const std = @import(\"std\");\n");42 try w.writeAll("const std = @import(\"std\");\n");
43 try w.writeAll("const builtin = @import(\"builtin\");\n");43 try w.writeAll("const builtin = @import(\"builtin\");\n");
44 try w.writeAll("const Pkg = std.build.Pkg;\n");
45 try w.writeAll("const string = []const u8;\n");44 try w.writeAll("const string = []const u8;\n");
45 try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n");
46 try w.writeAll("\n");46 try w.writeAll("\n");
47 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});47 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
48 try w.writeAll("\n");48 try w.writeAll("\n");
...@@ -51,7 +51,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -51,7 +51,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
51 \\ checkMinZig(builtin.zig_version, exe);51 \\ checkMinZig(builtin.zig_version, exe);
52 \\ @setEvalBranchQuota(1_000_000);52 \\ @setEvalBranchQuota(1_000_000);
53 \\ for (packages) |pkg| {53 \\ for (packages) |pkg| {
54 \\ exe.addPackage(pkg.pkg.?);54 \\ const moddep = pkg.pkg.?.zp(exe.builder);
55 \\ exe.addModule(moddep.name, moddep.module);
55 \\ }56 \\ }
56 \\ var llc = false;57 \\ var llc = false;
57 \\ var vcpkg = false;58 \\ var vcpkg = false;
...@@ -91,6 +92,26 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -91,6 +92,26 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
91 \\ vcpkg: bool = false,92 \\ vcpkg: bool = false,
92 \\};93 \\};
93 \\94 \\
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 \\
94 \\115 \\
95 );116 );
96117
...@@ -290,7 +311,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul...@@ -290,7 +311,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
290 mod.main,311 mod.main,
291 });312 });
292 if (mod.has_no_zig_deps()) {313 if (mod.has_no_zig_deps()) {
293 try w.writeAll(" null },\n");314 try w.writeAll(" &.{} },\n");
294 } else {315 } else {
295 try w.writeAll(" &.{");316 try w.writeAll(" &.{");
296 for (mod.deps) |moddep, j| {317 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...@@ -39,7 +39,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
39 try w.writeAll("// zig fmt: off\n");39 try w.writeAll("// zig fmt: off\n");
40 try w.writeAll("const std = @import(\"std\");\n");40 try w.writeAll("const std = @import(\"std\");\n");
41 try w.writeAll("const builtin = @import(\"builtin\");\n");41 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");
43 try w.writeAll("const string = []const u8;\n");43 try w.writeAll("const string = []const u8;\n");
44 try w.writeAll("\n");44 try w.writeAll("\n");
45 try w.writeAll(45 try w.writeAll(
...@@ -122,7 +122,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -122,7 +122,8 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
122 \\ const b = exe.builder;122 \\ const b = exe.builder;
123 \\ @setEvalBranchQuota(1_000_000);123 \\ @setEvalBranchQuota(1_000_000);
124 \\ for (packages) |pkg| {124 \\ for (packages) |pkg| {
125 \\ exe.addPackage(pkg.zp(b));125 \\ const moddep = pkg.zp(b);
126 \\ exe.addModule(moddep.name, moddep.module);
126 \\ }127 \\ }
127 \\ var llc = false;128 \\ var llc = false;
128 \\ var vcpkg = false;129 \\ var vcpkg = false;
...@@ -164,15 +165,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -164,15 +165,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
164 \\ frameworks: []const string = &.{},165 \\ frameworks: []const string = &.{},
165 \\ vcpkg: bool = false,166 \\ vcpkg: bool = false,
166 \\167 \\
167 \\ pub fn zp(self: *const Package, b: *std.build.Builder) Pkg {168 \\ pub fn zp(self: *const Package, b: *std.build.Builder) ModuleDependency {
168 \\ var temp: [100]Pkg = undefined;169 \\ var temp: [100]ModuleDependency = undefined;
169 \\ for (self.deps) |item, i| {170 \\ for (self.deps) |item, i| {
170 \\ temp[i] = item.zp(b);171 \\ temp[i] = item.zp(b);
171 \\ }172 \\ }
172 \\ return .{173 \\ return .{
173 \\ .name = self.name,174 \\ .name = self.name,
174 \\ .source = .{ .path = self.entry.? },175 \\ .module = b.createModule(.{
175 \\ .dependencies = b.allocator.dupe(Pkg, temp[0..self.deps.len]) catch @panic("oom"),176 \\ .source_file = .{ .path = self.entry.? },
177 \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"),
178 \\ }),
176 \\ };179 \\ };
177 \\ }180 \\ }
178 \\};181 \\};