-
Notifications
You must be signed in to change notification settings - Fork 12
/
Package.swift
67 lines (60 loc) · 3.01 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
// swift-tools-version:5.7
import PackageDescription
#if os(macOS)
import Foundation
let process = Process()
process.launchPath = "/usr/bin/xcode-select"
process.arguments = ["-p"]
let pipe = Pipe()
process.standardOutput = pipe
process.launch()
process.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let XcodePath = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .newlines)
let indexLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-L\(XcodePath)/Toolchains/XcodeDefault.xctoolchain/usr/lib"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "\(XcodePath)/Toolchains/XcodeDefault.xctoolchain/usr/lib"]),
]
let swiftDemangleLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "\(XcodePath)/Toolchains/XcodeDefault.xctoolchain/usr/lib"]),
// This is a hack to get Xcode's version instead of the system installed version
.unsafeFlags(["-Xlinker", "-force_load", "-Xlinker", "\(XcodePath)/Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib"]),
]
#else
let indexLinkerSettings: [LinkerSetting] = []
let swiftDemangleLinkerSettings: [LinkerSetting] = [.linkedLibrary("swiftDemangle")]
#endif
let package = Package(
name: "IndexStore",
platforms: [
.macOS(.v13),
],
products: [
.library(name: "IndexStore", targets: ["IndexStore"]),
.library(name: "CSwiftDemangle", targets: ["CSwiftDemangle"]),
.library(name: "SwiftDemangle", targets: ["SwiftDemangle"]),
.executable(name: "indexutil-export", targets: ["indexutil-export"]),
.executable(name: "unnecessary-testable", targets: ["unnecessary-testable"]),
.executable(name: "unused-imports", targets: ["unused-imports"]),
.executable(name: "indexutil-annotate", targets: ["indexutil-annotate"]),
.executable(name: "tycat", targets: ["tycat"]),
],
targets: [
.target(name: "CIndexStore"),
.target(name: "IndexStore", dependencies: ["CIndexStore"], linkerSettings: indexLinkerSettings),
.testTarget(name: "IndexStoreTests", dependencies: ["IndexStore"], exclude: ["BUILD", "Data"]),
.target(
name: "CSwiftDemangle",
cxxSettings: [.headerSearchPath("PrivateHeaders/include")],
linkerSettings: swiftDemangleLinkerSettings
),
.target(name: "SwiftDemangle", dependencies: ["CSwiftDemangle"]),
.testTarget(name: "SwiftDemangleTests", dependencies: ["SwiftDemangle"], exclude: ["BUILD"]),
.executableTarget(name: "indexutil-export", dependencies: ["IndexStore"], exclude: ["BUILD"]),
.executableTarget(name: "unnecessary-testable", dependencies: ["IndexStore"], exclude: ["BUILD"]),
.executableTarget(name: "unused-imports", dependencies: ["IndexStore"], exclude: ["BUILD"]),
.executableTarget(name: "indexutil-annotate", dependencies: ["IndexStore"], exclude: ["BUILD"]),
.executableTarget(name: "tycat", dependencies: ["IndexStore"], exclude: ["BUILD"]),
],
cxxLanguageStandard: .cxx17
)