33import PackageDescription
44import Foundation
55
6+ var unsupportedTests : Set < String > = [ " ObjectiveCNoBridgingStubs " ]
7+ #if !os(macOS) && !os(iOS) && !os(watchOS) && !os(tvOS)
8+ unsupportedTests. insert ( " ObjectiveCBridging " )
9+ unsupportedTests. insert ( " ObjectiveCBridgingStubs " )
10+ #endif
11+
612// This is a stop gap hack so we can edit benchmarks in Xcode.
713let singleSourceLibraries : [ String ] = {
814 let f = FileManager . `default`
915 let dirURL = URL ( fileURLWithPath: " single-source " ) . absoluteURL
1016 let fileURLs = try ! f. contentsOfDirectory ( at: dirURL,
1117 includingPropertiesForKeys: nil )
12- return fileURLs. flatMap { ( path: URL ) -> String ? in
18+ return fileURLs. compactMap { ( path: URL ) -> String ? in
1319 let c = path. lastPathComponent. split ( separator: " . " )
1420 // Too many components. Must be a gyb file.
1521 if c. count > 2 {
@@ -19,13 +25,15 @@ let singleSourceLibraries: [String] = {
1925 return nil
2026 }
2127
28+ let s = String ( c [ 0 ] )
29+
2230 // We do not support this test.
23- if c [ 0 ] == " ObjectiveCNoBridgingStubs " {
31+ if unsupportedTests . contains ( s ) {
2432 return nil
2533 }
2634
27- assert ( c [ 0 ] != " PrimsSplit " )
28- return String ( c [ 0 ] )
35+ assert ( s != " PrimsSplit " )
36+ return s
2937 }
3038} ( )
3139
@@ -42,7 +50,9 @@ let multiSourceLibraries: [String] = {
4250var products : [ Product ] = [ ]
4351products. append ( . library( name: " TestsUtils " , type: . static, targets: [ " TestsUtils " ] ) )
4452products. append ( . library( name: " DriverUtils " , type: . static, targets: [ " DriverUtils " ] ) )
53+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
4554products. append ( . library( name: " ObjectiveCTests " , type: . static, targets: [ " ObjectiveCTests " ] ) )
55+ #endif
4656products. append ( . executable( name: " SwiftBench " , targets: [ " SwiftBench " ] ) )
4757products. append ( . library( name: " PrimsSplit " , type: . static, targets: [ " PrimsSplit " ] ) )
4858products += singleSourceLibraries. map { . library( name: $0, type: . static, targets: [ $0] ) }
@@ -56,26 +66,35 @@ targets.append(
5666 dependencies: [ . target( name: " TestsUtils " ) , " LibProc " ] ,
5767 path: " utils " ,
5868 sources: [ " DriverUtils.swift " , " ArgParse.swift " ] ) )
69+
70+ var swiftBenchDeps : [ Target . Dependency ] = [ . target( name: " TestsUtils " ) ]
71+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
72+ swiftBenchDeps. append ( . target( name: " ObjectiveCTests " ) )
73+ #endif
74+ swiftBenchDeps. append ( . target( name: " DriverUtils " ) )
75+ swiftBenchDeps += singleSourceLibraries. map { . target( name: $0) }
76+ swiftBenchDeps += multiSourceLibraries. map { . target( name: $0) }
77+
5978targets. append (
6079 . 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) } ,
80+ dependencies: swiftBenchDeps,
6781 path: " utils " ,
6882 sources: [ " main.swift " ] ) )
83+
84+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
6985targets. append (
7086 . target( name: " ObjectiveCTests " ,
7187 path: " utils/ObjectiveCTests " ,
7288 publicHeadersPath: " . " ) )
89+ #endif
90+
91+ var singleSourceDeps : [ Target . Dependency ] = [ . target( name: " TestsUtils " ) ]
92+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
93+ singleSourceDeps. append ( . target( name: " ObjectiveCTests " ) )
94+ #endif
7395targets += singleSourceLibraries. map { x in
7496 return . target( name: x,
75- dependencies: [
76- . target( name: " TestsUtils " ) ,
77- . target( name: " ObjectiveCTests " ) ,
78- ] ,
97+ dependencies: singleSourceDeps,
7998 path: " single-source " ,
8099 sources: [ " \( x) .swift " ] )
81100}
0 commit comments