| ... | @@ -830,7 +830,17 @@ pub fn addModule(b: *Build, name: []const u8, options: Module.CreateOptions) *Mo | ... | @@ -830,7 +830,17 @@ pub fn addModule(b: *Build, name: []const u8, options: Module.CreateOptions) *Mo |
| 830 | const graph = b.graph; | 830 | const graph = b.graph; |
| 831 | const arena = graph.arena; | 831 | const arena = graph.arena; |
| 832 | const module = Module.create(b, options); | 832 | const module = Module.create(b, options); |
| 833 | b.modules.put(arena, graph.dupeString(name), module) catch @panic("OOM"); | 833 | const gop = b.modules.getOrPutValue( |
| | 834 | arena, |
| | 835 | graph.dupeString(name), |
| | 836 | module, |
| | 837 | ) catch @panic("OOM"); |
| | 838 | if (gop.found_existing) { |
| | 839 | panic( |
| | 840 | "A module with the name '{s}' has already been added to the package. Consider creating a private module with std.Build.createModule", |
| | 841 | .{name}, |
| | 842 | ); |
| | 843 | } |
| 834 | return module; | 844 | return module; |
| 835 | } | 845 | } |
| 836 | | 846 | |
| ... | @@ -992,13 +1002,33 @@ pub fn addWriteFile(b: *Build, file_path: []const u8, data: []const u8) *Step.Wr | ... | @@ -992,13 +1002,33 @@ pub fn addWriteFile(b: *Build, file_path: []const u8, data: []const u8) *Step.Wr |
| 992 | pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile { | 1002 | pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile { |
| 993 | const graph = b.graph; | 1003 | const graph = b.graph; |
| 994 | const wf = Step.WriteFile.create(b); | 1004 | const wf = Step.WriteFile.create(b); |
| 995 | b.named_writefiles.put(graph.arena, graph.dupeString(name), wf) catch @panic("OOM"); | 1005 | const gop = b.named_writefiles.getOrPutValue( |
| | 1006 | graph.arena, |
| | 1007 | graph.dupeString(name), |
| | 1008 | wf, |
| | 1009 | ) catch @panic("OOM"); |
| | 1010 | if (gop.found_existing) { |
| | 1011 | panic( |
| | 1012 | "A WriteFile step with the name '{s}' has already been added to the package. Consider creating a private WriteFile step with std.Build.addWriteFiles", |
| | 1013 | .{name}, |
| | 1014 | ); |
| | 1015 | } |
| 996 | return wf; | 1016 | return wf; |
| 997 | } | 1017 | } |
| 998 | | 1018 | |
| 999 | pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void { | 1019 | pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void { |
| 1000 | const graph = b.graph; | 1020 | const graph = b.graph; |
| 1001 | b.named_lazy_paths.put(graph.arena, graph.dupeString(name), lp.dupe(graph)) catch @panic("OOM"); | 1021 | const gop = b.named_lazy_paths.getOrPutValue( |
| | 1022 | graph.arena, |
| | 1023 | graph.dupeString(name), |
| | 1024 | lp.dupe(graph), |
| | 1025 | ) catch @panic("OOM"); |
| | 1026 | if (gop.found_existing) { |
| | 1027 | panic( |
| | 1028 | "A LazyPath with the name '{s}' has already been added to the package.", |
| | 1029 | .{name}, |
| | 1030 | ); |
| | 1031 | } |
| 1002 | } | 1032 | } |
| 1003 | | 1033 | |
| 1004 | /// Creates a step for mutating files inside a temporary directory created lazily | 1034 | /// Creates a step for mutating files inside a temporary directory created lazily |