File tree Expand file tree Collapse file tree 6 files changed +36
-22
lines changed Expand file tree Collapse file tree 6 files changed +36
-22
lines changed Original file line number Diff line number Diff line change @@ -681,9 +681,7 @@ package.targets.append(contentsOf: [
681
681
. testTarget(
682
682
name: " FunctionalPerformanceTests " ,
683
683
dependencies: [
684
- " swift-build " ,
685
- " swift-package " ,
686
- " swift-test " ,
684
+ " swift-package-manager " ,
687
685
" SPMTestSupport "
688
686
]
689
687
) ,
@@ -695,9 +693,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] ==
695
693
. testTarget(
696
694
name: " FunctionalTests " ,
697
695
dependencies: [
698
- " swift-build " ,
699
- " swift-package " ,
700
- " swift-test " ,
696
+ " swift-package-manager " ,
701
697
" PackageModel " ,
702
698
" SPMTestSupport "
703
699
]
@@ -713,10 +709,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] ==
713
709
. testTarget(
714
710
name: " CommandsTests " ,
715
711
dependencies: [
716
- " swift-build " ,
717
- " swift-package " ,
718
- " swift-test " ,
719
- " swift-run " ,
712
+ " swift-package-manager " ,
720
713
" Basics " ,
721
714
" Build " ,
722
715
" Commands " ,
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ struct BuildToolOptions: ParsableArguments {
95
95
}
96
96
97
97
/// swift-build tool namespace
98
- public struct SwiftBuildTool : SwiftCommand {
98
+ public struct SwiftBuildTool : AsyncSwiftCommand {
99
99
public static var configuration = CommandConfiguration (
100
100
commandName: " build " ,
101
101
_superCommandName: " swift " ,
@@ -110,7 +110,7 @@ public struct SwiftBuildTool: SwiftCommand {
110
110
@OptionGroup ( )
111
111
var options : BuildToolOptions
112
112
113
- public func run( _ swiftTool: SwiftTool ) throws {
113
+ public func run( _ swiftTool: SwiftTool ) async throws {
114
114
if options. shouldPrintBinPath {
115
115
return try print ( swiftTool. productsBuildParameters. buildPath. description)
116
116
}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public enum SwiftPM {
29
29
30
30
extension SwiftPM {
31
31
/// Executable name.
32
- private var executableName : RelativePath {
32
+ private var executableName : String {
33
33
switch self {
34
34
case . Build:
35
35
return " swift-build "
@@ -45,7 +45,7 @@ extension SwiftPM {
45
45
}
46
46
47
47
public var xctestBinaryPath : AbsolutePath {
48
- Self . xctestBinaryPath ( for: executableName )
48
+ Self . xctestBinaryPath ( for: RelativePath ( " swift-package-manager " ) )
49
49
}
50
50
51
51
public static func xctestBinaryPath( for executableName: RelativePath ) -> AbsolutePath {
@@ -114,11 +114,12 @@ extension SwiftPM {
114
114
#endif
115
115
// FIXME: We use this private environment variable hack to be able to
116
116
// create special conditions in swift-build for swiftpm tests.
117
- environment [ " SWIFTPM_TESTS_MODULECACHE " ] = xctestBinaryPath. parentDirectory. pathString
118
-
117
+ environment [ " SWIFTPM_TESTS_MODULECACHE " ] = self . xctestBinaryPath. parentDirectory. pathString
118
+
119
119
// Unset the internal env variable that allows skipping certain tests.
120
120
environment [ " _SWIFTPM_SKIP_TESTS_LIST " ] = nil
121
-
121
+ environment [ " SWIFTPM_EXEC_NAME " ] = self . executableName
122
+
122
123
for (key, value) in env ?? [ : ] {
123
124
environment [ key] = value
124
125
}
Original file line number Diff line number Diff line change 7
7
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8
8
9
9
add_executable (swift-build
10
- main .swift )
10
+ Entrypoint .swift )
11
11
target_link_libraries (swift-build PRIVATE
12
12
Commands )
13
13
14
+ target_compile_options (swift-build PRIVATE
15
+ -parse-as-library )
16
+
14
17
install (TARGETS swift-build
15
18
DESTINATION bin )
Original file line number Diff line number Diff line change 12
12
13
13
import Commands
14
14
15
- SwiftBuildTool . main ( )
15
+ @main
16
+ struct Entrypoint {
17
+ static func main( ) async {
18
+ await SwiftBuildTool . main ( )
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -17,17 +17,22 @@ import PackageCollectionsTool
17
17
import PackageRegistryTool
18
18
19
19
let firstArg = CommandLine . arguments [ 0 ]
20
- let execName = ( try ? AbsolutePath ( validating: firstArg) . basenameWithoutExt) ??
20
+ let baseNameWithoutExtension = ( try ? AbsolutePath ( validating: firstArg) . basenameWithoutExt) ??
21
21
( try ? RelativePath ( validating: firstArg) . basenameWithoutExt)
22
22
23
23
@main
24
24
struct SwiftPM {
25
25
static func main( ) async {
26
+ await main ( execName: baseNameWithoutExtension)
27
+ }
28
+
29
+ @discardableResult
30
+ private static func main( execName: String ? ) async -> Bool {
26
31
switch execName {
27
32
case " swift-package " :
28
33
await SwiftPackageTool . main ( )
29
34
case " swift-build " :
30
- SwiftBuildTool . main ( )
35
+ await SwiftBuildTool . main ( )
31
36
case " swift-experimental-sdk " :
32
37
await SwiftSDKTool . main ( )
33
38
case " swift-test " :
@@ -39,7 +44,14 @@ struct SwiftPM {
39
44
case " swift-package-registry " :
40
45
await SwiftPackageRegistryTool . main ( )
41
46
default :
42
- fatalError ( " swift-package-manager launched with unexpected name: \( execName ?? " (unknown) " ) " )
47
+ // Workaround a bug in Swift 5.9, where multiple executables with an `async` main entrypoint can't be linked
48
+ // into the same test bundle. We're then linking single `swift-package-manager` binary instead and passing
49
+ // executable name via `SWIFTPM_EXEC_NAME`.
50
+ if await !main( execName: EnvironmentVariables . process ( ) [ " SWIFTPM_EXEC_NAME " ] ) {
51
+ fatalError ( " swift-package-manager launched with unexpected name: \( execName ?? " (unknown) " ) " )
52
+ }
43
53
}
54
+
55
+ return true
44
56
}
45
57
}
You can’t perform that action at this time.
0 commit comments