| ... | ... | @@ -20,9 +20,9 @@ pub const ModFile = struct { |
| 20 | 20 | c_include_dirs: [][]const u8, |
| 21 | 21 | c_source_flags: [][]const u8, |
| 22 | 22 | c_source_files: [][]const u8, |
| 23 | | deps: []u.Dep, |
| 23 | deps: []const u.Dep, |
| 24 | 24 | yaml: yaml.Mapping, |
| 25 | | devdeps: []u.Dep, |
| 25 | devdeps: []const u.Dep, |
| 26 | 26 | root_files: [][]const u8, |
| 27 | 27 | files: [][]const u8, |
| 28 | 28 | |
| ... | ... | @@ -45,10 +45,6 @@ pub const ModFile = struct { |
| 45 | 45 | u.assert(false, "name may not contain any '/'", .{}); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | | const dep_list = try dep_list_by_name(alloc, mapping, "dependencies"); |
| 49 | | defer dep_list.deinit(); |
| 50 | | const devdep_list = try dep_list_by_name(alloc, mapping, "dev_dependencies"); |
| 51 | | defer devdep_list.deinit(); |
| 52 | 48 | |
| 53 | 49 | return Self{ |
| 54 | 50 | .alloc = alloc, |
| ... | ... | @@ -58,17 +54,16 @@ pub const ModFile = struct { |
| 58 | 54 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), |
| 59 | 55 | .c_source_flags = try mapping.get_string_array(alloc, "c_source_flags"), |
| 60 | 56 | .c_source_files = try mapping.get_string_array(alloc, "c_source_files"), |
| 61 | | .deps = dep_list.toOwnedSlice(), |
| 57 | .deps = try dep_list_by_name(alloc, mapping, "dependencies"), |
| 62 | 58 | .yaml = mapping, |
| 63 | | .devdeps = devdep_list.toOwnedSlice(), |
| 59 | .devdeps = try dep_list_by_name(alloc, mapping, "dev_dependencies"), |
| 64 | 60 | .root_files = try mapping.get_string_array(alloc, "root_files"), |
| 65 | 61 | .files = try mapping.get_string_array(alloc, "files"), |
| 66 | 62 | }; |
| 67 | 63 | } |
| 68 | 64 | |
| 69 | | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: []const u8) !*std.ArrayList(u.Dep) { |
| 70 | | const dep_list = try alloc.create(std.ArrayList(u.Dep)); |
| 71 | | dep_list.* = std.ArrayList(u.Dep).init(alloc); |
| 65 | fn dep_list_by_name(alloc: *std.mem.Allocator, mapping: yaml.Mapping, prop: []const u8) ![]const u.Dep { |
| 66 | const dep_list = &std.ArrayList(u.Dep).init(alloc); |
| 72 | 67 | if (mapping.get(prop)) |dep_seq| { |
| 73 | 68 | if (dep_seq == .sequence) { |
| 74 | 69 | for (dep_seq.sequence) |item| { |
| ... | ... | @@ -124,6 +119,6 @@ pub const ModFile = struct { |
| 124 | 119 | } |
| 125 | 120 | } |
| 126 | 121 | } |
| 127 | | return dep_list; |
| 122 | return dep_list.toOwnedSlice(); |
| 128 | 123 | } |
| 129 | 124 | }; |