From 6fd42714e7ec2ab81732770c6eebc9ff7a683b5e Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 28 Oct 2021 02:38:07 -0700 Subject: [PATCH] move DepType to lib entry point --- src/common.zig | 7 ++++--- src/lib.zig | 2 ++ src/util/dep.zig | 5 +++-- src/util/index.zig | 1 - src/util/modfile.zig | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common.zig b/src/common.zig index a51ef0d5456ce37cb1ae6d6a698ac1f2b387aef5..49a8ed35b744f9131990ebbbf01642d75181b4ce 100644 --- a/src/common.zig +++ b/src/common.zig @@ -5,6 +5,7 @@ const gpa = std.heap.c_allocator; const ansi = @import("ansi"); +const zigmod = @import("./lib.zig"); const u = @import("./util/index.zig"); const yaml = @import("./util/yaml.zig"); @@ -123,7 +124,7 @@ pub fn get_modpath(cachepath: string, d: u.Dep, options: *CollectOptions) !strin }, .git => { if (d.version.len > 0) { - const vers = u.parse_split(u.DepType.GitVersion, "-").do(d.version) catch |e| switch (e) { + const vers = u.parse_split(zigmod.DepType.GitVersion, "-").do(d.version) catch |e| switch (e) { error.IterEmpty => unreachable, error.NoMemberFound => { const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; @@ -201,7 +202,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: string, options: *CollectOption if (options.lock) |lock| { for (lock) |item| { if (std.mem.eql(u8, item[0], try d.clean_path())) { - d.type = std.meta.stringToEnum(u.DepType, item[1]).?; + d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?; d.path = item[2]; d.version = item[3]; break; @@ -367,7 +368,7 @@ pub fn parse_lockfile(dir: std.fs.Dir) ![]const [4]string { 2 => { var iter = std.mem.split(u8, line, " "); const asdep = u.Dep{ - .type = std.meta.stringToEnum(u.DepType, iter.next().?).?, + .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?, .path = iter.next().?, .version = iter.next().?, .id = "", diff --git a/src/lib.zig b/src/lib.zig index d1d18ad4e34953b70f5130060a647931d08bddf4..8e69617ac1490494d89e9e869138b10e2dcfbf51 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -22,3 +22,5 @@ pub fn init() !void { pub fn deinit() void { zfetch.deinit(); } + +pub const DepType = @import("./util/dep_type.zig").DepType; diff --git a/src/util/dep.zig b/src/util/dep.zig index 9a666a4dee40c55b519fc73f71a3ede78d1cdd25..55f6cef8859649f9f772446c48866c0bfd4e21e7 100644 --- a/src/util/dep.zig +++ b/src/util/dep.zig @@ -3,6 +3,7 @@ const string = []const u8; const gpa = std.heap.c_allocator; const builtin = std.builtin; +const zigmod = @import("../lib.zig"); const u = @import("index.zig"); const yaml = @import("./yaml.zig"); @@ -12,7 +13,7 @@ const yaml = @import("./yaml.zig"); pub const Dep = struct { const Self = @This(); - type: u.DepType, + type: zigmod.DepType, path: string, id: string, @@ -65,7 +66,7 @@ pub const Dep = struct { } return switch (self.type) { .git => blk: { - const vers = try u.parse_split(u.DepType.GitVersion, "-").do(self.version); + const vers = try u.parse_split(zigmod.DepType.GitVersion, "-").do(self.version); if (vers.id.frozen()) break :blk self.version; break :blk try self.type.exact_version(dpath); }, diff --git a/src/util/index.zig b/src/util/index.zig index de16da7c9e39a82d149db931d78eb0b435644dbf..70437f722d607353288dd6b3f43a22b9d7425723 100644 --- a/src/util/index.zig +++ b/src/util/index.zig @@ -1,5 +1,4 @@ usingnamespace @import("./funcs.zig"); -usingnamespace @import("./dep_type.zig"); usingnamespace @import("./dep.zig"); usingnamespace @import("./modfile.zig"); usingnamespace @import("./module.zig"); diff --git a/src/util/modfile.zig b/src/util/modfile.zig index ddd7f8875b217a777ff723e5015dbad6dbe4e6ad..7cacf4022770fe3af53a87c75ceccb9e933dfc33 100644 --- a/src/util/modfile.zig +++ b/src/util/modfile.zig @@ -1,6 +1,7 @@ const std = @import("std"); const string = []const u8; +const zigmod = @import("../lib.zig"); const u = @import("index.zig"); const yaml = @import("./yaml.zig"); @@ -94,7 +95,7 @@ pub const ModFile = struct { if (version == null) { version = ""; } - const dep_type = std.meta.stringToEnum(u.DepType, dtype).?; + const dep_type = std.meta.stringToEnum(zigmod.DepType, dtype).?; if (dep_type == .local) { if (path.len > 0) { name = path; -- 2.54.0