-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPackage.swift
100 lines (96 loc) · 2.86 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
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: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import Foundation
import PackageDescription
func tryGuessSwiftLibRoot() -> String {
let task = Process()
task.executableURL = URL(fileURLWithPath: "/bin/sh")
task.arguments = ["-c", "which swift"]
task.standardOutput = Pipe()
do {
try task.run()
let outputData = (task.standardOutput as! Pipe).fileHandleForReading.readDataToEndOfFile()
let path = URL(fileURLWithPath: String(decoding: outputData, as: UTF8.self))
return path.deletingLastPathComponent().path + "/../lib/swift"
} catch {
return "/usr/lib/swift"
}
}
let SwiftLibRoot = tryGuessSwiftLibRoot()
let package = Package(
name: "LinuxHalSwiftIO",
platforms: [
// specify each minimum deployment requirement,
// otherwise the platform default minimum is used.
.macOS(.v10_15),
],
products: [
// Products define the executables and libraries a package produces, and make them visible
// to other packages.
.library(
name: "LinuxHalSwiftIO",
targets: ["LinuxHalSwiftIO"]
),
.library(
name: "AsyncSwiftIO",
targets: ["AsyncSwiftIO"]
),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/madmachineio/SwiftIO", from: "0.1.0"),
.package(url: "https://github.com/PADL/IORingSwift", from: "0.1.5"),
.package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"),
.package(url: "https://github.com/lhoward/AsyncExtensions", from: "0.9.0"),
.package(url: "https://github.com/apple/swift-system", from: "1.0.0"),
],
targets: [
.target(
name: "LinuxHalSwiftIO",
dependencies: [
.product(name: "CSwiftIO", package: "SwiftIO"),
],
linkerSettings: [
.linkedLibrary("gpiod", .when(platforms: [.linux])),
]
),
.target(
name: "AsyncSwiftIO",
dependencies: [
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "SystemPackage", package: "swift-system"),
"AsyncExtensions",
.product(name: "SwiftIO", package: "SwiftIO"),
"LinuxHalSwiftIO",
.product(
name: "IORing",
package: "IORingSwift",
condition: .when(platforms: [.linux])
),
]
),
.executableTarget(
name: "SPIMonitor",
dependencies: [
"AsyncSwiftIO",
"SwiftIO",
],
path: "Examples/SPIMonitor"
),
.executableTarget(
name: "UARTMonitor",
dependencies: [
"AsyncSwiftIO",
"SwiftIO",
],
path: "Examples/UARTMonitor"
),
.testTarget(
name: "LinuxHalSwiftIOTests",
dependencies: [
.target(name: "LinuxHalSwiftIO"),
.target(name: "AsyncSwiftIO"),
]
),
]
)