File: PackageDescriptionSerialization.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (283 lines) | stat: -rw-r--r-- 7,461 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2023 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
//
//===----------------------------------------------------------------------===//

#if USE_IMPL_ONLY_IMPORTS
@_implementationOnly import Foundation
#else
import Foundation
#endif

enum Serialization {
    // MARK: - build settings serialization

    struct BuildConfiguration: Codable {
        let config: String
    }

    struct BuildSettingCondition: Codable {
        let platforms: [Platform]?
        let config: BuildConfiguration?
    }

    struct BuildSettingData: Codable {
        let name: String
        let value: [String]
        let condition: BuildSettingCondition?
    }

    struct CSetting: Codable {
        let data: BuildSettingData
    }

    struct CXXSetting: Codable {
        let data: BuildSettingData
    }

    struct SwiftSetting: Codable {
        let data: BuildSettingData
    }

    struct LinkerSetting: Codable {
        let data: BuildSettingData
    }

    // MARK: - language standards serialization

    enum CLanguageStandard: String, Codable {
        case c89
        case c90
        case c99
        case c11
        case c17
        case c18
        case c2x
        case gnu89
        case gnu90
        case gnu99
        case gnu11
        case gnu17
        case gnu18
        case gnu2x
        case iso9899_1990 = "iso9899:1990"
        case iso9899_199409 = "iso9899:199409"
        case iso9899_1999 = "iso9899:1999"
        case iso9899_2011 = "iso9899:2011"
        case iso9899_2017 = "iso9899:2017"
        case iso9899_2018 = "iso9899:2018"
    }

    enum CXXLanguageStandard: String, Codable {
        case cxx98 = "c++98"
        case cxx03 = "c++03"
        case cxx11 = "c++11"
        case cxx14 = "c++14"
        case cxx17 = "c++17"
        case cxx1z = "c++1z"
        case cxx20 = "c++20"
        case cxx2b = "c++2b"
        case gnucxx98 = "gnu++98"
        case gnucxx03 = "gnu++03"
        case gnucxx11 = "gnu++11"
        case gnucxx14 = "gnu++14"
        case gnucxx17 = "gnu++17"
        case gnucxx1z = "gnu++1z"
        case gnucxx20 = "gnu++20"
        case gnucxx2b = "gnu++2b"
    }

    enum SwiftVersion: Codable {
        case v3
        case v4
        case v4_2
        case v5
        case v6
        case version(String)
    }

    // MARK: - version serialization

    struct Version: Codable {
        let major: Int
        let minor: Int
        let patch: Int
        let prereleaseIdentifiers: [String]
        let buildMetadataIdentifiers: [String]
    }

    // MARK: - package dependency serialization

    struct PackageDependency: Codable {
        enum SourceControlRequirement: Codable {
            case exact(Version)
            case range(lowerBound: Version, upperBound: Version)
            case revision(String)
            case branch(String)
        }

        enum RegistryRequirement: Codable {
            case exact(Version)
            case range(lowerBound: Version, upperBound: Version)
        }

        enum Kind: Codable {
            case fileSystem(name: String?, path: String)
            case sourceControl(name: String?, location: String, requirement: SourceControlRequirement)
            case registry(id: String, requirement: RegistryRequirement)
        }

        let kind: Kind
        let moduleAliases: [String: String]?
    }

    // MARK: - platforms serialization

    struct Platform: Codable {
        let name: String
    }

    struct SupportedPlatform: Codable {
        let platform: Platform
        let version: String?
    }

    // MARK: - target serialization

    enum TargetDependency: Codable {
        struct Condition: Codable {
            let platforms: [Platform]?
        }

        case target(name: String, condition: Condition?)
        case product(name: String, package: String?, moduleAliases: [String: String]?, condition: Condition?)
        case byName(name: String, condition: Condition?)
    }

    enum TargetType: Codable {
        case regular
        case executable
        case test
        case system
        case binary
        case plugin
        case `macro`
    }

    enum PluginCapability: Codable {
        case buildTool
        case command(intent: PluginCommandIntent, permissions: [PluginPermission])
    }

    enum PluginCommandIntent: Codable {
        case documentationGeneration
        case sourceCodeFormatting
        case custom(verb: String, description: String)
    }

    enum PluginPermission: Codable {
        case allowNetworkConnections(scope: PluginNetworkPermissionScope, reason: String)
        case writeToPackageDirectory(reason: String)
    }

    enum PluginNetworkPermissionScope: Codable {
        case none
        case local(ports: [Int])
        case all(ports: [Int])
        case docker
        case unixDomainSocket
    }

    enum PluginUsage: Codable {
        case plugin(name: String, package: String?)
    }

    struct Target: Codable {
        let name: String
        let path: String?
        let url: String?
        let sources: [String]?
        let resources: [Resource]?
        let exclude: [String]
        let dependencies: [TargetDependency]
        let publicHeadersPath: String?
        let type: TargetType
        let packageAccess: Bool
        let pkgConfig: String?
        let providers: [SystemPackageProvider]?
        let pluginCapability: PluginCapability?
        let cSettings: [CSetting]?
        let cxxSettings: [CXXSetting]?
        let swiftSettings: [SwiftSetting]?
        let linkerSettings: [LinkerSetting]?
        let checksum: String?
        let pluginUsages: [PluginUsage]?
    }

    // MARK: - resource serialization

    struct Resource: Codable {
        enum Localization: String, Codable {
            case `default`
            case base
        }

        let rule: String
        let path: String
        let localization: Localization?
    }

    // MARK: - product serialization

    struct Product: Codable {
        enum ProductType: Codable {
            enum LibraryType: Codable {
                case automatic
                case dynamic
                case `static`
            }

            case executable
            case library(type: LibraryType)
            case plugin
        }

        let name: String
        let targets: [String]
        let productType: ProductType
    }

    // MARK: - package serialization

    struct LanguageTag: Codable {
        let tag: String
    }

    enum SystemPackageProvider: Codable {
        case brew([String])
        case apt([String])
        case yum([String])
        case nuget([String])
    }

    struct Package: Codable {
        let name: String
        let platforms: [SupportedPlatform]?
        let defaultLocalization: LanguageTag?
        let pkgConfig: String?
        let providers: [SystemPackageProvider]?
        let targets: [Target]
        let products: [Product]
        let dependencies: [PackageDependency]
        let swiftLanguageVersions: [SwiftVersion]?
        let cLanguageStandard: CLanguageStandard?
        let cxxLanguageStandard: CXXLanguageStandard?
    }
}