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...@@ -91,6 +91,9 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: C
91 }91 }
92 switch (d.type) {92 switch (d.type) {
93 .local => {93 .local => {
94 if (!std.mem.endsWith(u8, d.main, ".zig")) {
95 return d.main;
96 }
94 return d.path;97 return d.path;
95 },98 },
96 .system_lib => {99 .system_lib => {
...@@ -197,23 +200,19 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8...@@ -197,23 +200,19 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8
197 });200 });
198 },201 },
199 else => {202 else => {
200 if (d.type == .local) {
201 try list.append(try u.Module.from(d));
202 return;
203 }
204 var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) {203 var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) {
205 error.FileNotFound => {204 error.FileNotFound => {
206 if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) {205 if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) {
207 var mod_from = try u.Module.from(d);206 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..];
209 if (mod_from.is_for_this()) try list.append(mod_from);208 if (mod_from.is_for_this()) try list.append(mod_from);
210 }209 }
211 return;210 return;
212 },211 },
213 else => e,212 else => e,
214 };213 };
215 dd.clean_path = u.trim_prefix(moddir, dir)[1..];214 const save = dd;
216215 if (d.type != .local) dd.clean_path = u.trim_prefix(moddir, dir)[1..];
217 if (dd.id.len == 0) dd.id = try u.random_string(48);216 if (dd.id.len == 0) dd.id = try u.random_string(48);
218 if (d.name.len > 0) dd.name = d.name;217 if (d.name.len > 0) dd.name = d.name;
219 if (d.main.len > 0) dd.main = d.main;218 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...@@ -222,7 +221,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8
222 if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files;221 if (d.c_source_files.len > 0) dd.c_source_files = d.c_source_files;
223 if (d.only_os.len > 0) dd.only_os = d.only_os;222 if (d.only_os.len > 0) dd.only_os = d.only_os;
224 if (d.except_os.len > 0) dd.except_os = d.except_os;223 if (d.except_os.len > 0) dd.except_os = d.except_os;
225224 if (d.type == .local) dd.main = try std.fs.path.join(gpa, &.{ d.main, save.main });
226 if (dd.is_for_this()) try list.append(dd);225 if (dd.is_for_this()) try list.append(dd);
227 },226 },
228 }227 }