Files
swift-mirror/benchmark/Package.swift
Michael Gottesman 0a70ec336a [benchmark] Add swiftpm support for the benchmark suite.
This means that we can now edit benchmarks in Xcode! Keep in mind:

1. This is not an official build. It is just so we can use Xcode to edit files
and get IDE features.
2. I had to do a little hackery to keep the build the way it is today where all
single-source files are their own modules.
3. As long as we do not change the directory structure, everything should just
update and work since I added a little code that dynamically adds the tests.

Also, to do this I had to rename multi-source/PrimsSplit/main.swift =>
Prims_main.swift. That is because the name main.swift is special in some way and
I hit linker errors. By simply changing the name from main.swift =>
Prims_main.swift, everything is good. I am going to file a separate bug for
that.
2018-06-03 23:50:27 -07:00

89 lines
2.9 KiB
Swift

// swift-tools-version:4.0
import PackageDescription
import Foundation
// This is a stop gap hack so we can edit benchmarks in Xcode.
let singleSourceLibraries: [String] = {
let f = FileManager.`default`
let dirURL = URL(fileURLWithPath: "single-source").absoluteURL
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
includingPropertiesForKeys: nil)
return fileURLs.flatMap { (path: URL) -> String? in
let c = path.lastPathComponent.split(separator: ".")
// Too many components. Must be a gyb file.
if c.count > 2 {
return nil
}
if c[1] != "swift" {
return nil
}
// We do not support this test.
if c[0] == "ObjectiveCNoBridgingStubs" {
return nil
}
assert(c[0] != "PrimsSplit")
return String(c[0])
}
}()
let multiSourceLibraries: [String] = {
let f = FileManager.`default`
let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
includingPropertiesForKeys: nil)
return fileURLs.map { (path: URL) -> String in
return path.lastPathComponent
}
}()
let p = Package(
name: "swiftbench",
products: [
.library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]),
.library(name: "DriverUtils", type: .static, targets: ["DriverUtils"]),
.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]),
.executable(name: "SwiftBench", targets: ["SwiftBench"]),
.library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"])
] + singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
+ multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) },
targets: [
.target(name: "TestsUtils",
path: "utils",
sources: ["TestsUtils.swift"]),
.target(name: "DriverUtils",
dependencies: [.target(name: "TestsUtils")],
path: "utils",
sources: ["DriverUtils.swift", "ArgParse.swift"]),
.target(name: "SwiftBench",
dependencies: [
.target(name: "TestsUtils"),
.target(name: "ObjectiveCTests"),
.target(name: "DriverUtils"),
] + singleSourceLibraries.map { .target(name: $0) }
+ multiSourceLibraries.map { .target(name: $0) },
path: "utils",
sources: ["main.swift"]),
.target(name: "ObjectiveCTests",
path: "utils/ObjectiveCTests",
publicHeadersPath: "."),
] + singleSourceLibraries.map { x in
return .target(name: x,
dependencies: [
.target(name: "TestsUtils"),
.target(name: "ObjectiveCTests"),
],
path: "single-source",
sources: ["\(x).swift"])
} + multiSourceLibraries.map { x in
return .target(name: x,
dependencies: [
.target(name: "TestsUtils")
],
path: "multi-source/\(x)")
},
swiftLanguageVersions: [4]
)