-
Notifications
You must be signed in to change notification settings - Fork 1
/
Package.swift
53 lines (47 loc) · 1.36 KB
/
Package.swift
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
// swift-tools-version: 6.0
import PackageDescription
func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
guard let value = Context.environment[key] else {
return defaultValue
}
if value == "1" {
return true
} else if value == "0" {
return false
} else {
return defaultValue
}
}
let testTarget = Target.testTarget(name: "ProtobufKitTests")
let compatibilityTestCondition = envEnable("PROTOBUFKIT_SWIFTUI_COMPATIBILITY_TEST")
if compatibilityTestCondition {
var swiftSettings: [SwiftSetting] = (testTarget.swiftSettings ?? [])
swiftSettings.append(.define("PROTOBUFKIT_SWIFTUI_COMPATIBILITY_TEST"))
testTarget.swiftSettings = swiftSettings
} else {
testTarget.dependencies.append("ProtobufKit")
}
let libraryType: Product.Library.LibraryType?
switch Context.environment["PROTOBUFKIT_LIBRARY_TYPE"] {
case "dynamic":
libraryType = .dynamic
case "static":
libraryType = .static
default:
libraryType = nil
}
let package = Package(
name: "ProtobufKit",
products: [
.library(name: "ProtobufKit", type: libraryType, targets: ["ProtobufKit"]),
],
targets: [
.target(
name: "ProtobufKit",
swiftSettings: [
.enableUpcomingFeature("InternalImportsByDefault"),
]
),
testTarget,
]
)