-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPackage.swift
More file actions
105 lines (91 loc) · 3.32 KB
/
Package.swift
File metadata and controls
105 lines (91 loc) · 3.32 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
101
102
103
104
105
// swift-tools-version: 6.0
// (be sure to update the .swift-version file when this Swift version changes)
import PackageDescription
let package = Package(
name: "OSCKit",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13) /* .linux */],
products: [
.library(name: "OSCKitCore", targets: ["OSCKitCore"])
],
dependencies: [
.package(url: "https://github.com/orchetect/swift-ascii", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-numerics", from: "1.1.0")
],
targets: [
.target(
name: "OSCKitCore",
dependencies: [
.product(name: "SwiftASCII", package: "swift-ascii")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.testTarget(
name: "OSCKitCoreTests",
dependencies: [
"OSCKitCore",
.product(name: "Numerics", package: "swift-numerics")
]
)
]
)
// MARK: - OSCKit Networking Layer Target is currently only available on Apple platforms.
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
package.products += [
.library(name: "OSCKit", targets: ["OSCKit"])
]
package.dependencies += [
.package(url: "https://github.com/robbiehanson/CocoaAsyncSocket", from: "7.0.0")
]
package.targets += [
.target(
name: "OSCKit",
dependencies: [
"OSCKitCore",
.product(
name: "CocoaAsyncSocket",
package: "CocoaAsyncSocket",
condition: .when(platforms: [.macOS, .macCatalyst, .iOS, .tvOS, .visionOS, .driverKit])
)
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.testTarget(
name: "OSCKitTests",
dependencies: ["OSCKit"]
)
]
#endif
#if canImport(Foundation) || canImport(CoreFoundation)
#if canImport(Foundation)
import class Foundation.ProcessInfo
func getEnvironmentVar(_ name: String) -> String? {
ProcessInfo.processInfo.environment[name]
}
#elseif canImport(CoreFoundation)
import CoreFoundation
func getEnvironmentVar(_ name: String) -> String? {
guard let rawValue = getenv(name) else { return nil }
return String(utf8String: rawValue)
}
#endif
func isEnvironmentVarTrue(_ name: String) -> Bool {
guard let value = getEnvironmentVar(name)?
.trimmingCharacters(in: .whitespacesAndNewlines)
else { return false }
return ["true", "yes", "1"].contains(value.lowercased())
}
// MARK: - DocC Dependency
/// Conditionally opt-in to Swift DocC Plugin when an environment flag is present.
if isEnvironmentVarTrue("ENABLE_DOCC_PLUGIN") {
package.dependencies += [
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.5")
]
}
// MARK: - CI Pipeline
if isEnvironmentVarTrue("GITHUB_ACTIONS") {
for target in package.targets.filter(\.isTest) {
if target.swiftSettings == nil { target.swiftSettings = [] }
target.swiftSettings? += [.define("GITHUB_ACTIONS", .when(configuration: .debug))]
}
}
#endif