authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-02 15:51:41 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-06-02 15:53:46 -07:00
log21683f9329aa22ed8a2d0e3cdff48a398521b65c
tree89f8b0910f0be90c8f0dd16132aea8c1a6d7d5bd
parent53130967cc11bb69e4eee56844ae6a6e8fbcdd74

upgrade to Zig 0.12.0


18 files changed, 286 insertions(+), 308 deletions(-)

.github/workflows/nightly.yml+1-1
...@@ -26,7 +26,7 @@ jobs:...@@ -26,7 +26,7 @@ jobs:
26 - name: Setup Zig26 - name: Setup Zig
27 uses: goto-bus-stop/setup-zig@v227 uses: goto-bus-stop/setup-zig@v2
28 with:28 with:
29 version: "0.11.0"29 version: "0.12.0"
3030
31 - run: zig version31 - run: zig version
32 - run: zig env32 - run: zig env
.github/workflows/push.yml+1-1
...@@ -19,7 +19,7 @@ jobs:...@@ -19,7 +19,7 @@ jobs:
19 - name: Setup Zig19 - name: Setup Zig
20 uses: goto-bus-stop/setup-zig@v220 uses: goto-bus-stop/setup-zig@v2
21 with:21 with:
22 version: "0.11.0"22 version: "0.12.0"
2323
24 - run: zig version24 - run: zig version
25 - run: zig env25 - run: zig env
README.md+1-1
...@@ -16,7 +16,7 @@ A package manager for the Zig programming language....@@ -16,7 +16,7 @@ A package manager for the Zig programming language.
16- https://github.com/nektro/zigmod/releases16- https://github.com/nektro/zigmod/releases
1717
18## Built With18## Built With
19- Zig master (at least `0.11.0`)19- Zig master (at least `0.12.0`)
20- See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock)20- See [`zig.mod`](./zig.mod) and [`zigmod.lock`](./zigmod.lock)
2121
22### Build from Source22### Build from Source
build.zig+10-5
...@@ -3,22 +3,27 @@ const string = []const u8;...@@ -3,22 +3,27 @@ const string = []const u8;
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const deps = @import("./deps.zig");4const deps = @import("./deps.zig");
55
6pub fn build(b: *std.build.Builder) void {6pub fn build(b: *std.Build) void {
7 const target = b.standardTargetOptions(.{});7 const target = b.standardTargetOptions(.{});
8 const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;8 const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;
9 const use_full_name = b.option(bool, "use-full-name", "") orelse false;9 const use_full_name = b.option(bool, "use-full-name", "") orelse false;
10 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) });10 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) });
11 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });11 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
12 const exe = b.addExecutable(.{ .name = exe_name, .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = mode });12 const exe = b.addExecutable(.{
13 .name = exe_name,
14 .root_source_file = .{ .path = "src/main.zig" },
15 .target = target,
16 .optimize = mode,
17 });
13 const tag = b.option(string, "tag", "") orelse "dev";18 const tag = b.option(string, "tag", "") orelse "dev";
14 const strip = b.option(bool, "strip", "Build without debug info.") orelse false;19 const strip = b.option(bool, "strip", "Build without debug info.") orelse false;
1520
16 const exe_options = b.addOptions();21 const exe_options = b.addOptions();
17 exe.addOptions("build_options", exe_options);22 exe.root_module.addImport("build_options", exe_options.createModule());
18 exe_options.addOption(string, "version", tag);23 exe_options.addOption(string, "version", tag);
1924
20 deps.addAllTo(exe);25 deps.addAllTo(exe);
21 exe.strip = strip;26 exe.root_module.strip = strip;
22 b.installArtifact(exe);27 b.installArtifact(exe);
2328
24 const run_cmd = b.addRunArtifact(exe);29 const run_cmd = b.addRunArtifact(exe);
deps.zig+106-105
...@@ -1,19 +1,18 @@...@@ -1,19 +1,18 @@
1// zig fmt: off1// zig fmt: off
2const std = @import("std");2const std = @import("std");
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const ModuleDependency = std.build.ModuleDependency;
5const string = []const u8;4const string = []const u8;
65
7pub const GitExactStep = struct {6pub const GitExactStep = struct {
8 step: std.build.Step,7 step: std.Build.Step,
9 builder: *std.build.Builder,8 builder: *std.Build,
10 url: string,9 url: string,
11 commit: string,10 commit: string,
1211
13 pub fn create(b: *std.build.Builder, url: string, commit: string) *GitExactStep {12 pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep {
14 var result = b.allocator.create(GitExactStep) catch @panic("memory");13 var result = b.allocator.create(GitExactStep) catch @panic("memory");
15 result.* = GitExactStep{14 result.* = GitExactStep{
16 .step = std.build.Step.init(.{15 .step = std.Build.Step.init(.{
17 .id = .custom,16 .id = .custom,
18 .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),17 .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),
19 .owner = b,18 .owner = b,
...@@ -30,11 +29,11 @@ pub const GitExactStep = struct {...@@ -30,11 +29,11 @@ pub const GitExactStep = struct {
30 const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });29 const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });
31 flip(std.fs.cwd().access(repopath, .{})) catch return result;30 flip(std.fs.cwd().access(repopath, .{})) catch return result;
3231
33 var clonestep = std.build.RunStep.create(b, "clone");32 var clonestep = std.Build.Step.Run.create(b, "clone");
34 clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });33 clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
35 result.step.dependOn(&clonestep.step);34 result.step.dependOn(&clonestep.step);
3635
37 var checkoutstep = std.build.RunStep.create(b, "checkout");36 var checkoutstep = std.Build.Step.Run.create(b, "checkout");
38 checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });37 checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
39 result.step.dependOn(&checkoutstep.step);38 result.step.dependOn(&checkoutstep.step);
40 checkoutstep.step.dependOn(&clonestep.step);39 checkoutstep.step.dependOn(&clonestep.step);
...@@ -42,35 +41,35 @@ pub const GitExactStep = struct {...@@ -42,35 +41,35 @@ pub const GitExactStep = struct {
42 return result;41 return result;
43 }42 }
4443
45 fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void {44 fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
46 _ = step;45 _ = step;
47 _ = prog_node;46 _ = prog_node;
48 }47 }
49};48};
5049
51pub fn fetch(exe: *std.build.LibExeObjStep) void {50pub fn fetch(exe: *std.Build.Step.Compile) void {
52 const b = exe.step.owner;51 const b = exe.step.owner;
53 inline for (comptime std.meta.declarations(package_data)) |decl| {52 inline for (comptime std.meta.declarations(package_data)) |decl| {
54 const path = &@field(package_data, decl.name).entry;53 const path = &@field(package_data, decl.name).entry;
55 const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";54 const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";
56 if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });55 if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });
57 }56 }
58 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "6777f1db221d0cb50322842f558f03e3c3a4099f").step);57 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "c778640d3dc153e900fbe37e2816b5176af3c802").step);
59 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "ddbe89bb0d9085e939bcbc713caeb2b7cf852bae").step);58 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "38a018ad3a19d5b4663a5364d2d31271f250846b").step);
60 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40").step);59 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "4dc8850883b49e4a452871298788b06b1af9fe24").step);
61 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "f51277414a2309f776fb79f3d55f26e37f9a54da").step);60 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "863be236188e5f24d16554f9dcd7df96dd254a13").step);
62 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "ac607e4e7ac36d46cc67c8786262578330543a36").step);61 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "c3e439f86b0484e4428f38c4d8b07b7b5ae1634b").step);
63 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step);62 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd").step);
64 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "05f0e90a185cb04a09b96f686dffc6375c420e9b").step);63 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "74f0ddb0a4dfa7921739b88cc381951a6b6e73ce").step);
65 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "5cc2a5565d04fe2c0085f0d6818590e800d9dcf7").step);64 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-inquirer", "9e1d873db79e9ffa6ae6e06bd372428c9be85d97").step);
66 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "550cabd5a18ace5e67761bc5b867c10e926f4314").step);65 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-leven", "e548b0bcc7b6f34f636c0b6b905928d31254c54d").step);
67 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "c9b8cbf3565675a056ad4e9b57cb4f84020e7680").step);66 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses", "f46d9f774df929885eef66c733a1e2a46bf16aec").step);
68 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "3c07c6e4eb0965dafd0b029c632f823631b3169c").step);67 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-licenses-text", "b01e5a2dffcc564bddd8f514fe64bab9b5c52572").step);
69 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step);68 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-range", "4b2f12808aa09be4b27a163efc424dd4e0415992").step);
70 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "12fad367a5282827aad7e12f0e9cd36f672c4010").step);69 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "ba546bbf2e8438c9b2325f36f392c9d95b432e8e").step);
71 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step);70 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "0d17fb99cba338aedc1abac12d78d5e5f04f0b6b").step);
72 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "92e6072d8a385d8b08fdcae3ae2021fe5293528f").step);71 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "a7f03a1e652abe8c89b376d090cec50acb0d2a1a").step);
73 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "855473062efac722624737f1adc56f9c0dd92017").step);72 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "0ad514dcfb7525e32ae349b9acc0a53976f3a9fa").step);
74 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);73 exe.step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step);
75}74}
7675
...@@ -86,48 +85,17 @@ fn flip(foo: anytype) !void {...@@ -86,48 +85,17 @@ fn flip(foo: anytype) !void {
86 return error.ExpectedError;85 return error.ExpectedError;
87}86}
8887
89pub fn addAllTo(exe: *std.build.LibExeObjStep) void {88pub fn addAllTo(exe: *std.Build.Step.Compile) void {
90 checkMinZig(builtin.zig_version, exe);89 checkMinZig(builtin.zig_version, exe);
91 fetch(exe);90 fetch(exe);
92 const b = exe.step.owner;
93 @setEvalBranchQuota(1_000_000);91 @setEvalBranchQuota(1_000_000);
94 for (packages) |pkg| {92 for (packages) |pkg| {
95 const moddep = pkg.zp(b);93 const module = pkg.module(exe);
96 exe.addModule(moddep.name, moddep.module);94 exe.root_module.addImport(pkg.name, module);
97 }
98 addAllLibrariesTo(exe);
99}
100
101pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void {
102 const b = exe.step.owner;
103 var llc = false;
104 var vcpkg = false;
105 inline for (comptime std.meta.declarations(package_data)) |decl| {
106 const pkg = @as(Package, @field(package_data, decl.name));
107 const root = if (pkg.store) |st| b.fmt("{s}/zigmod/deps/{s}", .{ b.cache_root.path.?, st }) else ".";
108 for (pkg.system_libs) |item| {
109 exe.linkSystemLibrary(item);
110 llc = true;
111 }
112 for (pkg.frameworks) |item| {
113 if (!builtin.target.isDarwin()) @panic(exe.step.owner.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item}));
114 exe.linkFramework(item);
115 llc = true;
116 }
117 for (pkg.c_include_dirs) |item| {
118 exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ root, item })});
119 llc = true;
120 }
121 for (pkg.c_source_files) |item| {
122 exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ root, item }) }, .flags = pkg.c_source_flags });
123 llc = true;
124 }
125 vcpkg = vcpkg or pkg.vcpkg;
126 }95 }
127 if (llc) exe.linkLibC();
128 if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err));
129}96}
13097
98var link_lib_c = false;
131pub const Package = struct {99pub const Package = struct {
132 name: string = "",100 name: string = "",
133 entry: ?string = null,101 entry: ?string = null,
...@@ -138,69 +106,102 @@ pub const Package = struct {...@@ -138,69 +106,102 @@ pub const Package = struct {
138 c_source_flags: []const string = &.{},106 c_source_flags: []const string = &.{},
139 system_libs: []const string = &.{},107 system_libs: []const string = &.{},
140 frameworks: []const string = &.{},108 frameworks: []const string = &.{},
141 vcpkg: bool = false,109 module_memo: ?*std.Build.Module = null,
142 module: ?ModuleDependency = null,
143110
144 pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency {111 pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
145 var temp: [100]ModuleDependency = undefined;112 if (self.module_memo) |cached| {
146 for (self.deps, 0..) |item, i| {113 return cached;
147 temp[i] = item.zp(b);
148 }114 }
149 if (self.module) |mod| {115 const b = exe.step.owner;
150 return mod;116
117 const result = b.createModule(.{});
118 const dummy_library = b.addStaticLibrary(.{
119 .name = "dummy",
120 .target = exe.root_module.resolved_target orelse b.host,
121 .optimize = exe.root_module.optimize.?,
122 });
123 if (self.entry) |capture| {
124 result.root_source_file = .{ .path = capture };
125 }
126 for (self.deps) |item| {
127 const module_dep = item.module(exe);
128 if (module_dep.root_source_file != null) {
129 result.addImport(item.name, module_dep);
130 }
131 for (module_dep.include_dirs.items) |jtem| {
132 switch (jtem) {
133 .path => result.addIncludePath(jtem.path),
134 .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {},
135 }
136 }
137 }
138 for (self.c_include_dirs) |item| {
139 result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
140 dummy_library.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
141 link_lib_c = true;
142 }
143 for (self.c_source_files) |item| {
144 dummy_library.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags });
145 }
146 for (self.system_libs) |item| {
147 dummy_library.linkSystemLibrary(item);
151 }148 }
152 const result = ModuleDependency{149 for (self.frameworks) |item| {
153 .name = self.name,150 dummy_library.linkFramework(item);
154 .module = b.createModule(.{151 }
155 .source_file = .{ .path = self.entry.? },152 if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) {
156 .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"),153 dummy_library.linkLibC();
157 }),154 exe.root_module.linkLibrary(dummy_library);
158 };155 link_lib_c = true;
159 self.module = result;156 }
157 if (link_lib_c) {
158 result.link_libc = true;
159 }
160 self.module_memo = result;
160 return result;161 return result;
161 }162 }
162};163};
163164
164fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {165fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {
165 const min = std.SemanticVersion.parse("0.11.0") catch return;166 const min = std.SemanticVersion.parse("0.12.0") catch return;
166 if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min}));167 if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{current, min}));
167}168}
168169
169pub const package_data = struct {170pub const package_data = struct {
170 pub var _o6ogpor87xc2 = Package{171 pub var _o6ogpor87xc2 = Package{
171 .store = "/git/github.com/marlersoft/zigwin32/6777f1db221d0cb50322842f558f03e3c3a4099f",172 .store = "/git/github.com/marlersoft/zigwin32/c778640d3dc153e900fbe37e2816b5176af3c802",
172 .name = "win32",173 .name = "win32",
173 .entry = "/git/github.com/marlersoft/zigwin32/6777f1db221d0cb50322842f558f03e3c3a4099f/win32.zig",174 .entry = "/git/github.com/marlersoft/zigwin32/c778640d3dc153e900fbe37e2816b5176af3c802/win32.zig",
174 };175 };
175 pub var _u7sysdckdymi = Package{176 pub var _u7sysdckdymi = Package{
176 .store = "/git/github.com/nektro/arqv-ini/ddbe89bb0d9085e939bcbc713caeb2b7cf852bae",177 .store = "/git/github.com/nektro/arqv-ini/38a018ad3a19d5b4663a5364d2d31271f250846b",
177 .name = "ini",178 .name = "ini",
178 .entry = "/git/github.com/nektro/arqv-ini/ddbe89bb0d9085e939bcbc713caeb2b7cf852bae/src/ini.zig",179 .entry = "/git/github.com/nektro/arqv-ini/38a018ad3a19d5b4663a5364d2d31271f250846b/src/ini.zig",
179 };180 };
180 pub var _csbnipaad8n7 = Package{181 pub var _csbnipaad8n7 = Package{
181 .store = "/git/github.com/nektro/iguanaTLS/f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40",182 .store = "/git/github.com/nektro/iguanaTLS/4dc8850883b49e4a452871298788b06b1af9fe24",
182 .name = "iguanaTLS",183 .name = "iguanaTLS",
183 .entry = "/git/github.com/nektro/iguanaTLS/f5c7c3fe880c5a23fbcdc21dfcb83c2776931f40/src/main.zig",184 .entry = "/git/github.com/nektro/iguanaTLS/4dc8850883b49e4a452871298788b06b1af9fe24/src/main.zig",
184 };185 };
185 pub var _s84v9o48ucb0 = Package{186 pub var _s84v9o48ucb0 = Package{
186 .store = "/git/github.com/nektro/zig-ansi/ac607e4e7ac36d46cc67c8786262578330543a36",187 .store = "/git/github.com/nektro/zig-ansi/c3e439f86b0484e4428f38c4d8b07b7b5ae1634b",
187 .name = "ansi",188 .name = "ansi",
188 .entry = "/git/github.com/nektro/zig-ansi/ac607e4e7ac36d46cc67c8786262578330543a36/src/lib.zig",189 .entry = "/git/github.com/nektro/zig-ansi/c3e439f86b0484e4428f38c4d8b07b7b5ae1634b/src/lib.zig",
189 };190 };
190 pub var _f7dubzb7cyqe = Package{191 pub var _f7dubzb7cyqe = Package{
191 .store = "/git/github.com/nektro/zig-extras/05f0e90a185cb04a09b96f686dffc6375c420e9b",192 .store = "/git/github.com/nektro/zig-extras/74f0ddb0a4dfa7921739b88cc381951a6b6e73ce",
192 .name = "extras",193 .name = "extras",
193 .entry = "/git/github.com/nektro/zig-extras/05f0e90a185cb04a09b96f686dffc6375c420e9b/src/lib.zig",194 .entry = "/git/github.com/nektro/zig-extras/74f0ddb0a4dfa7921739b88cc381951a6b6e73ce/src/lib.zig",
194 };195 };
195 pub var _0npcrzfdlrvk = Package{196 pub var _0npcrzfdlrvk = Package{
196 .store = "/git/github.com/nektro/zig-licenses/c9b8cbf3565675a056ad4e9b57cb4f84020e7680",197 .store = "/git/github.com/nektro/zig-licenses/f46d9f774df929885eef66c733a1e2a46bf16aec",
197 .name = "licenses",198 .name = "licenses",
198 .entry = "/git/github.com/nektro/zig-licenses/c9b8cbf3565675a056ad4e9b57cb4f84020e7680/src/lib.zig",199 .entry = "/git/github.com/nektro/zig-licenses/f46d9f774df929885eef66c733a1e2a46bf16aec/src/lib.zig",
199 };200 };
200 pub var _pt88y5d80m25 = Package{201 pub var _pt88y5d80m25 = Package{
201 .store = "/git/github.com/nektro/zig-licenses-text/3c07c6e4eb0965dafd0b029c632f823631b3169c",202 .store = "/git/github.com/nektro/zig-licenses-text/b01e5a2dffcc564bddd8f514fe64bab9b5c52572",
202 .name = "licenses-text",203 .name = "licenses-text",
203 .entry = "/git/github.com/nektro/zig-licenses-text/3c07c6e4eb0965dafd0b029c632f823631b3169c/src/lib.zig",204 .entry = "/git/github.com/nektro/zig-licenses-text/b01e5a2dffcc564bddd8f514fe64bab9b5c52572/src/lib.zig",
204 };205 };
205 pub var _tnj3qf44tpeq = Package{206 pub var _tnj3qf44tpeq = Package{
206 .store = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992",207 .store = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992",
...@@ -208,15 +209,15 @@ pub const package_data = struct {...@@ -208,15 +209,15 @@ pub const package_data = struct {
208 .entry = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992/src/lib.zig",209 .entry = "/git/github.com/nektro/zig-range/4b2f12808aa09be4b27a163efc424dd4e0415992/src/lib.zig",
209 };210 };
210 pub var _c1xirp1ota5p = Package{211 pub var _c1xirp1ota5p = Package{
211 .store = "/git/github.com/nektro/zig-inquirer/5cc2a5565d04fe2c0085f0d6818590e800d9dcf7",212 .store = "/git/github.com/nektro/zig-inquirer/9e1d873db79e9ffa6ae6e06bd372428c9be85d97",
212 .name = "inquirer",213 .name = "inquirer",
213 .entry = "/git/github.com/nektro/zig-inquirer/5cc2a5565d04fe2c0085f0d6818590e800d9dcf7/src/lib.zig",214 .entry = "/git/github.com/nektro/zig-inquirer/9e1d873db79e9ffa6ae6e06bd372428c9be85d97/src/lib.zig",
214 .deps = &[_]*Package{ &_s84v9o48ucb0, &_tnj3qf44tpeq },215 .deps = &[_]*Package{ &_s84v9o48ucb0, &_tnj3qf44tpeq },
215 };216 };
216 pub var _96h80ezrvj7i = Package{217 pub var _96h80ezrvj7i = Package{
217 .store = "/git/github.com/nektro/zig-leven/550cabd5a18ace5e67761bc5b867c10e926f4314",218 .store = "/git/github.com/nektro/zig-leven/e548b0bcc7b6f34f636c0b6b905928d31254c54d",
218 .name = "leven",219 .name = "leven",
219 .entry = "/git/github.com/nektro/zig-leven/550cabd5a18ace5e67761bc5b867c10e926f4314/src/lib.zig",220 .entry = "/git/github.com/nektro/zig-leven/e548b0bcc7b6f34f636c0b6b905928d31254c54d/src/lib.zig",
220 .deps = &[_]*Package{ &_tnj3qf44tpeq },221 .deps = &[_]*Package{ &_tnj3qf44tpeq },
221 };222 };
222 pub var _2ovav391ivak = Package{223 pub var _2ovav391ivak = Package{
...@@ -226,32 +227,32 @@ pub const package_data = struct {...@@ -226,32 +227,32 @@ pub const package_data = struct {
226 .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i },227 .deps = &[_]*Package{ &_pt88y5d80m25, &_96h80ezrvj7i },
227 };228 };
228 pub var _iecwp4b3bsfm = Package{229 pub var _iecwp4b3bsfm = Package{
229 .store = "/git/github.com/nektro/zig-time/12fad367a5282827aad7e12f0e9cd36f672c4010",230 .store = "/git/github.com/nektro/zig-time/ba546bbf2e8438c9b2325f36f392c9d95b432e8e",
230 .name = "time",231 .name = "time",
231 .entry = "/git/github.com/nektro/zig-time/12fad367a5282827aad7e12f0e9cd36f672c4010/time.zig",232 .entry = "/git/github.com/nektro/zig-time/ba546bbf2e8438c9b2325f36f392c9d95b432e8e/time.zig",
232 .deps = &[_]*Package{ &_f7dubzb7cyqe },233 .deps = &[_]*Package{ &_f7dubzb7cyqe },
233 };234 };
234 pub var _g982zq6e8wsv = Package{235 pub var _g982zq6e8wsv = Package{
235 .store = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b",236 .store = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b",
236 .name = "yaml",237 .name = "yaml",
237 .entry = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b/yaml.zig",238 .entry = "/git/github.com/nektro/zig-yaml/0d17fb99cba338aedc1abac12d78d5e5f04f0b6b/yaml.zig",
238 .deps = &[_]*Package{ &_f7dubzb7cyqe },239 .deps = &[_]*Package{ &_8mdbh0zuneb0, &_f7dubzb7cyqe },
239 };240 };
240 pub var _9k24gimke1an = Package{241 pub var _9k24gimke1an = Package{
241 .store = "/git/github.com/truemedian/hzzp/92e6072d8a385d8b08fdcae3ae2021fe5293528f",242 .store = "/git/github.com/truemedian/hzzp/a7f03a1e652abe8c89b376d090cec50acb0d2a1a",
242 .name = "hzzp",243 .name = "hzzp",
243 .entry = "/git/github.com/truemedian/hzzp/92e6072d8a385d8b08fdcae3ae2021fe5293528f/src/main.zig",244 .entry = "/git/github.com/truemedian/hzzp/a7f03a1e652abe8c89b376d090cec50acb0d2a1a/src/main.zig",
244 };245 };
245 pub var _ejw82j2ipa0e = Package{246 pub var _ejw82j2ipa0e = Package{
246 .store = "/git/github.com/nektro/zfetch/f51277414a2309f776fb79f3d55f26e37f9a54da",247 .store = "/git/github.com/nektro/zfetch/863be236188e5f24d16554f9dcd7df96dd254a13",
247 .name = "zfetch",248 .name = "zfetch",
248 .entry = "/git/github.com/nektro/zfetch/f51277414a2309f776fb79f3d55f26e37f9a54da/src/main.zig",249 .entry = "/git/github.com/nektro/zfetch/863be236188e5f24d16554f9dcd7df96dd254a13/src/main.zig",
249 .deps = &[_]*Package{ &_9k24gimke1an, &_csbnipaad8n7 },250 .deps = &[_]*Package{ &_9k24gimke1an, &_csbnipaad8n7 },
250 };251 };
251 pub var _2ta738wrqbaq = Package{252 pub var _2ta738wrqbaq = Package{
252 .store = "/git/github.com/ziglibs/known-folders/855473062efac722624737f1adc56f9c0dd92017",253 .store = "/git/github.com/ziglibs/known-folders/0ad514dcfb7525e32ae349b9acc0a53976f3a9fa",
253 .name = "known-folders",254 .name = "known-folders",
254 .entry = "/git/github.com/ziglibs/known-folders/855473062efac722624737f1adc56f9c0dd92017/known-folders.zig",255 .entry = "/git/github.com/ziglibs/known-folders/0ad514dcfb7525e32ae349b9acc0a53976f3a9fa/known-folders.zig",
255 };256 };
256 pub var _89ujp8gq842x = Package{257 pub var _89ujp8gq842x = Package{
257 .name = "zigmod",258 .name = "zigmod",
docs/README.md+1-1
...@@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed....@@ -10,7 +10,7 @@ The rest of this documentation will assume you already have Zig installed.
1010
11As Zig is still in development itself, if you plan to contribute to Zigmod you will need a master download of Zig. Those can be obtained from https://ziglang.org/download/#release-master.11As Zig is still in development itself, if you plan to contribute to Zigmod you will need a master download of Zig. Those can be obtained from https://ziglang.org/download/#release-master.
1212
13The earliest Zig release this Zigmod was verified to work with is `0.11.0`.13The earliest Zig release this Zigmod was verified to work with is `0.12.0`.
1414
15## Download15## Download
16You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source.16You may download a precompiled binary from https://github.com/nektro/zigmod/releases or build the project from source.
docs/deps.zig.md+1-6
...@@ -15,10 +15,6 @@ A helper function to automatically pull in dependencies, purely from the `zig bu...@@ -15,10 +15,6 @@ A helper function to automatically pull in dependencies, purely from the `zig bu
15- Type: `pub fn (exe: *std.build.LibExeObjStep) void`15- Type: `pub fn (exe: *std.build.LibExeObjStep) void`
16A helper function to add all of the packages, C files, and system libraries to the passed exectuable. It will also automatically link libC in the event that any C files are found in the dependency tree.16A helper function to add all of the packages, C files, and system libraries to the passed exectuable. It will also automatically link libC in the event that any C files are found in the dependency tree.
1717
18### `addAllLibrariesTo`
19- Type: `pub fn (exe: *std.build.LibExeObjStep) void`
20A helper function called by `addAllTo` that adds the C files and libraries.
21
22### `Package`18### `Package`
23```zig19```zig
24pub const Package = struct {20pub const Package = struct {
...@@ -29,7 +25,6 @@ pub const Package = struct {...@@ -29,7 +25,6 @@ pub const Package = struct {
29 c_source_flags: []const string = &.{},25 c_source_flags: []const string = &.{},
30 system_libs: []const string = &.{},26 system_libs: []const string = &.{},
31 frameworks: []const string = &.{},27 frameworks: []const string = &.{},
32 vcpkg: bool = false,
33};28};
34```29```
3530
...@@ -43,7 +38,7 @@ This is a an array of all of the items in `package_data`, but only contains the...@@ -43,7 +38,7 @@ This is a an array of all of the items in `package_data`, but only contains the
4338
44### `pkgs`39### `pkgs`
45- Type: `struct<NAME, Package>`40- Type: `struct<NAME, Package>`
46This is a struct that associates the package name to the relavant `Package`. The only packages listed are the dependencies of the root project. 41This is a struct that associates the package name to the relavant `Package`. The only packages listed are the dependencies of the root project.
4742
48### `imports`43### `imports`
49- Type: `struct<NAME, @import(main)>`44- Type: `struct<NAME, @import(main)>`
docs/zig.mod.md-10
...@@ -58,11 +58,6 @@ Similar to `dependencies` but will only get added to the project if the current...@@ -58,11 +58,6 @@ Similar to `dependencies` but will only get added to the project if the current
58- Type: `string`58- Type: `string`
59Parsed 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.59Parsed 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.
6060
61#### `vcpkg`
62- Type: `bool`
63- Example: `true`|any
64This 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.
65
66----61----
6762
68### Dep Object63### Dep Object
...@@ -124,10 +119,5 @@ This attribute specifies a way to filter when the dependency will be generated i...@@ -124,10 +119,5 @@ This attribute specifies a way to filter when the dependency will be generated i
124- Example: `true`|any119- Example: `true`|any
125This attribute is a manual override for having an external repo that contains no Zig or C code but other files be managed through Zigmod and `deps.zig`. `true` is the only value that will enable this flag.120This attribute is a manual override for having an external repo that contains no Zig or C code but other files be managed through Zigmod and `deps.zig`. `true` is the only value that will enable this flag.
126121
127#### Dep `vcpkg`
128- Type: `string`
129- Example: `true`|any
130This 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.
131
132#### Dep Overrides122#### Dep Overrides
133There are a number of fields you can add to a `Dep` object that will override it's top-level value. This is most useful in the case where a project you want to use does not have a `zigmod.yml` manifest. You can then use overrides to define the values for them. The only top-level value you can not override is `dependencies`.123There are a number of fields you can add to a `Dep` object that will override it's top-level value. This is most useful in the case where a project you want to use does not have a `zigmod.yml` manifest. You can then use overrides to define the values for them. The only top-level value you can not override is `dependencies`.
src/cmd/fetch.zig+73-77
...@@ -52,94 +52,89 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -52,94 +52,89 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
52 try w.writeAll("const std = @import(\"std\");\n");52 try w.writeAll("const std = @import(\"std\");\n");
53 try w.writeAll("const builtin = @import(\"builtin\");\n");53 try w.writeAll("const builtin = @import(\"builtin\");\n");
54 try w.writeAll("const string = []const u8;\n");54 try w.writeAll("const string = []const u8;\n");
55 try w.writeAll("const ModuleDependency = std.build.ModuleDependency;\n");
56 try w.writeAll("\n");55 try w.writeAll("\n");
57 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});56 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
58 try w.writeAll("\n");57 try w.writeAll("\n");
59 try w.writeAll(58 try w.writeAll(
60 \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void {59 \\pub fn addAllTo(exe: *std.Build.Step.Compile) void {
61 \\ checkMinZig(builtin.zig_version, exe);60 \\ checkMinZig(builtin.zig_version, exe);
62 \\ const b = exe.step.owner;
63 \\ @setEvalBranchQuota(1_000_000);61 \\ @setEvalBranchQuota(1_000_000);
64 \\ for (packages) |pkg| {62 \\ for (packages) |pkg| {
65 \\ const moddep = pkg.zp(b);63 \\ const module = pkg.module(exe);
66 \\ exe.addModule(moddep.name, moddep.module);64 \\ exe.root_module.addImport(pkg.import.?[0], module);
67 \\ }65 \\ }
68 \\ addAllLibrariesTo(exe);
69 \\}
70 \\
71 \\pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void {
72 \\ const b = exe.step.owner;
73 \\ var llc = false;
74 \\ var vcpkg = false;
75 \\ inline for (comptime std.meta.declarations(package_data)) |decl| {
76 \\ const pkg = @as(Package, @field(package_data, decl.name));
77 \\ for (pkg.system_libs) |item| {
78 \\ exe.linkSystemLibrary(item);
79 \\ llc = true;
80 \\ }
81 \\ for (pkg.frameworks) |item| {
82 \\ if (!builtin.target.isDarwin()) @panic(b.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item}));
83 \\ exe.linkFramework(item);
84 \\ llc = true;
85 \\ }
86 \\ for (pkg.c_include_dirs) |item| {
87 \\ exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ @field(dirs, decl.name), item })});
88 \\ llc = true;
89 \\ }
90 \\ for (pkg.c_source_files) |item| {
91 \\ exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ @field(dirs, decl.name), item }) }, .flags = pkg.c_source_flags });
92 \\ llc = true;
93 \\ }
94 \\ vcpkg = vcpkg or pkg.vcpkg;
95 \\ }
96 \\ if (llc) exe.linkLibC();
97 \\ if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err));
98 \\}66 \\}
99 \\67 \\
68 \\var link_lib_c = false;
100 \\pub const Package = struct {69 \\pub const Package = struct {
101 \\ directory: string,70 \\ directory: string,
102 \\ pkg: ?Pkg = null,71 \\ import: ?struct { string, std.Build.LazyPath } = null,
72 \\ dependencies: []const *Package,
103 \\ c_include_dirs: []const string = &.{},73 \\ c_include_dirs: []const string = &.{},
104 \\ c_source_files: []const string = &.{},74 \\ c_source_files: []const string = &.{},
105 \\ c_source_flags: []const string = &.{},75 \\ c_source_flags: []const string = &.{},
106 \\ system_libs: []const string = &.{},76 \\ system_libs: []const string = &.{},
107 \\ frameworks: []const string = &.{},77 \\ frameworks: []const string = &.{},
108 \\ vcpkg: bool = false,78 \\ module_memo: ?*std.Build.Module = null,
109 \\ module: ?ModuleDependency = null,
110 \\79 \\
111 \\ pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency {80 \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
112 \\ var temp: [100]ModuleDependency = undefined;81 \\ if (self.module_memo) |cached| {
113 \\ const pkg = self.pkg.?;82 \\ return cached;
114 \\ for (pkg.dependencies, 0..) |item, i| {83 \\ }
115 \\ temp[i] = item.zp(b);84 \\ const b = exe.step.owner;
85 \\ const result = b.createModule(.{});
86 \\ const dummy_library = b.addStaticLibrary(.{
87 \\ .name = "dummy",
88 \\ .target = exe.root_module.resolved_target orelse b.host,
89 \\ .optimize = exe.root_module.optimize.?,
90 \\ });
91 \\ if (self.import) |capture| {
92 \\ result.root_source_file = capture[1];
93 \\ }
94 \\ for (self.dependencies) |item| {
95 \\ const module_dep = item.module(exe);
96 \\ if (module_dep.root_source_file != null) {
97 \\ result.addImport(item.import.?[0], module_dep);
98 \\ }
99 \\ for (module_dep.include_dirs.items) |jtem| {
100 \\ switch (jtem) {
101 \\ .path => result.addIncludePath(jtem.path),
102 \\ .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {},
103 \\ }
104 \\ }
105 \\ }
106 \\ for (self.c_include_dirs) |item| {
107 \\ result.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item })));
108 \\ dummy_library.addIncludePath(b.path(b.fmt("{s}/{s}", .{ self.directory, item })));
109 \\ link_lib_c = true;
110 \\ }
111 \\ for (self.c_source_files) |item| {
112 \\ dummy_library.addCSourceFile(.{ .file = b.path(b.fmt("{s}/{s}", .{ self.directory, item })), .flags = self.c_source_flags });
116 \\ }113 \\ }
117 \\ if (self.module) |mod| {114 \\ for (self.system_libs) |item| {
118 \\ return mod;115 \\ dummy_library.linkSystemLibrary(item);
119 \\ }116 \\ }
120 \\ const result = ModuleDependency{117 \\ for (self.frameworks) |item| {
121 \\ .name = pkg.name,118 \\ dummy_library.linkFramework(item);
122 \\ .module = b.createModule(.{119 \\ }
123 \\ .source_file = pkg.source,120 \\ if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) {
124 \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..pkg.dependencies.len]) catch @panic("oom"),121 \\ dummy_library.linkLibC();
125 \\ }),122 \\ exe.root_module.linkLibrary(dummy_library);
126 \\ };123 \\ link_lib_c = true;
127 \\ self.module = result;124 \\ }
125 \\ if (link_lib_c) {
126 \\ result.link_libc = true;
127 \\ }
128 \\ self.module_memo = result;
128 \\ return result;129 \\ return result;
129 \\ }130 \\ }
130 \\};131 \\};
131 \\132 \\
132 \\pub const Pkg = struct {
133 \\ name: string,
134 \\ source: std.build.FileSource,
135 \\ dependencies: []const *Package,
136 \\};
137 \\
138 \\133 \\
139 );134 );
140135
141 try w.print(136 try w.print(
142 \\fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {{137 \\fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {{
143 \\ const min = std.SemanticVersion.parse("{?}") catch return;138 \\ const min = std.SemanticVersion.parse("{?}") catch return;
144 \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}}));139 \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}}));
145 \\}}140 \\}}
...@@ -148,7 +143,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -148,7 +143,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
148 , .{top_module.minZigVersion()});143 , .{top_module.minZigVersion()});
149144
150 try w.writeAll("pub const dirs = struct {\n");145 try w.writeAll("pub const dirs = struct {\n");
151 try print_dirs(w, list.items);146 try print_dirs(w, list.items, alloc);
152 try w.writeAll("};\n\n");147 try w.writeAll("};\n\n");
153148
154 try w.writeAll("pub const package_data = struct {\n");149 try w.writeAll("pub const package_data = struct {\n");
...@@ -215,7 +210,7 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void {...@@ -215,7 +210,7 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void {
215 while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| {210 while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| {
216 if (line[0] == ' ') continue;211 if (line[0] == ' ') continue;
217 if (line[0] == '-') try rems.append(line[1..]);212 if (line[0] == '-') try rems.append(line[1..]);
218 if (line[0] == '+') if (line[1] == '2') continue else try adds.append(line[1..]);213 if (line[0] == '+') if (line[1] == '2') break else try adds.append(line[1..]);
219 }214 }
220215
221 var changes = std.StringHashMap(DiffChange).init(alloc);216 var changes = std.StringHashMap(DiffChange).init(alloc);
...@@ -287,13 +282,18 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item:...@@ -287,13 +282,18 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item:
287 return false;282 return false;
288}283}
289284
290fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void {285fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module, alloc: std.mem.Allocator) !void {
291 for (list) |mod| {286 for (list) |mod| {
292 if (mod.type == .system_lib or mod.type == .framework) continue;287 if (mod.type == .system_lib or mod.type == .framework) continue;
293 if (std.mem.eql(u8, mod.id, "root")) {288 if (std.mem.eql(u8, mod.id, "root")) {
294 try w.writeAll(" pub const _root = \"\";\n");289 try w.writeAll(" pub const _root = \"\";\n");
295 continue;290 continue;
296 }291 }
292 if (std.mem.eql(u8, mod.clean_path, "../..")) {
293 const cwd_realpath = try std.fs.cwd().realpathAlloc(alloc, ".");
294 try w.print(" pub const _{s} = \"{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(cwd_realpath) });
295 continue;
296 }
297 try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) });297 try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) });
298 }298 }
299}299}
...@@ -327,23 +327,22 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul...@@ -327,23 +327,22 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
327 });327 });
328 if (mod.main.len > 0 and !std.mem.eql(u8, mod.id, "root")) {328 if (mod.main.len > 0 and !std.mem.eql(u8, mod.id, "root")) {
329 try w.print(329 try w.print(
330 \\ .pkg = Pkg{{ .name = "{s}", .source = .{{ .path = dirs._{s} ++ "/{s}" }}, .dependencies =330 \\ .import = .{{ "{s}", .{{ .path = dirs._{s} ++ "/{s}" }} }},
331 \\
331 , .{332 , .{
332 mod.name,333 mod.name,
333 mod.short_id(),334 mod.short_id(),
334 mod.main,335 mod.main,
335 });336 });
336 if (mod.has_no_zig_deps()) {337 }
337 try w.writeAll(" &.{} },\n");338 {
338 } else {339 try w.writeAll(" .dependencies =");
339 try w.writeAll(" &.{");340 try w.writeAll(" &.{");
340 for (mod.deps, 0..) |moddep, j| {341 for (mod.deps, 0..) |moddep, j| {
341 if (moddep.main.len == 0) continue;342 try w.print(" &_{s}", .{moddep.id[0..12]});
342 try w.print(" &_{s}", .{moddep.id[0..12]});343 if (j != mod.deps.len - 1) try w.writeAll(",");
343 if (j != mod.deps.len - 1) try w.writeAll(",");
344 }
345 try w.writeAll(" } },\n");
346 }344 }
345 try w.writeAll(" },\n");
347 }346 }
348 if (mod.c_include_dirs.len > 0) {347 if (mod.c_include_dirs.len > 0) {
349 try w.writeAll(" .c_include_dirs = &.{");348 try w.writeAll(" .c_include_dirs = &.{");
...@@ -387,9 +386,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul...@@ -387,9 +386,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
387 }386 }
388 try w.writeAll(" },\n");387 try w.writeAll(" },\n");
389 }388 }
390 if (mod.vcpkg) {
391 try w.writeAll(" .vcpkg = true,\n");
392 }
393 try w.writeAll(" };\n");389 try w.writeAll(" };\n");
394390
395 try done.append(mod);391 try done.append(mod);
src/cmd/generate.zig+67-70
...@@ -41,20 +41,19 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -41,20 +41,19 @@ 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 ModuleDependency = std.build.ModuleDependency;\n");
45 try w.writeAll("const string = []const u8;\n");44 try w.writeAll("const string = []const u8;\n");
46 try w.writeAll("\n");45 try w.writeAll("\n");
47 try w.writeAll(46 try w.writeAll(
48 \\pub const GitExactStep = struct {47 \\pub const GitExactStep = struct {
49 \\ step: std.build.Step,48 \\ step: std.Build.Step,
50 \\ builder: *std.build.Builder,49 \\ builder: *std.Build,
51 \\ url: string,50 \\ url: string,
52 \\ commit: string,51 \\ commit: string,
53 \\52 \\
54 \\ pub fn create(b: *std.build.Builder, url: string, commit: string) *GitExactStep {53 \\ pub fn create(b: *std.Build, url: string, commit: string) *GitExactStep {
55 \\ var result = b.allocator.create(GitExactStep) catch @panic("memory");54 \\ var result = b.allocator.create(GitExactStep) catch @panic("memory");
56 \\ result.* = GitExactStep{55 \\ result.* = GitExactStep{
57 \\ .step = std.build.Step.init(.{56 \\ .step = std.Build.Step.init(.{
58 \\ .id = .custom,57 \\ .id = .custom,
59 \\ .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),58 \\ .name = b.fmt("git clone {s} @ {s}", .{ url, commit }),
60 \\ .owner = b,59 \\ .owner = b,
...@@ -71,11 +70,11 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -71,11 +70,11 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
71 \\ const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });70 \\ const repopath = b.fmt("{s}/zigmod/deps/git/{s}/{s}", .{ b.cache_root.path.?, urlpath, commit });
72 \\ flip(std.fs.cwd().access(repopath, .{})) catch return result;71 \\ flip(std.fs.cwd().access(repopath, .{})) catch return result;
73 \\72 \\
74 \\ var clonestep = std.build.RunStep.create(b, "clone");73 \\ var clonestep = std.Build.Step.Run.create(b, "clone");
75 \\ clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });74 \\ clonestep.addArgs(&.{ "git", "clone", "-q", "--progress", url, repopath });
76 \\ result.step.dependOn(&clonestep.step);75 \\ result.step.dependOn(&clonestep.step);
77 \\76 \\
78 \\ var checkoutstep = std.build.RunStep.create(b, "checkout");77 \\ var checkoutstep = std.Build.Step.Run.create(b, "checkout");
79 \\ checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });78 \\ checkoutstep.addArgs(&.{ "git", "-C", repopath, "checkout", "-q", commit });
80 \\ result.step.dependOn(&checkoutstep.step);79 \\ result.step.dependOn(&checkoutstep.step);
81 \\ checkoutstep.step.dependOn(&clonestep.step);80 \\ checkoutstep.step.dependOn(&clonestep.step);
...@@ -85,18 +84,18 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -85,18 +84,18 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
85 \\ return result;84 \\ return result;
86 \\ }85 \\ }
87 \\86 \\
88 \\ fn make(step: *std.build.Step, prog_node: *std.Progress.Node) !void {87 \\ fn make(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
89 \\ _ = step;88 \\ _ = step;
90 \\ _ = prog_node;89 \\ _ = prog_node;
91 \\ }90 \\ }
92 \\};91 \\};
93 \\92 \\
94 \\pub fn fetch(exe: *std.build.LibExeObjStep) void {93 \\pub fn fetch(exe: *std.Build.Step.Compile) void {
95 \\ const b = exe.step.owner;94 \\ const b = exe.step.owner;
96 \\ inline for (comptime std.meta.declarations(package_data)) |decl| {95 \\ inline for (comptime std.meta.declarations(package_data)) |decl| {
97 \\ const path = &@field(package_data, decl.name).entry;96 \\ const path = &@field(package_data, decl.name).entry;
98 \\ const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";97 \\ const root = if (@field(package_data, decl.name).store) |_| b.cache_root.path.? else ".";
99 \\ if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });98 \\ if (path.* != null) path.* = b.fmt("{s}/zigmod/deps{s}", .{ root, path.*.? });
100 \\ }99 \\ }
101 \\100 \\
102 );101 );
...@@ -125,48 +124,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -125,48 +124,17 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
125 \\ return error.ExpectedError;124 \\ return error.ExpectedError;
126 \\}125 \\}
127 \\126 \\
128 \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void {127 \\pub fn addAllTo(exe: *std.Build.Step.Compile) void {
129 \\ checkMinZig(builtin.zig_version, exe);128 \\ checkMinZig(builtin.zig_version, exe);
130 \\ fetch(exe);129 \\ fetch(exe);
131 \\ const b = exe.step.owner;
132 \\ @setEvalBranchQuota(1_000_000);130 \\ @setEvalBranchQuota(1_000_000);
133 \\ for (packages) |pkg| {131 \\ for (packages) |pkg| {
134 \\ const moddep = pkg.zp(b);132 \\ const module = pkg.module(exe);
135 \\ exe.addModule(moddep.name, moddep.module);133 \\ exe.root_module.addImport(pkg.name, module);
136 \\ }
137 \\ addAllLibrariesTo(exe);
138 \\}
139 \\
140 \\pub fn addAllLibrariesTo(exe: *std.build.LibExeObjStep) void {
141 \\ const b = exe.step.owner;
142 \\ var llc = false;
143 \\ var vcpkg = false;
144 \\ inline for (comptime std.meta.declarations(package_data)) |decl| {
145 \\ const pkg = @as(Package, @field(package_data, decl.name));
146 \\ const root = if (pkg.store) |st| b.fmt("{s}/zigmod/deps/{s}", .{ b.cache_root.path.?, st }) else ".";
147 \\ for (pkg.system_libs) |item| {
148 \\ exe.linkSystemLibrary(item);
149 \\ llc = true;
150 \\ }
151 \\ for (pkg.frameworks) |item| {
152 \\ if (!builtin.target.isDarwin()) @panic(exe.step.owner.fmt("a dependency is attempting to link to the framework {s}, which is only possible under Darwin", .{item}));
153 \\ exe.linkFramework(item);
154 \\ llc = true;
155 \\ }
156 \\ for (pkg.c_include_dirs) |item| {
157 \\ exe.addIncludePath(.{.path = b.fmt("{s}/{s}", .{ root, item })});
158 \\ llc = true;
159 \\ }
160 \\ for (pkg.c_source_files) |item| {
161 \\ exe.addCSourceFile(.{ .file = .{ .path = b.fmt("{s}/{s}", .{ root, item }) }, .flags = pkg.c_source_flags });
162 \\ llc = true;
163 \\ }
164 \\ vcpkg = vcpkg or pkg.vcpkg;
165 \\ }134 \\ }
166 \\ if (llc) exe.linkLibC();
167 \\ if (builtin.os.tag == .windows and vcpkg) exe.addVcpkgPaths(.static) catch |err| @panic(@errorName(err));
168 \\}135 \\}
169 \\136 \\
137 \\var link_lib_c = false;
170 \\pub const Package = struct {138 \\pub const Package = struct {
171 \\ name: string = "",139 \\ name: string = "",
172 \\ entry: ?string = null,140 \\ entry: ?string = null,
...@@ -177,25 +145,58 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -177,25 +145,58 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
177 \\ c_source_flags: []const string = &.{},145 \\ c_source_flags: []const string = &.{},
178 \\ system_libs: []const string = &.{},146 \\ system_libs: []const string = &.{},
179 \\ frameworks: []const string = &.{},147 \\ frameworks: []const string = &.{},
180 \\ vcpkg: bool = false,148 \\ module_memo: ?*std.Build.Module = null,
181 \\ module: ?ModuleDependency = null,
182 \\149 \\
183 \\ pub fn zp(self: *Package, b: *std.build.Builder) ModuleDependency {150 \\ pub fn module(self: *Package, exe: *std.Build.Step.Compile) *std.Build.Module {
184 \\ var temp: [100]ModuleDependency = undefined;151 \\ if (self.module_memo) |cached| {
185 \\ for (self.deps, 0..) |item, i| {152 \\ return cached;
186 \\ temp[i] = item.zp(b);
187 \\ }153 \\ }
188 \\ if (self.module) |mod| {154 \\ const b = exe.step.owner;
189 \\ return mod;155 \\
156 \\ const result = b.createModule(.{});
157 \\ const dummy_library = b.addStaticLibrary(.{
158 \\ .name = "dummy",
159 \\ .target = exe.root_module.resolved_target orelse b.host,
160 \\ .optimize = exe.root_module.optimize.?,
161 \\ });
162 \\ if (self.entry) |capture| {
163 \\ result.root_source_file = .{ .path = capture };
164 \\ }
165 \\ for (self.deps) |item| {
166 \\ const module_dep = item.module(exe);
167 \\ if (module_dep.root_source_file != null) {
168 \\ result.addImport(item.name, module_dep);
169 \\ }
170 \\ for (module_dep.include_dirs.items) |jtem| {
171 \\ switch (jtem) {
172 \\ .path => result.addIncludePath(jtem.path),
173 \\ .path_system, .path_after, .framework_path, .framework_path_system, .other_step, .config_header_step => {},
174 \\ }
175 \\ }
176 \\ }
177 \\ for (self.c_include_dirs) |item| {
178 \\ result.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
179 \\ dummy_library.addIncludePath(.{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) });
180 \\ link_lib_c = true;
181 \\ }
182 \\ for (self.c_source_files) |item| {
183 \\ dummy_library.addCSourceFile(.{ .file = .{ .cwd_relative = b.fmt("{s}/zigmod/deps{s}/{s}", .{ b.cache_root.path.?, self.store.?, item }) }, .flags = self.c_source_flags });
184 \\ }
185 \\ for (self.system_libs) |item| {
186 \\ dummy_library.linkSystemLibrary(item);
190 \\ }187 \\ }
191 \\ const result = ModuleDependency{188 \\ for (self.frameworks) |item| {
192 \\ .name = self.name,189 \\ dummy_library.linkFramework(item);
193 \\ .module = b.createModule(.{190 \\ }
194 \\ .source_file = .{ .path = self.entry.? },191 \\ if (self.c_source_files.len > 0 or self.system_libs.len > 0 or self.frameworks.len > 0) {
195 \\ .dependencies = b.allocator.dupe(ModuleDependency, temp[0..self.deps.len]) catch @panic("oom"),192 \\ dummy_library.linkLibC();
196 \\ }),193 \\ exe.root_module.linkLibrary(dummy_library);
197 \\ };194 \\ link_lib_c = true;
198 \\ self.module = result;195 \\ }
196 \\ if (link_lib_c) {
197 \\ result.link_libc = true;
198 \\ }
199 \\ self.module_memo = result;
199 \\ return result;200 \\ return result;
200 \\ }201 \\ }
201 \\};202 \\};
...@@ -204,7 +205,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D...@@ -204,7 +205,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
204 );205 );
205206
206 try w.print(207 try w.print(
207 \\fn checkMinZig(current: std.SemanticVersion, exe: *std.build.LibExeObjStep) void {{208 \\fn checkMinZig(current: std.SemanticVersion, exe: *std.Build.Step.Compile) void {{
208 \\ const min = std.SemanticVersion.parse("{?}") catch return;209 \\ const min = std.SemanticVersion.parse("{?}") catch return;
209 \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}}));210 \\ if (current.order(min).compare(.lt)) @panic(exe.step.owner.fmt("Your Zig version v{{}} does not meet the minimum build requirement of v{{}}", .{{current, min}}));
210 \\}}211 \\}}
...@@ -273,7 +274,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:...@@ -273,7 +274,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:
273 , .{274 , .{
274 mod.short_id(),275 mod.short_id(),
275 });276 });
276 var fixed_path = if (std.mem.startsWith(u8, mod.clean_path, "v/")) mod.clean_path[2..std.mem.lastIndexOfScalar(u8, mod.clean_path, '/').?] else mod.clean_path;277 const fixed_path = if (std.mem.startsWith(u8, mod.clean_path, "v/")) mod.clean_path[2..std.mem.lastIndexOfScalar(u8, mod.clean_path, '/').?] else mod.clean_path;
277 switch (mod.type) {278 switch (mod.type) {
278 .system_lib, .framework => {},279 .system_lib, .framework => {},
279 .local => {},280 .local => {},
...@@ -285,10 +286,9 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:...@@ -285,10 +286,9 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:
285 try w.print(" .name = \"{s}\",\n", .{mod.name});286 try w.print(" .name = \"{s}\",\n", .{mod.name});
286 try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath), mod.main });287 try w.print(" .entry = \"/{}/{s}/{s}\",\n", .{ std.zig.fmtEscapes(fixed_path), try mod.pin(alloc, cachepath), mod.main });
287288
288 if (!mod.has_no_zig_deps()) {289 if (mod.deps.len != 0) {
289 try w.writeAll(" .deps = &[_]*Package{");290 try w.writeAll(" .deps = &[_]*Package{");
290 for (mod.deps, 0..) |moddep, j| {291 for (mod.deps, 0..) |moddep, j| {
291 if (moddep.main.len == 0) continue;
292 try w.print(" &_{s}", .{moddep.id[0..12]});292 try w.print(" &_{s}", .{moddep.id[0..12]});
293 if (j != mod.deps.len - 1) try w.writeAll(",");293 if (j != mod.deps.len - 1) try w.writeAll(",");
294 }294 }
...@@ -337,9 +337,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:...@@ -337,9 +337,6 @@ fn print_pkg_data_to(w: std.fs.File.Writer, alloc: std.mem.Allocator, cachepath:
337 }337 }
338 try w.writeAll(" },\n");338 try w.writeAll(" },\n");
339 }339 }
340 if (mod.vcpkg) {
341 try w.writeAll(" .vcpkg = true,\n");
342 }
343 try w.writeAll(" };\n");340 try w.writeAll(" };\n");
344341
345 try done.append(mod);342 try done.append(mod);
src/common.zig+6-9
...@@ -54,7 +54,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO...@@ -54,7 +54,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO
54 .yaml = m.yaml,54 .yaml = m.yaml,
55 .dep = null,55 .dep = null,
56 .min_zig_version = m.min_zig_version,56 .min_zig_version = m.min_zig_version,
57 .vcpkg = m.vcpkg,
58 };57 };
59}58}
6059
...@@ -85,7 +84,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,...@@ -85,7 +84,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, dtype: zigmod.Dep.Type,
85 .yaml = m.yaml,84 .yaml = m.yaml,
86 .dep = null,85 .dep = null,
87 .min_zig_version = m.min_zig_version,86 .min_zig_version = m.min_zig_version,
88 .vcpkg = m.vcpkg,
89 };87 };
90}88}
9189
...@@ -153,7 +151,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !...@@ -153,7 +151,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
153 defer pvd.close();151 defer pvd.close();
154 try pvd.deleteTree(".git");152 try pvd.deleteTree(".git");
155 }153 }
156 var pvd = try std.fs.cwd().openIterableDir(pv, .{});154 var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true });
157 defer pvd.close();155 defer pvd.close();
158 try setTreeReadOnly(pvd, options.alloc);156 try setTreeReadOnly(pvd, options.alloc);
159 return pv;157 return pv;
...@@ -190,7 +188,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !...@@ -190,7 +188,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
190 try d.type.pull(options.alloc, d.path, pv);188 try d.type.pull(options.alloc, d.path, pv);
191 if (try u.validate_hash(options.alloc, d.version, file_path)) {189 if (try u.validate_hash(options.alloc, d.version, file_path)) {
192 try std.fs.cwd().deleteFile(file_path);190 try std.fs.cwd().deleteFile(file_path);
193 var pvd = try std.fs.cwd().openIterableDir(pv, .{});191 var pvd = try std.fs.cwd().openDir(pv, .{ .iterate = true });
194 defer pvd.close();192 defer pvd.close();
195 try setTreeReadOnly(pvd, options.alloc);193 try setTreeReadOnly(pvd, options.alloc);
196 return pv;194 return pv;
...@@ -243,7 +241,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO...@@ -243,7 +241,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
243 .dep = d.*,241 .dep = d.*,
244 .for_build = d.for_build,242 .for_build = d.for_build,
245 .min_zig_version = null,243 .min_zig_version = null,
246 .vcpkg = false,
247 };244 };
248 },245 },
249 else => {246 else => {
...@@ -297,7 +294,7 @@ pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: std....@@ -297,7 +294,7 @@ pub fn gen_files_package(alloc: std.mem.Allocator, cachepath: string, mdir: std.
297 defer map.deinit();294 defer map.deinit();
298295
299 for (dirs) |dir_path| {296 for (dirs) |dir_path| {
300 const dir = try mdir.openIterableDir(dir_path, .{});297 const dir = try mdir.openDir(dir_path, .{ .iterate = true });
301 var walker = try dir.walk(alloc);298 var walker = try dir.walk(alloc);
302 defer walker.deinit();299 defer walker.deinit();
303 while (try walker.next()) |p| {300 while (try walker.next()) |p| {
...@@ -377,13 +374,13 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str...@@ -377,13 +374,13 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str
377 return list.toOwnedSlice();374 return list.toOwnedSlice();
378}375}
379376
380fn setTreeReadOnly(idir: std.fs.IterableDir, alloc: std.mem.Allocator) !void {377fn setTreeReadOnly(dir: std.fs.Dir, alloc: std.mem.Allocator) !void {
381 var walker = try idir.walk(alloc);378 var walker = try dir.walk(alloc);
382 defer walker.deinit();379 defer walker.deinit();
383380
384 while (try walker.next()) |entry| {381 while (try walker.next()) |entry| {
385 if (entry.kind != .file) continue;382 if (entry.kind != .file) continue;
386 var file = try idir.dir.openFile(entry.path, .{});383 var file = try dir.openFile(entry.path, .{});
387 defer file.close();384 defer file.close();
388 var metadata = try file.metadata();385 var metadata = try file.metadata();
389 var perms = metadata.permissions();386 var perms = metadata.permissions();
src/main.zig+2-2
...@@ -56,7 +56,7 @@ pub fn main() !void {...@@ -56,7 +56,7 @@ pub fn main() !void {
56 for (args[1..]) |item| {56 for (args[1..]) |item| {
57 try sub_cmd_args.append(item);57 try sub_cmd_args.append(item);
58 }58 }
59 const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) {59 const result = std.ChildProcess.run(.{ .allocator = gpa, .argv = sub_cmd_args.items }) catch |e| switch (e) {
60 else => |ee| return ee,60 else => |ee| return ee,
61 error.FileNotFound => {61 error.FileNotFound => {
62 fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]});62 fail("unknown command \"{s}\" for \"zigmod\"", .{args[0]});
...@@ -75,7 +75,7 @@ const ansi_reset = "\x1B[39m";...@@ -75,7 +75,7 @@ const ansi_reset = "\x1B[39m";
75pub fn assert(ok: bool, comptime fmt: string, args: anytype) void {75pub fn assert(ok: bool, comptime fmt: string, args: anytype) void {
76 if (!ok) {76 if (!ok) {
77 std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args);77 std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args);
78 std.os.exit(1);78 std.process.exit(1);
79 }79 }
80}80}
8181
src/util/dep.zig-1
...@@ -27,7 +27,6 @@ pub const Dep = struct {...@@ -27,7 +27,6 @@ pub const Dep = struct {
27 yaml: ?yaml.Mapping,27 yaml: ?yaml.Mapping,
28 deps: []zigmod.Dep,28 deps: []zigmod.Dep,
29 keep: bool = false,29 keep: bool = false,
30 vcpkg: bool = false,
31 for_build: bool = false,30 for_build: bool = false,
32 parent_id: string,31 parent_id: string,
3332
src/util/funcs.zig+4-4
...@@ -19,7 +19,7 @@ const ansi_reset = "\x1B[39m";...@@ -19,7 +19,7 @@ const ansi_reset = "\x1B[39m";
19pub fn assert(ok: bool, comptime fmt: string, args: anytype) void {19pub fn assert(ok: bool, comptime fmt: string, args: anytype) void {
20 if (!ok) {20 if (!ok) {
21 std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args);21 std.debug.print(ansi_red ++ fmt ++ ansi_reset ++ "\n", args);
22 std.os.exit(1);22 std.process.exit(1);
23 }23 }
24}24}
2525
...@@ -47,13 +47,13 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {...@@ -47,13 +47,13 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
47}47}
4848
49pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {49pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {
50 var dir = try std.fs.cwd().openIterableDir(dpath, .{});50 var dir = try std.fs.cwd().openDir(dpath, .{ .iterate = true });
51 defer dir.close();51 defer dir.close();
52 return try extras.fileList(alloc, dir);52 return try extras.fileList(alloc, dir);
53}53}
5454
55pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.ExecResult {55pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.RunResult {
56 return std.ChildProcess.exec(.{ .allocator = alloc, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) {56 return std.ChildProcess.run(.{ .allocator = alloc, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch (e) {
57 error.FileNotFound => {57 error.FileNotFound => {
58 u.fail("\"{s}\" command not found", .{args[0]});58 u.fail("\"{s}\" command not found", .{args[0]});
59 },59 },
src/util/modfile.zig-3
...@@ -28,7 +28,6 @@ pub const ModFile = struct {...@@ -28,7 +28,6 @@ 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,
3231
33 pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !std.fs.File {32 pub fn openFile(dir: std.fs.Dir, ops: std.fs.File.OpenFlags) !std.fs.File {
34 return dir.openFile("zig.mod", ops) catch |err| switch (err) {33 return dir.openFile("zig.mod", ops) catch |err| switch (err) {
...@@ -75,7 +74,6 @@ pub const ModFile = struct {...@@ -75,7 +74,6 @@ pub const ModFile = struct {
75 .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false),74 .rootdeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "root_dependencies" }, false),
76 .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true),75 .builddeps = try dep_list_by_name(alloc, mapping, &.{ "dev_dependencies", "build_dependencies" }, true),
77 .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version") orelse "") catch null,76 .min_zig_version = std.SemanticVersion.parse(mapping.get_string("min_zig_version") orelse "") catch null,
78 .vcpkg = std.mem.eql(u8, "true", mapping.get_string("vcpkg") orelse ""),
79 };77 };
80 }78 }
8179
...@@ -137,7 +135,6 @@ pub const ModFile = struct {...@@ -137,7 +135,6 @@ pub const ModFile = struct {
137 .yaml = item.mapping,135 .yaml = item.mapping,
138 .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build),136 .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build),
139 .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""),137 .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""),
140 .vcpkg = std.mem.eql(u8, "true", item.mapping.get_string("vcpkg") orelse ""),
141 .for_build = for_build,138 .for_build = for_build,
142 .parent_id = mapping.get_string("id") orelse "",139 .parent_id = mapping.get_string("id") orelse "",
143 });140 });
src/util/module.zig-2
...@@ -27,7 +27,6 @@ pub const Module = struct {...@@ -27,7 +27,6 @@ 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,
3130
32 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: string, options: *common.CollectOptions) !Module {31 pub fn from(alloc: std.mem.Allocator, dep: zigmod.Dep, cachepath: string, options: *common.CollectOptions) !Module {
33 var moddeps = std.ArrayList(Module).init(alloc);32 var moddeps = std.ArrayList(Module).init(alloc);
...@@ -54,7 +53,6 @@ pub const Module = struct {...@@ -54,7 +53,6 @@ pub const Module = struct {
54 .dep = dep,53 .dep = dep,
55 .for_build = dep.for_build,54 .for_build = dep.for_build,
56 .min_zig_version = null,55 .min_zig_version = null,
57 .vcpkg = dep.vcpkg,
58 };56 };
59 }57 }
6058
zig.mod+5-2
...@@ -3,7 +3,7 @@ name: zigmod...@@ -3,7 +3,7 @@ name: zigmod
3main: src/lib.zig3main: src/lib.zig
4license: MIT4license: MIT
5description: A package manager for the Zig programming language.5description: A package manager for the Zig programming language.
6min_zig_version: 0.11.06min_zig_version: 0.12.0
7dependencies:7dependencies:
8 - src: git https://github.com/nektro/zig-yaml8 - src: git https://github.com/nektro/zig-yaml
9 - src: git https://github.com/nektro/zig-ansi9 - src: git https://github.com/nektro/zig-ansi
...@@ -18,7 +18,10 @@ dependencies:...@@ -18,7 +18,10 @@ dependencies:
1818
19root_dependencies:19root_dependencies:
20 - src: git https://github.com/marlersoft/zigwin3220 - src: git https://github.com/marlersoft/zigwin32
21 id: zg4wbiyyfn2fdpmia0jjh2d5k0xb7v1l7zn3xcyv21 id: o6ogpor87xc23o863qaqfciqqdnt48nlj0395dk1xt4m9b34
22 keep: true22 keep: true
23 name: win32
24 main: win32.zig
25 license: MIT
23 - src: git https://github.com/nektro/zig-extras26 - src: git https://github.com/nektro/zig-extras
24 - src: git https://github.com/nektro/zig-ansi27 - src: git https://github.com/nektro/zig-ansi
zigmod.lock+8-8
...@@ -1,18 +1,18 @@...@@ -1,18 +1,18 @@
1212
2git https://github.com/marlersoft/zigwin32 commit-c778640d3dc153e900fbe37e2816b5176af3c8022git https://github.com/marlersoft/zigwin32 commit-c778640d3dc153e900fbe37e2816b5176af3c802
3git https://github.com/nektro/arqv-ini commit-ddbe89bb0d9085e939bcbc713caeb2b7cf852bae3git https://github.com/nektro/arqv-ini commit-38a018ad3a19d5b4663a5364d2d31271f250846b
4git https://github.com/nektro/iguanaTLS commit-f5c7c3fe880c5a23fbcdc21dfcb83c2776931f404git https://github.com/nektro/iguanaTLS commit-4dc8850883b49e4a452871298788b06b1af9fe24
5git https://github.com/nektro/zfetch commit-478031843703fef875ca347898208c01869c7c9d5git https://github.com/nektro/zfetch commit-863be236188e5f24d16554f9dcd7df96dd254a13
6git https://github.com/nektro/zig-ansi commit-407a70207ee818f6920096f40779e3fb52db49b06git https://github.com/nektro/zig-ansi commit-c3e439f86b0484e4428f38c4d8b07b7b5ae1634b
7git https://github.com/nektro/zig-detect-license commit-3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd7git https://github.com/nektro/zig-detect-license commit-3ff57d0681b7bd7f8ca9bd092afa0b4bfe2f1afd
8git https://github.com/nektro/zig-extras commit-c95c2301565603856ff6fcaecaa63bdcdd689bc18git https://github.com/nektro/zig-extras commit-74f0ddb0a4dfa7921739b88cc381951a6b6e73ce
9git https://github.com/nektro/zig-inquirer commit-9e1d873db79e9ffa6ae6e06bd372428c9be85d979git https://github.com/nektro/zig-inquirer commit-9e1d873db79e9ffa6ae6e06bd372428c9be85d97
10git https://github.com/nektro/zig-leven commit-e548b0bcc7b6f34f636c0b6b905928d31254c54d10git https://github.com/nektro/zig-leven commit-e548b0bcc7b6f34f636c0b6b905928d31254c54d
11git https://github.com/nektro/zig-licenses commit-f46d9f774df929885eef66c733a1e2a46bf16aec11git https://github.com/nektro/zig-licenses commit-f46d9f774df929885eef66c733a1e2a46bf16aec
12git https://github.com/nektro/zig-licenses-text commit-b01e5a2dffcc564bddd8f514fe64bab9b5c5257212git https://github.com/nektro/zig-licenses-text commit-b01e5a2dffcc564bddd8f514fe64bab9b5c52572
13git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e041599213git https://github.com/nektro/zig-range commit-4b2f12808aa09be4b27a163efc424dd4e0415992
14git https://github.com/nektro/zig-time commit-913d3ff01878326955bb3b265dcb3fdb3607d23214git https://github.com/nektro/zig-time commit-ba546bbf2e8438c9b2325f36f392c9d95b432e8e
15git https://github.com/nektro/zig-yaml commit-0d17fb99cba338aedc1abac12d78d5e5f04f0b6b15git https://github.com/nektro/zig-yaml commit-0d17fb99cba338aedc1abac12d78d5e5f04f0b6b
16git https://github.com/truemedian/hzzp commit-31563ce8173038aff326f83b18d49d84e273725516git https://github.com/truemedian/hzzp commit-a7f03a1e652abe8c89b376d090cec50acb0d2a1a
17git https://github.com/ziglibs/known-folders commit-bf79988adcfce166f848e4b11e718c196636532917git https://github.com/ziglibs/known-folders commit-0ad514dcfb7525e32ae349b9acc0a53976f3a9fa
18git https://github.com/yaml/libyaml tag-0.2.518git https://github.com/yaml/libyaml tag-0.2.5