| ... | @@ -90,9 +90,6 @@ modules: std.StringArrayHashMap(*Module), | ... | @@ -90,9 +90,6 @@ modules: std.StringArrayHashMap(*Module), |
| 90 | | 90 | |
| 91 | named_writefiles: std.StringArrayHashMap(*Step.WriteFile), | 91 | named_writefiles: std.StringArrayHashMap(*Step.WriteFile), |
| 92 | named_lazy_paths: std.StringArrayHashMap(LazyPath), | 92 | named_lazy_paths: std.StringArrayHashMap(LazyPath), |
| 93 | /// A map from build root dirs to the corresponding `*Dependency`. This is shared with all child | | |
| 94 | /// `Build`s. | | |
| 95 | initialized_deps: *InitializedDepMap, | | |
| 96 | /// The hash of this instance's package. `""` means that this is the root package. | 93 | /// The hash of this instance's package. `""` means that this is the root package. |
| 97 | pkg_hash: []const u8, | 94 | pkg_hash: []const u8, |
| 98 | /// A mapping from dependency names to package hashes. | 95 | /// A mapping from dependency names to package hashes. |
| ... | @@ -125,6 +122,7 @@ pub const Graph = struct { | ... | @@ -125,6 +122,7 @@ pub const Graph = struct { |
| 125 | host: ResolvedTarget, | 122 | host: ResolvedTarget, |
| 126 | incremental: ?bool = null, | 123 | incremental: ?bool = null, |
| 127 | random_seed: u32 = 0, | 124 | random_seed: u32 = 0, |
| | 125 | dependency_cache: InitializedDepMap = .empty, |
| 128 | }; | 126 | }; |
| 129 | | 127 | |
| 130 | const AvailableDeps = []const struct { []const u8, []const u8 }; | 128 | const AvailableDeps = []const struct { []const u8, []const u8 }; |
| ... | @@ -144,7 +142,7 @@ const SystemLibraryMode = enum { | ... | @@ -144,7 +142,7 @@ const SystemLibraryMode = enum { |
| 144 | declared_enabled, | 142 | declared_enabled, |
| 145 | }; | 143 | }; |
| 146 | | 144 | |
| 147 | const InitializedDepMap = std.HashMap(InitializedDepKey, *Dependency, InitializedDepContext, std.hash_map.default_max_load_percentage); | 145 | const InitializedDepMap = std.HashMapUnmanaged(InitializedDepKey, *Dependency, InitializedDepContext, std.hash_map.default_max_load_percentage); |
| 148 | const InitializedDepKey = struct { | 146 | const InitializedDepKey = struct { |
| 149 | build_root_string: []const u8, | 147 | build_root_string: []const u8, |
| 150 | user_input_options: UserInputOptionsMap, | 148 | user_input_options: UserInputOptionsMap, |
| ... | @@ -252,8 +250,6 @@ pub fn create( | ... | @@ -252,8 +250,6 @@ pub fn create( |
| 252 | available_deps: AvailableDeps, | 250 | available_deps: AvailableDeps, |
| 253 | ) !*Build { | 251 | ) !*Build { |
| 254 | const arena = graph.arena; | 252 | const arena = graph.arena; |
| 255 | const initialized_deps = try arena.create(InitializedDepMap); | | |
| 256 | initialized_deps.* = InitializedDepMap.initContext(arena, .{ .allocator = arena }); | | |
| 257 | | 253 | |
| 258 | const b = try arena.create(Build); | 254 | const b = try arena.create(Build); |
| 259 | b.* = .{ | 255 | b.* = .{ |
| ... | @@ -304,7 +300,6 @@ pub fn create( | ... | @@ -304,7 +300,6 @@ pub fn create( |
| 304 | .modules = .init(arena), | 300 | .modules = .init(arena), |
| 305 | .named_writefiles = .init(arena), | 301 | .named_writefiles = .init(arena), |
| 306 | .named_lazy_paths = .init(arena), | 302 | .named_lazy_paths = .init(arena), |
| 307 | .initialized_deps = initialized_deps, | | |
| 308 | .pkg_hash = "", | 303 | .pkg_hash = "", |
| 309 | .available_deps = available_deps, | 304 | .available_deps = available_deps, |
| 310 | .release_mode = .off, | 305 | .release_mode = .off, |
| ... | @@ -398,7 +393,6 @@ fn createChildOnly( | ... | @@ -398,7 +393,6 @@ fn createChildOnly( |
| 398 | .modules = .init(allocator), | 393 | .modules = .init(allocator), |
| 399 | .named_writefiles = .init(allocator), | 394 | .named_writefiles = .init(allocator), |
| 400 | .named_lazy_paths = .init(allocator), | 395 | .named_lazy_paths = .init(allocator), |
| 401 | .initialized_deps = parent.initialized_deps, | | |
| 402 | .pkg_hash = pkg_hash, | 396 | .pkg_hash = pkg_hash, |
| 403 | .available_deps = pkg_deps, | 397 | .available_deps = pkg_deps, |
| 404 | .release_mode = parent.release_mode, | 398 | .release_mode = parent.release_mode, |
| ... | @@ -2127,10 +2121,10 @@ fn dependencyInner( | ... | @@ -2127,10 +2121,10 @@ fn dependencyInner( |
| 2127 | args: anytype, | 2121 | args: anytype, |
| 2128 | ) *Dependency { | 2122 | ) *Dependency { |
| 2129 | const user_input_options = userInputOptionsFromArgs(b.allocator, args); | 2123 | const user_input_options = userInputOptionsFromArgs(b.allocator, args); |
| 2130 | if (b.initialized_deps.get(.{ | 2124 | if (b.graph.dependency_cache.getContext(.{ |
| 2131 | .build_root_string = build_root_string, | 2125 | .build_root_string = build_root_string, |
| 2132 | .user_input_options = user_input_options, | 2126 | .user_input_options = user_input_options, |
| 2133 | })) |dep| | 2127 | }, .{ .allocator = b.graph.arena })) |dep| |
| 2134 | return dep; | 2128 | return dep; |
| 2135 | | 2129 | |
| 2136 | const build_root: std.Build.Cache.Directory = .{ | 2130 | const build_root: std.Build.Cache.Directory = .{ |
| ... | @@ -2155,10 +2149,10 @@ fn dependencyInner( | ... | @@ -2155,10 +2149,10 @@ fn dependencyInner( |
| 2155 | const dep = b.allocator.create(Dependency) catch @panic("OOM"); | 2149 | const dep = b.allocator.create(Dependency) catch @panic("OOM"); |
| 2156 | dep.* = .{ .builder = sub_builder }; | 2150 | dep.* = .{ .builder = sub_builder }; |
| 2157 | | 2151 | |
| 2158 | b.initialized_deps.put(.{ | 2152 | b.graph.dependency_cache.putContext(b.graph.arena, .{ |
| 2159 | .build_root_string = build_root_string, | 2153 | .build_root_string = build_root_string, |
| 2160 | .user_input_options = user_input_options, | 2154 | .user_input_options = user_input_options, |
| 2161 | }, dep) catch @panic("OOM"); | 2155 | }, dep, .{ .allocator = b.graph.arena }) catch @panic("OOM"); |
| 2162 | return dep; | 2156 | return dep; |
| 2163 | } | 2157 | } |
| 2164 | | 2158 | |