|
| 1 | +// swift-tools-version:4.0 |
| 2 | + |
| 3 | +import PackageDescription |
| 4 | +import Foundation |
| 5 | + |
| 6 | +// This is a stop gap hack so we can edit benchmarks in Xcode. |
| 7 | +let singleSourceLibraries: [String] = { |
| 8 | + let f = FileManager.`default` |
| 9 | + let dirURL = URL(fileURLWithPath: "single-source").absoluteURL |
| 10 | + let fileURLs = try! f.contentsOfDirectory(at: dirURL, |
| 11 | + includingPropertiesForKeys: nil) |
| 12 | + return fileURLs.flatMap { (path: URL) -> String? in |
| 13 | + let c = path.lastPathComponent.split(separator: ".") |
| 14 | + // Too many components. Must be a gyb file. |
| 15 | + if c.count > 2 { |
| 16 | + return nil |
| 17 | + } |
| 18 | + if c[1] != "swift" { |
| 19 | + return nil |
| 20 | + } |
| 21 | + |
| 22 | + // We do not support this test. |
| 23 | + if c[0] == "ObjectiveCNoBridgingStubs" { |
| 24 | + return nil |
| 25 | + } |
| 26 | + |
| 27 | + assert(c[0] != "PrimsSplit") |
| 28 | + return String(c[0]) |
| 29 | + } |
| 30 | +}() |
| 31 | + |
| 32 | +let multiSourceLibraries: [String] = { |
| 33 | + let f = FileManager.`default` |
| 34 | + let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL |
| 35 | + let fileURLs = try! f.contentsOfDirectory(at: dirURL, |
| 36 | + includingPropertiesForKeys: nil) |
| 37 | + return fileURLs.map { (path: URL) -> String in |
| 38 | + return path.lastPathComponent |
| 39 | + } |
| 40 | +}() |
| 41 | + |
| 42 | +let p = Package( |
| 43 | + name: "swiftbench", |
| 44 | + products: [ |
| 45 | + .library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]), |
| 46 | + .library(name: "DriverUtils", type: .static, targets: ["DriverUtils"]), |
| 47 | + .library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]), |
| 48 | + .executable(name: "SwiftBench", targets: ["SwiftBench"]), |
| 49 | + .library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]) |
| 50 | + ] + singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) } |
| 51 | + + multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }, |
| 52 | + targets: [ |
| 53 | + .target(name: "TestsUtils", |
| 54 | + path: "utils", |
| 55 | + sources: ["TestsUtils.swift"]), |
| 56 | + .target(name: "DriverUtils", |
| 57 | + dependencies: [.target(name: "TestsUtils")], |
| 58 | + path: "utils", |
| 59 | + sources: ["DriverUtils.swift", "ArgParse.swift"]), |
| 60 | + .target(name: "SwiftBench", |
| 61 | + dependencies: [ |
| 62 | + .target(name: "TestsUtils"), |
| 63 | + .target(name: "ObjectiveCTests"), |
| 64 | + .target(name: "DriverUtils"), |
| 65 | + ] + singleSourceLibraries.map { .target(name: $0) } |
| 66 | + + multiSourceLibraries.map { .target(name: $0) }, |
| 67 | + path: "utils", |
| 68 | + sources: ["main.swift"]), |
| 69 | + .target(name: "ObjectiveCTests", |
| 70 | + path: "utils/ObjectiveCTests", |
| 71 | + publicHeadersPath: "."), |
| 72 | + ] + singleSourceLibraries.map { x in |
| 73 | + return .target(name: x, |
| 74 | + dependencies: [ |
| 75 | + .target(name: "TestsUtils"), |
| 76 | + .target(name: "ObjectiveCTests"), |
| 77 | + ], |
| 78 | + path: "single-source", |
| 79 | + sources: ["\(x).swift"]) |
| 80 | + } + multiSourceLibraries.map { x in |
| 81 | + return .target(name: x, |
| 82 | + dependencies: [ |
| 83 | + .target(name: "TestsUtils") |
| 84 | + ], |
| 85 | + path: "multi-source/\(x)") |
| 86 | + }, |
| 87 | + swiftLanguageVersions: [4] |
| 88 | +) |
0 commit comments