 unsupportedTests.insert("ObjectiveCBridgingStubs")
 #endif
 
-// This is a stop gap hack so we can edit benchmarks in Xcode.
-let singleSourceLibraries: [String] = {
+//===---
+// Single Source Libraries
+//
+
+/// Return the source files in subDirectory that we will translate into
+/// libraries. Each source library will be compiled as its own module.
+func getSingleSourceLibraries(subDirectory: String) -> [String] {
   let f = FileManager.`default`
-  let dirURL = URL(fileURLWithPath: "single-source").absoluteURL
+  let dirURL = URL(fileURLWithPath: subDirectory)
   let fileURLs = try! f.contentsOfDirectory(at: dirURL,
                                             includingPropertiesForKeys: nil)
   return fileURLs.compactMap { (path: URL) -> String? in

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
singleSourceDeps.append(.target(name: "ObjectiveCTests"))
#endif
targets += singleSourceLibraries.map { x in
    return .target(name: x,
      dependencies: singleSourceDeps,
      path: "single-source",
      sources: ["\(x).swift"])
}
targets += multiSourceLibraries.map { x in
  return .target(name: x,
    dependencies: [
      .target(name: "TestsUtils")
    ],
    path: "multi-source/\(x)")
}

let p = Package(
  name: "swiftbench",

products.append(.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]))
#endif
products.append(.executable(name: "SwiftBench", targets: ["SwiftBench"]))

products += singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
products += multiSourceLibraries.map {
  return .library(name: $0.name, type: .static, targets: [$0.name])
}

//===---
// Targets
//

var targets: [Target] = []
targets.append(.target(name: "TestsUtils", path: "utils", sources: ["TestsUtils.swift"]))
