| author | |
| committer | |
| log | 21e9824c43eb8d7b4bee9b3d07e80dbca623b82f |
| tree | 03d5d69371056aaf8929c8d64aee533679300864 |
| parent | 0d3e261e8a6b3de11f42fe209c1a5822de0d7df8 |
4 files changed, 14 insertions(+), 6 deletions(-)
src/common.zig+3-2| ... | ... | @@ -180,7 +180,7 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: C |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, options: CollectOptions) !void { | |
| 183 | pub fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8, parent_name: []const u8, options: CollectOptions) anyerror!void { | |
| 184 | 184 | const moddir = try get_moddir(dir, d, parent_name, options); |
| 185 | 185 | switch (d.type) { |
| 186 | 186 | .system_lib => { |
| ... | ... | @@ -203,7 +203,7 @@ fn get_module_from_dep(list: *std.ArrayList(u.Module), d: u.Dep, dir: []const u8 |
| 203 | 203 | var dd = try collect_deps(dir, try u.concat(&.{ moddir, "/zig.mod" }), options) catch |e| switch (e) { |
| 204 | 204 | error.FileNotFound => { |
| 205 | 205 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 206 | var mod_from = try u.Module.from(d); | |
| 206 | var mod_from = try u.Module.from(d, dir, options); | |
| 207 | 207 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 208 | 208 | if (mod_from.is_for_this()) try list.append(mod_from); |
| 209 | 209 | } |
| ... | ... | @@ -283,6 +283,7 @@ fn add_files_package(pkg_name: []const u8, dirs: []const []const u8, list: *std. |
| 283 | 283 | .only_os = &.{}, |
| 284 | 284 | .except_os = &.{}, |
| 285 | 285 | .yaml = null, |
| 286 | .deps = &.{}, | |
| 286 | 287 | }; |
| 287 | 288 | try get_module_from_dep(list, d, destination, parent_name, .{ |
| 288 | 289 | .log = false, |
src/util/dep.zig+1| ... | ... | @@ -24,6 +24,7 @@ pub const Dep = struct { |
| 24 | 24 | only_os: []const []const u8, |
| 25 | 25 | except_os: []const []const u8, |
| 26 | 26 | yaml: ?yaml.Mapping, |
| 27 | deps: []const u.Dep, | |
| 27 | 28 | |
| 28 | 29 | pub fn clean_path(self: Dep) ![]const u8 { |
| 29 | 30 | if (self.type == .local) { |
src/util/modfile.zig+2-2| ... | ... | @@ -45,7 +45,6 @@ pub const ModFile = struct { |
| 45 | 45 | u.assert(false, "name may not contain any '/'", .{}); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | ||
| 49 | 48 | return Self{ |
| 50 | 49 | .alloc = alloc, |
| 51 | 50 | .id = if (id.len == 0) try u.random_string(48) else id, |
| ... | ... | @@ -62,7 +61,7 @@ pub const ModFile = struct { |
| 62 | 61 | }; |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: []const u8) ![]const u.Dep { | |
| 64 | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: []const u8) anyerror![]const u.Dep { | |
| 66 | 65 | const dep_list = &std.ArrayList(u.Dep).init(alloc); |
| 67 | 66 | if (mapping.get(prop)) |dep_seq| { |
| 68 | 67 | if (dep_seq == .sequence) { |
| ... | ... | @@ -115,6 +114,7 @@ pub const ModFile = struct { |
| 115 | 114 | .only_os = try u.list_remove(try u.split(item.mapping.get_string("only_os"), ","), ""), |
| 116 | 115 | .except_os = try u.list_remove(try u.split(item.mapping.get_string("except_os"), ","), ""), |
| 117 | 116 | .yaml = item.mapping, |
| 117 | .deps = try dep_list_by_name(alloc, item.mapping, "dependencies"), | |
| 118 | 118 | }); |
| 119 | 119 | } |
| 120 | 120 | } |
src/util/module.zig+8-2| ... | ... | @@ -4,6 +4,7 @@ const builtin = std.builtin; |
| 4 | 4 | |
| 5 | 5 | const u = @import("index.zig"); |
| 6 | 6 | const yaml = @import("./yaml.zig"); |
| 7 | const common = @import("./../common.zig"); | |
| 7 | 8 | |
| 8 | 9 | // |
| 9 | 10 | // |
| ... | ... | @@ -23,7 +24,12 @@ pub const Module = struct { |
| 23 | 24 | deps: []Module, |
| 24 | 25 | clean_path: []const u8, |
| 25 | 26 | |
| 26 | pub fn from(dep: u.Dep) !Module { | |
| 27 | pub fn from(dep: u.Dep, dir: []const u8, options: common.CollectOptions) !Module { | |
| 28 | const moddeps = &std.ArrayList(Module).init(gpa); | |
| 29 | defer moddeps.deinit(); | |
| 30 | for (dep.deps) |d| { | |
| 31 | try common.get_module_from_dep(moddeps, d, dir, dep.name, options); | |
| 32 | } | |
| 27 | 33 | return Module{ |
| 28 | 34 | .is_sys_lib = false, |
| 29 | 35 | .id = if (dep.id.len > 0) dep.id else try u.random_string(48), |
| ... | ... | @@ -32,7 +38,7 @@ pub const Module = struct { |
| 32 | 38 | .c_include_dirs = dep.c_include_dirs, |
| 33 | 39 | .c_source_flags = dep.c_source_flags, |
| 34 | 40 | .c_source_files = dep.c_source_files, |
| 35 | .deps = &.{}, | |
| 41 | .deps = moddeps.toOwnedSlice(), | |
| 36 | 42 | .clean_path = try dep.clean_path(), |
| 37 | 43 | .only_os = dep.only_os, |
| 38 | 44 | .except_os = dep.except_os, |