authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-06-20 13:42:39 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-06-20 13:42:39 -07:00
log0d3e261e8a6b3de11f42fe209c1a5822de0d7df8
tree3a5325daaf7e40c9b267bc3ea55e998a16ff8388
parentf80411755fb8f5e7592721a0a0b08540ea605f31

allow local type deps to point at directories


1 files changed, 7 insertions(+), 8 deletions(-)

src/common.zig+7-8
......@@ -91,6 +91,9 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: C
9191 }
9292 switch (d.type) {
9393 .local => {
94 if (!std.mem.endsWith(u8, d.main, ".zig")) {
95 return d.main;
96 }
9497 return d.path;
9598 },
9699 .system_lib => {
......@@ -197,23 +200,19 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8
197200 });
198201 },
199202 else => {
200 if (d.type == .local) {
201 try list.append(try u.Module.from(d));
202 return;
203 }
204203 var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) {
205204 error.FileNotFound => {
206205 if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) {
207206 var mod_from = try u.Module.from(d);
208 mod_from.clean_path = u.trim_prefix(moddir, dir)[1..];
207 if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..];
209208 if (mod_from.is_for_this()) try list.append(mod_from);
210209 }
211210 return;
212211 },
213212 else => e,
214213 };
215 dd.clean_path = u.trim_prefix(moddir, dir)[1..];
216
214 const save = dd;
215 if (d.type != .local) dd.clean_path = u.trim_prefix(moddir, dir)[1..];
217216 if (dd.id.len == 0) dd.id = try u.random_string(48);
218217 if (d.name.len > 0) dd.name = d.name;
219218 if (d.main.len > 0) dd.main = d.main;
......@@ -222,7 +221,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8
222221 if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files;
223222 if (d.only_os.len > 0) dd.only_os = d.only_os;
224223 if (d.except_os.len > 0) dd.except_os = d.except_os;
225
224 if (d.type == .local) dd.main = try std.fs.path.join(gpa, &.{ d.main, save.main });
226225 if (dd.is_for_this()) try list.append(dd);
227226 },
228227 }