at main 961 B view raw
1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers 2// 3// SPDX-License-Identifier: MPL-2.0 4 5import Foundation 6import llbuild2fx 7 8extension Keys.SourceTree { 9 struct GetDependencyGraph: BuildKey { 10 let sourceTreeId: LLBDataID 11 12 typealias ValueType = Graph<UnitName> 13 14 static let versionDependencies: [any FXVersioning.Type] = [Keys.SourceTree.GetUnitMap.self, Keys.Blob.ParseImports.self] 15 16 func computeValue(_ ctx: BuildContext<Self>) async throws -> Graph<UnitName> { 17 let unitMap = try await ctx.request(Keys.SourceTree.GetUnitMap(sourceTreeId: sourceTreeId)) 18 var edges: [UnitName: Set<UnitName>] = [:] 19 20 for (unitName, unitInfo) in unitMap.units { 21 if edges[unitName] == nil { edges[unitName] = [] } 22 let imports = try await ctx.request(Keys.Blob.ParseImports(blobId: unitInfo.blobId)) 23 for importedUnitName in imports { 24 edges[unitName]!.insert(importedUnitName) 25 } 26 } 27 28 return Graph(edges: edges) 29 } 30 } 31}