authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 02:39:55 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 02:39:55 -07:00
log791f4831c20376be1511bef09eb018533a3cdcbf
tree2e43ac5c3024622d30fe11ce6130cf02a1431ec3
parent6fd42714e7ec2ab81732770c6eebc9ff7a683b5e

move Dep to lib entry point


7 files changed, 16 insertions(+), 14 deletions(-)

src/cmd/aquila/install.zig+2-1
...@@ -4,6 +4,7 @@ const gpa = std.heap.c_allocator;...@@ -4,6 +4,7 @@ const gpa = std.heap.c_allocator;
44
5const knownfolders = @import("known-folders");5const knownfolders = @import("known-folders");
66
7const zigmod = @import("../../lib.zig");
7const u = @import("./../../util/index.zig");8const u = @import("./../../util/index.zig");
8const common = @import("./../../common.zig");9const common = @import("./../../common.zig");
910
...@@ -29,7 +30,7 @@ pub fn execute(args: [][]u8) !void {...@@ -29,7 +30,7 @@ pub fn execute(args: [][]u8) !void {
2930
30 // get modfile and dep31 // get modfile and dep
31 const m = try u.ModFile.from_dir(gpa, homedir);32 const m = try u.ModFile.from_dir(gpa, homedir);
32 var dep: u.Dep = undefined;33 var dep: zigmod.Dep = undefined;
33 for (m.devdeps) |d| {34 for (m.devdeps) |d| {
34 if (std.mem.eql(u8, d.path, pkgurl)) {35 if (std.mem.eql(u8, d.path, pkgurl)) {
35 dep = d;36 dep = d;
src/common.zig+4-4
...@@ -94,7 +94,7 @@ pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void...@@ -94,7 +94,7 @@ pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void
94 }94 }
95}95}
9696
97pub fn get_modpath(cachepath: string, d: u.Dep, options: *CollectOptions) !string {97pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !string {
98 const p = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path() });98 const p = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path() });
99 const pv = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path_v() });99 const pv = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path_v() });
100100
...@@ -198,7 +198,7 @@ pub fn get_modpath(cachepath: string, d: u.Dep, options: *CollectOptions) !strin...@@ -198,7 +198,7 @@ pub fn get_modpath(cachepath: string, d: u.Dep, options: *CollectOptions) !strin
198 }198 }
199}199}
200200
201pub fn get_module_from_dep(d: *u.Dep, cachepath: string, options: *CollectOptions) anyerror!?u.Module {201pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?u.Module {
202 if (options.lock) |lock| {202 if (options.lock) |lock| {
203 for (lock) |item| {203 for (lock) |item| {
204 if (std.mem.eql(u8, item[0], try d.clean_path())) {204 if (std.mem.eql(u8, item[0], try d.clean_path())) {
...@@ -326,7 +326,7 @@ pub fn add_files_package(pkg_name: string, mdir: std.fs.Dir, dirs: []const strin...@@ -326,7 +326,7 @@ pub fn add_files_package(pkg_name: string, mdir: std.fs.Dir, dirs: []const strin
326 \\326 \\
327 );327 );
328328
329 var d: u.Dep = .{329 var d: zigmod.Dep = .{
330 .type = .local,330 .type = .local,
331 .path = "files",331 .path = "files",
332 .id = "",332 .id = "",
...@@ -367,7 +367,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4]string {...@@ -367,7 +367,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4]string {
367 },367 },
368 2 => {368 2 => {
369 var iter = std.mem.split(u8, line, " ");369 var iter = std.mem.split(u8, line, " ");
370 const asdep = u.Dep{370 const asdep = zigmod.Dep{
371 .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?,371 .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?,
372 .path = iter.next().?,372 .path = iter.next().?,
373 .version = iter.next().?,373 .version = iter.next().?,
src/lib.zig+1
...@@ -24,3 +24,4 @@ pub fn deinit() void {...@@ -24,3 +24,4 @@ pub fn deinit() void {
24}24}
2525
26pub const DepType = @import("./util/dep_type.zig").DepType;26pub const DepType = @import("./util/dep_type.zig").DepType;
27pub const Dep = @import("./util/dep.zig").Dep;
src/util/dep.zig+1-1
...@@ -26,7 +26,7 @@ pub const Dep = struct {...@@ -26,7 +26,7 @@ pub const Dep = struct {
26 only_os: []const string = &.{},26 only_os: []const string = &.{},
27 except_os: []const string = &.{},27 except_os: []const string = &.{},
28 yaml: ?yaml.Mapping,28 yaml: ?yaml.Mapping,
29 deps: []u.Dep,29 deps: []zigmod.Dep,
3030
31 pub fn clean_path(self: Dep) !string {31 pub fn clean_path(self: Dep) !string {
32 if (self.type == .local) {32 if (self.type == .local) {
src/util/index.zig-1
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1usingnamespace @import("./funcs.zig");1usingnamespace @import("./funcs.zig");
2usingnamespace @import("./dep.zig");
3usingnamespace @import("./modfile.zig");2usingnamespace @import("./modfile.zig");
4usingnamespace @import("./module.zig");3usingnamespace @import("./module.zig");
src/util/modfile.zig+5-5
...@@ -21,9 +21,9 @@ pub const ModFile = struct {...@@ -21,9 +21,9 @@ pub const ModFile = struct {
21 c_include_dirs: []const string,21 c_include_dirs: []const string,
22 c_source_flags: []const string,22 c_source_flags: []const string,
23 c_source_files: []const string,23 c_source_files: []const string,
24 deps: []u.Dep,24 deps: []zigmod.Dep,
25 yaml: yaml.Mapping,25 yaml: yaml.Mapping,
26 devdeps: []u.Dep,26 devdeps: []zigmod.Dep,
27 root_files: []const string,27 root_files: []const string,
28 files: []const string,28 files: []const string,
2929
...@@ -67,8 +67,8 @@ pub const ModFile = struct {...@@ -67,8 +67,8 @@ pub const ModFile = struct {
67 };67 };
68 }68 }
6969
70 fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: string) anyerror![]u.Dep {70 fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: string) anyerror![]zigmod.Dep {
71 var dep_list = std.ArrayList(u.Dep).init(alloc);71 var dep_list = std.ArrayList(zigmod.Dep).init(alloc);
72 if (mapping.get(prop)) |dep_seq| {72 if (mapping.get(prop)) |dep_seq| {
73 if (dep_seq == .sequence) {73 if (dep_seq == .sequence) {
74 for (dep_seq.sequence) |item| {74 for (dep_seq.sequence) |item| {
...@@ -107,7 +107,7 @@ pub const ModFile = struct {...@@ -107,7 +107,7 @@ pub const ModFile = struct {
107 }107 }
108 }108 }
109109
110 try dep_list.append(u.Dep{110 try dep_list.append(zigmod.Dep{
111 .type = dep_type,111 .type = dep_type,
112 .path = path,112 .path = path,
113 .id = item.mapping.get_string("id"),113 .id = item.mapping.get_string("id"),
src/util/module.zig+3-2
...@@ -3,6 +3,7 @@ const string = []const u8;...@@ -3,6 +3,7 @@ const string = []const u8;
3const gpa = std.heap.c_allocator;3const gpa = std.heap.c_allocator;
4const builtin = @import("builtin");4const builtin = @import("builtin");
55
6const zigmod = @import("../lib.zig");
6const u = @import("index.zig");7const u = @import("index.zig");
7const yaml = @import("./yaml.zig");8const yaml = @import("./yaml.zig");
8const common = @import("./../common.zig");9const common = @import("./../common.zig");
...@@ -23,9 +24,9 @@ pub const Module = struct {...@@ -23,9 +24,9 @@ pub const Module = struct {
23 yaml: ?yaml.Mapping,24 yaml: ?yaml.Mapping,
24 deps: []Module,25 deps: []Module,
25 clean_path: string,26 clean_path: string,
26 dep: ?u.Dep,27 dep: ?zigmod.Dep,
2728
28 pub fn from(dep: u.Dep, dir: string, options: *common.CollectOptions) !Module {29 pub fn from(dep: zigmod.Dep, dir: string, options: *common.CollectOptions) !Module {
29 var moddeps = std.ArrayList(Module).init(gpa);30 var moddeps = std.ArrayList(Module).init(gpa);
30 defer moddeps.deinit();31 defer moddeps.deinit();
31 for (dep.deps) |*d| {32 for (dep.deps) |*d| {