-
Notifications
You must be signed in to change notification settings - Fork 0
/
Package.swift
147 lines (135 loc) · 4.04 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
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
// swift-tools-version:5.9
import Foundation
import PackageDescription
// FIXME: make BuildConfigurationurable
#if os(Linux)
let BuildConfiguration = "debug"
#else
let BuildConfiguration = "release"
#endif
let Platform: String
#if os(Linux)
Platform = "linux"
#elseif canImport(Darwin)
Platform = "mac"
#endif
let Architecture: String
#if canImport(Darwin)
Architecture = "x64_arm64"
#elseif arch(x86_64)
Architecture = "x64"
#elseif arch(arm64)
Architecture = "arm64"
#endif
// FIXME: this is clearly not right
let AvdeccBuildDir = "_build_\(Platform)_\(Architecture)_makefiles_\(BuildConfiguration)"
let AvdeccArtifactRoot = ".build/artifacts/avdeccswift/avdecc"
let AvdeccIncludePath = "\(AvdeccArtifactRoot)/include"
let AvdeccCxxLibPath = "\(AvdeccArtifactRoot)/\(AvdeccBuildDir)/src"
let AvdeccCLibPath = "\(AvdeccCxxLibPath)/bindings/c"
let AvdeccCxxControllerLibPath = "\(AvdeccCxxLibPath)/controller"
let AvdeccAltLibPath = "/usr/local/lib"
let AvdeccDebugSuffix = BuildConfiguration == "debug" ? "-d" : ""
var AvdeccLinkerSettings = [LinkerSetting]()
// only necessary on Linux
#if !canImport(Darwin)
AvdeccLinkerSettings += [.linkedLibrary("BlocksRuntime")]
#endif
let AvdeccUnsafeLinkerFlags: [String] = [
"-Xlinker", "-L", "-Xlinker", AvdeccCxxLibPath,
"-Xlinker", "-rpath", "-Xlinker", AvdeccCxxLibPath,
"-Xlinker", "-L", "-Xlinker", AvdeccCLibPath,
"-Xlinker", "-rpath", "-Xlinker", AvdeccCLibPath,
"-Xlinker", "-L", "-Xlinker", AvdeccCxxControllerLibPath,
"-Xlinker", "-rpath", "-Xlinker", AvdeccCxxControllerLibPath,
"-Xlinker", "-L", "-Xlinker", AvdeccAltLibPath,
"-Xlinker", "-rpath", "-Xlinker", AvdeccAltLibPath,
]
let package = Package(
name: "AVDECCSwift",
platforms: [
.macOS(.v13),
],
products: [
.library(
name: "AVDECCSwift",
type: .dynamic, // build dynamic library to comply with LGPL
targets: ["AVDECCSwift"]
),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"),
// .package(url: "https://github.com/lhoward/AsyncExtensions", branch: "linux"),
],
targets: [
.binaryTarget(
name: "avdecc",
path: "avdecc.artifactbundle.zip"
// url: "https://github.com/PADL/AVDECCSwift/raw/main/avdecc.artifactbundle.zip",
// checksum: "8eeb26c186329c7849c18a14837b6d78cea5d9aecb3e7fbb720274869e79a810"
),
.target(
name: "CAVDECC",
dependencies: [
"avdecc",
],
exclude: [
"avdecc/\(AvdeccBuildDir)",
"avdecc/examples",
"avdecc/externals",
"avdecc/resources",
"avdecc/src",
"avdecc/scripts",
"avdecc/tests",
],
cSettings: [
.headerSearchPath("avdecc/include"),
.headerSearchPath("avdecc/externals/nih/include"),
],
cxxSettings: [
.headerSearchPath("avdecc/include"),
.headerSearchPath("avdecc/externals/nih/include"),
],
swiftSettings: [
],
linkerSettings: [
.linkedLibrary("la_avdecc_c\(AvdeccDebugSuffix)"),
.linkedLibrary("la_avdecc_cxx\(AvdeccDebugSuffix)"),
.unsafeFlags(AvdeccUnsafeLinkerFlags),
] + AvdeccLinkerSettings
),
.target(
name: "AVDECCSwift",
dependencies: [
"CAVDECC",
],
cSettings: [
.headerSearchPath("../CAVDECC/avdecc/include"),
.headerSearchPath("../CAVDECC/avdecc/externals/nih/include"),
],
cxxSettings: [
.headerSearchPath("../CAVDECC/avdecc/include"),
.headerSearchPath("../CAVDECC/avdecc/externals/nih/include"),
],
swiftSettings: [
]
),
.executableTarget(
name: "Discovery",
dependencies: [
"AVDECCSwift",
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
],
path: "Examples/Discovery"
),
.testTarget(
name: "AVDECCSwiftTests",
dependencies: [
.target(name: "AVDECCSwift"),
]
),
],
cLanguageStandard: .c17,
cxxLanguageStandard: .cxx17
)