File: DependencyGraphMessages.swift

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (110 lines) | stat: -rw-r--r-- 4,989 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

public import SWBUtil

public struct ComputeDependencyGraphRequest: SessionMessage, RequestMessage, SerializableCodable, Equatable {
    public typealias ResponseMessage = DependencyGraphResponse

    public static let name = "COMPUTE_DEPENDENCY_GRAPH_REQUEST"

    public let sessionHandle: String
    public let targetGUIDs: [TargetGUID]
    public let buildParameters: BuildParametersMessagePayload
    public let includeImplicitDependencies: Bool
    public let dependencyScope: DependencyScopeMessagePayload

    public init(sessionHandle: String, targetGUIDs: [TargetGUID], buildParameters: BuildParametersMessagePayload, includeImplicitDependencies: Bool, dependencyScope: DependencyScopeMessagePayload) {
        self.sessionHandle = sessionHandle
        self.targetGUIDs = targetGUIDs
        self.buildParameters = buildParameters
        self.includeImplicitDependencies = includeImplicitDependencies
        self.dependencyScope = dependencyScope
    }

    enum CodingKeys: CodingKey {
        case sessionHandle
        case targetGUIDs
        case buildParameters
        case includeImplicitDependencies
        case dependencyScope
    }

    public init(from decoder: any Decoder) throws {
        let container: KeyedDecodingContainer<ComputeDependencyGraphRequest.CodingKeys> = try decoder.container(keyedBy: ComputeDependencyGraphRequest.CodingKeys.self)

        self.sessionHandle = try container.decode(String.self, forKey: ComputeDependencyGraphRequest.CodingKeys.sessionHandle)
        self.targetGUIDs = try container.decode([TargetGUID].self, forKey: ComputeDependencyGraphRequest.CodingKeys.targetGUIDs)
        self.buildParameters = try container.decode(BuildParametersMessagePayload.self, forKey: ComputeDependencyGraphRequest.CodingKeys.buildParameters)
        self.includeImplicitDependencies = try container.decode(Bool.self, forKey: ComputeDependencyGraphRequest.CodingKeys.includeImplicitDependencies)
        self.dependencyScope = try container.decodeIfPresent(DependencyScopeMessagePayload.self, forKey: ComputeDependencyGraphRequest.CodingKeys.dependencyScope) ?? .workspace

    }

    public func encode(to encoder: any Encoder) throws {
        var container: KeyedEncodingContainer<ComputeDependencyGraphRequest.CodingKeys> = encoder.container(keyedBy: ComputeDependencyGraphRequest.CodingKeys.self)

        try container.encode(self.sessionHandle, forKey: ComputeDependencyGraphRequest.CodingKeys.sessionHandle)
        try container.encode(self.targetGUIDs, forKey: ComputeDependencyGraphRequest.CodingKeys.targetGUIDs)
        try container.encode(self.buildParameters, forKey: ComputeDependencyGraphRequest.CodingKeys.buildParameters)
        try container.encode(self.includeImplicitDependencies, forKey: ComputeDependencyGraphRequest.CodingKeys.includeImplicitDependencies)
        try container.encode(self.dependencyScope, forKey: ComputeDependencyGraphRequest.CodingKeys.dependencyScope)
    }
}

public struct DependencyGraphResponse: Message, SerializableCodable, Equatable {
    public static let name = "DEPENDENCY_GRAPH_RESPONSE"

    public let adjacencyList: [TargetGUID: [TargetGUID]]

    public init(adjacencyList: [TargetGUID: [TargetGUID]]) {
        self.adjacencyList = adjacencyList
    }
}


// MARK: Getting declared dependency info


public struct DumpBuildDependencyInfoRequest: SessionChannelBuildMessage, RequestMessage, SerializableCodable, Equatable {
    public typealias ResponseMessage = VoidResponse
    
    public static let name = "DUMP_BUILD_DEPENDENCY_INFO_REQUEST"

    /// The identifier for the session to initiate the request in.
    public let sessionHandle: String

    /// The channel to communicate with the client on.
    public let responseChannel: UInt64

    /// The request to use to compute the build dependency info to dump.
    public let request: BuildRequestMessagePayload

    /// The path to which the build dependency info should be dumped.
    public let outputPath: String

    public init(sessionHandle: String, responseChannel: UInt64, request: BuildRequestMessagePayload, outputPath: String) {
        self.sessionHandle = sessionHandle
        self.responseChannel = responseChannel
        self.request = request
        self.outputPath = outputPath
    }
}


// MARK: Registering messages

let dependencyGraphMessageTypes: [any Message.Type] = [
    ComputeDependencyGraphRequest.self,
    DependencyGraphResponse.self,
    DumpBuildDependencyInfoRequest.self,
]