-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPackage.swift
More file actions
100 lines (90 loc) · 3.37 KB
/
Copy pathPackage.swift
File metadata and controls
100 lines (90 loc) · 3.37 KB
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
// swift-tools-version: 6.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2026 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import PackageDescription
// Availability Macros
let availabilityTags: [_Availability] = [
_Availability("SwiftTLS"),
]
let versionNumbers = ["0.1.0"]
// Availability Macro Utilities
enum _OSAvailability: String {
// The OS versions in which `SwiftTLS 0.1.0` APIs first became available.
case alwaysAvailable = "macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26"
// Use 10000 for future availability to avoid compiler magic around the 9999 version number but ensure it is greater than 9999"
case future = "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000, visionOS 10000"
}
struct _Availability {
let name: String
let osAvailability: _OSAvailability
init(_ name: String, osAvailability: _OSAvailability = .alwaysAvailable) {
self.name = name
self.osAvailability = osAvailability
}
}
let availabilityMacros: [SwiftSetting] = versionNumbers.flatMap { version in
availabilityTags.map {
.enableExperimentalFeature("AvailabilityMacro=\($0.name) \(version):\($0.osAvailability.rawValue)")
}
}
var packageDependencies = [PackageDescription.Package.Dependency]()
var targetDependencies = [PackageDescription.Target.Dependency]()
var settings: [SwiftSetting]? = [
// Add build settings here
.enableExperimentalFeature("Lifetimes"),
]
#if os(Linux)
packageDependencies = [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "5.0.0-beta.1"),
]
targetDependencies = [
.product(name: "Logging", package: "swift-log"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "CryptoExtras", package: "swift-crypto"),
]
#else
packageDependencies = [
.package(url: "https://github.com/apple/swift-crypto.git", from: "5.0.0-beta.1")
]
targetDependencies = [
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "CryptoExtras", package: "swift-crypto"),
]
#endif
let package = Package(
name: "swift-tls",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "SwiftTLS",
targets: ["SwiftTLS"]),
],
dependencies: packageDependencies,
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "SwiftTLS",
dependencies: targetDependencies,
swiftSettings: availabilityMacros + (settings ?? [])
),
.testTarget(
name: "SwiftTLSTests",
dependencies: ["SwiftTLS"],
swiftSettings: availabilityMacros + (settings ?? [])
),
]
)