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;
44
55const knownfolders = @import("known-folders");
66
7const zigmod = @import("../../lib.zig");
78const u = @import("./../../util/index.zig");
89const common = @import("./../../common.zig");
910
......@@ -29,7 +30,7 @@ pub fn execute(args: [][]u8) !void {
2930
3031 // get modfile and dep
3132 const m = try u.ModFile.from_dir(gpa, homedir);
32 var dep: u.Dep = undefined;
33 var dep: zigmod.Dep = undefined;
3334 for (m.devdeps) |d| {
3435 if (std.mem.eql(u8, d.path, pkgurl)) {
3536 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
9494 }
9595}
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 {
9898 const p = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path() });
9999 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
198198 }
199199}
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 {
202202 if (options.lock) |lock| {
203203 for (lock) |item| {
204204 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
326326 \\
327327 );
328328
329 var d: u.Dep = .{
329 var d: zigmod.Dep = .{
330330 .type = .local,
331331 .path = "files",
332332 .id = "",
......@@ -367,7 +367,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4]string {
367367 },
368368 2 => {
369369 var iter = std.mem.split(u8, line, " ");
370 const asdep = u.Dep{
370 const asdep = zigmod.Dep{
371371 .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?,
372372 .path = iter.next().?,
373373 .version = iter.next().?,
src/lib.zig+1
......@@ -24,3 +24,4 @@ pub fn deinit() void {
2424}
2525
2626pub 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 {
2626 only_os: []const string = &.{},
2727 except_os: []const string = &.{},
2828 yaml: ?yaml.Mapping,
29 deps: []u.Dep,
29 deps: []zigmod.Dep,
3030
3131 pub fn clean_path(self: Dep) !string {
3232 if (self.type == .local) {
src/util/index.zig-1
......@@ -1,4 +1,3 @@
11usingnamespace @import("./funcs.zig");
2usingnamespace @import("./dep.zig");
32usingnamespace @import("./modfile.zig");
43usingnamespace @import("./module.zig");
src/util/modfile.zig+5-5
......@@ -21,9 +21,9 @@ pub const ModFile = struct {
2121 c_include_dirs: []const string,
2222 c_source_flags: []const string,
2323 c_source_files: []const string,
24 deps: []u.Dep,
24 deps: []zigmod.Dep,
2525 yaml: yaml.Mapping,
26 devdeps: []u.Dep,
26 devdeps: []zigmod.Dep,
2727 root_files: []const string,
2828 files: []const string,
2929
......@@ -67,8 +67,8 @@ pub const ModFile = struct {
6767 };
6868 }
6969
70 fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: string) anyerror![]u.Dep {
71 var dep_list = std.ArrayList(u.Dep).init(alloc);
70 fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: string) anyerror![]zigmod.Dep {
71 var dep_list = std.ArrayList(zigmod.Dep).init(alloc);
7272 if (mapping.get(prop)) |dep_seq| {
7373 if (dep_seq == .sequence) {
7474 for (dep_seq.sequence) |item| {
......@@ -107,7 +107,7 @@ pub const ModFile = struct {
107107 }
108108 }
109109
110 try dep_list.append(u.Dep{
110 try dep_list.append(zigmod.Dep{
111111 .type = dep_type,
112112 .path = path,
113113 .id = item.mapping.get_string("id"),
src/util/module.zig+3-2
......@@ -3,6 +3,7 @@ const string = []const u8;
33const gpa = std.heap.c_allocator;
44const builtin = @import("builtin");
55
6const zigmod = @import("../lib.zig");
67const u = @import("index.zig");
78const yaml = @import("./yaml.zig");
89const common = @import("./../common.zig");
......@@ -23,9 +24,9 @@ pub const Module = struct {
2324 yaml: ?yaml.Mapping,
2425 deps: []Module,
2526 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 {
2930 var moddeps = std.ArrayList(Module).init(gpa);
3031 defer moddeps.deinit();
3132 for (dep.deps) |*d| {