| ... | @@ -59,18 +59,21 @@ pub const ModFile = struct { | ... | @@ -59,18 +59,21 @@ pub const ModFile = struct { |
| 59 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), | 59 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), |
| 60 | .c_source_flags = try mapping.get_string_array(alloc, "c_source_flags"), | 60 | .c_source_flags = try mapping.get_string_array(alloc, "c_source_flags"), |
| 61 | .c_source_files = try mapping.get_string_array(alloc, "c_source_files"), | 61 | .c_source_files = try mapping.get_string_array(alloc, "c_source_files"), |
| 62 | .deps = try dep_list_by_name(alloc, mapping, "dependencies"), | 62 | .deps = try dep_list_by_name(alloc, mapping, &.{"dependencies"}), |
| 63 | .yaml = mapping, | 63 | .yaml = mapping, |
| 64 | .devdeps = try dep_list_by_name(alloc, mapping, "dev_dependencies"), | 64 | .devdeps = try dep_list_by_name(alloc, mapping, &.{"dev_dependencies"}), |
| 65 | .root_files = try mapping.get_string_array(alloc, "root_files"), | 65 | .root_files = try mapping.get_string_array(alloc, "root_files"), |
| 66 | .files = try mapping.get_string_array(alloc, "files"), | 66 | .files = try mapping.get_string_array(alloc, "files"), |
| 67 | }; | 67 | }; |
| 68 | } | 68 | } |
| 69 | | 69 | |
| 70 | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: string) anyerror![]zigmod.Dep { | 70 | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, props: []const string) anyerror![]zigmod.Dep { |
| 71 | var dep_list = std.ArrayList(zigmod.Dep).init(alloc); | 71 | var dep_list = std.ArrayList(zigmod.Dep).init(alloc); |
| 72 | if (mapping.get(prop)) |dep_seq| { | 72 | defer dep_list.deinit(); |
| 73 | if (dep_seq == .sequence) { | 73 | |
| | 74 | for (props) |prop| { |
| | 75 | if (mapping.get(prop)) |dep_seq| { |
| | 76 | if (dep_seq != .sequence) continue; |
| 74 | for (dep_seq.sequence) |item| { | 77 | for (dep_seq.sequence) |item| { |
| 75 | var dtype: string = undefined; | 78 | var dtype: string = undefined; |
| 76 | var path: string = undefined; | 79 | var path: string = undefined; |
| ... | @@ -121,7 +124,7 @@ pub const ModFile = struct { | ... | @@ -121,7 +124,7 @@ pub const ModFile = struct { |
| 121 | .only_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("only_os"), ","), ""), | 124 | .only_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("only_os"), ","), ""), |
| 122 | .except_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("except_os"), ","), ""), | 125 | .except_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("except_os"), ","), ""), |
| 123 | .yaml = item.mapping, | 126 | .yaml = item.mapping, |
| 124 | .deps = try dep_list_by_name(alloc, item.mapping, "dependencies"), | 127 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}), |
| 125 | }); | 128 | }); |
| 126 | } | 129 | } |
| 127 | } | 130 | } |