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
|
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "swift-sdk-generator",
platforms: [.macOS(.v13)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.executable(
name: "swift-sdk-generator",
targets: ["GeneratorCLI"]
),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "GeneratorCLI",
dependencies: [
"SwiftSDKGenerator",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
]
),
.target(
name: "SwiftSDKGenerator",
dependencies: [
.target(name: "AsyncProcess"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "Logging", package: "swift-log"),
.product(name: "SystemPackage", package: "swift-system"),
"Helpers",
],
exclude: ["Dockerfiles"],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
]
),
.testTarget(
name: "SwiftSDKGeneratorTests",
dependencies: [
"SwiftSDKGenerator",
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
]
),
.testTarget(
name: "GeneratorEngineTests",
dependencies: [
"Helpers",
]
),
.target(
name: "Helpers",
dependencies: [
"SystemSQLite",
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "Logging", package: "swift-log"),
.product(name: "SystemPackage", package: "swift-system"),
],
exclude: ["Vendor/README.md"],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
]
),
.testTarget(
name: "HelpersTests",
dependencies: [
"Helpers",
]
),
.systemLibrary(name: "SystemSQLite", pkgConfig: "sqlite3"),
.target(
name: "AsyncProcess",
dependencies: [
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "Logging", package: "swift-log"),
.product(name: "NIO", package: "swift-nio"),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "SystemPackage", package: "swift-system"),
]
),
.testTarget(
name: "AsyncProcessTests",
dependencies: [
"AsyncProcess",
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.product(name: "Logging", package: "swift-log"),
]
),
],
swiftLanguageVersions: [.v5, .version("6")]
)
struct Configuration {
let useAsyncHttpClient: Bool
let useLocalDependencies: Bool
init(SWIFT_SDK_GENERATOR_DISABLE_AHC: Bool, SWIFTCI_USE_LOCAL_DEPS: Bool) {
self.useAsyncHttpClient = !SWIFT_SDK_GENERATOR_DISABLE_AHC && !SWIFTCI_USE_LOCAL_DEPS
self.useLocalDependencies = SWIFTCI_USE_LOCAL_DEPS
}
}
let configuration = Configuration(
SWIFT_SDK_GENERATOR_DISABLE_AHC: Context.environment["SWIFT_SDK_GENERATOR_DISABLE_AHC"] != nil,
SWIFTCI_USE_LOCAL_DEPS: Context.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil
)
if configuration.useAsyncHttpClient {
package.dependencies.append(
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.19.0")
)
let targetsToAppend: Set<String> = ["SwiftSDKGenerator", "Helpers"]
for target in package.targets.filter({ targetsToAppend.contains($0.name) }) {
target.dependencies.append(
.product(name: "AsyncHTTPClient", package: "async-http-client")
)
}
}
if configuration.useLocalDependencies {
package.dependencies += [
.package(path: "../swift-system"),
.package(path: "../swift-argument-parser"),
.package(path: "../swift-async-algorithms"),
.package(path: "../swift-atomics"),
.package(path: "../swift-collections"),
.package(path: "../swift-crypto"),
.package(path: "../swift-nio"),
.package(path: "../swift-log"),
]
} else {
package.dependencies += [
.package(url: "https://github.com/apple/swift-system", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-async-algorithms.git", exact: "1.0.1"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.2"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.1.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
]
}
|