Skip to content

Commit 13c7989

Browse files
committed
cleanup
1 parent ca7a313 commit 13c7989

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,14 @@ public final class ManifestLoader: ManifestLoaderProtocol {
695695
let macOSPackageDescriptionPath: AbsolutePath
696696
// if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
697697
// which produces a framework for dynamic package products.
698-
if runtimePath.basename == "PackageFrameworks" {
698+
if runtimePath.extension == "framework" {
699699
cmd += [
700-
"-F", runtimePath.pathString,
700+
"-F", runtimePath.parentDirectory.pathString,
701701
"-framework", "PackageDescription",
702-
"-Xlinker", "-rpath", "-Xlinker", runtimePath.pathString,
702+
"-Xlinker", "-rpath", "-Xlinker", runtimePath.parentDirectory.pathString,
703703
]
704704

705-
macOSPackageDescriptionPath = runtimePath.appending(RelativePath("PackageDescription.framework/PackageDescription"))
705+
macOSPackageDescriptionPath = runtimePath.appending(component: "PackageDescription")
706706
} else {
707707
cmd += [
708708
"-L", runtimePath.pathString,
@@ -715,7 +715,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
715715
#endif
716716

717717
// note: this is not correct for all platforms, but we only actually use it on macOS.
718-
macOSPackageDescriptionPath = runtimePath.appending(RelativePath("libPackageDescription.dylib"))
718+
macOSPackageDescriptionPath = runtimePath.appending(component: "libPackageDescription.dylib")
719719
}
720720

721721
// Use the same minimum deployment target as the PackageDescription library (with a fallback of 10.15).
@@ -854,8 +854,8 @@ public final class ManifestLoader: ManifestLoaderProtocol {
854854
cmd += ["-swift-version", toolsVersion.swiftLanguageVersion.rawValue]
855855
// if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
856856
// which produces a framework for dynamic package products.
857-
if runtimePath.basename == "PackageFrameworks" {
858-
cmd += ["-I", runtimePath.parentDirectory.pathString]
857+
if runtimePath.extension == "framework" {
858+
cmd += ["-I", runtimePath.parentDirectory.parentDirectory.pathString]
859859
} else {
860860
cmd += ["-I", runtimePath.pathString]
861861
}

Sources/PackageModel/ToolchainConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension ToolchainConfiguration {
9595
)
9696
}
9797

98-
fileprivate init(swiftCompilerPath: AbsolutePath) {
98+
public init(swiftCompilerPath: AbsolutePath) {
9999
let rootPath = swiftCompilerPath.parentDirectory.parentDirectory.appending(components: "lib", "swift", "pm")
100100
self.init(root: rootPath)
101101
}

Sources/Workspace/DefaultPluginScriptRunner.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner {
6060
let macOSPackageDescriptionPath: AbsolutePath
6161
// if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
6262
// which produces a framework for dynamic package products.
63-
if runtimePath.basename == "PackageFrameworks" {
63+
if runtimePath.extension == "framework" {
6464
command += [
65-
"-F", runtimePath.pathString,
65+
"-F", runtimePath.parentDirectory.pathString,
6666
"-framework", "PackagePlugin",
67-
"-Xlinker", "-rpath", "-Xlinker", runtimePath.pathString,
67+
"-Xlinker", "-rpath", "-Xlinker", runtimePath.parentDirectory.pathString,
6868
]
69-
macOSPackageDescriptionPath = runtimePath.appending(RelativePath("PackagePlugin.framework/PackagePlugin"))
69+
macOSPackageDescriptionPath = runtimePath.appending(component: "PackagePlugin")
7070
} else {
7171
command += [
7272
"-L", runtimePath.pathString,
@@ -79,7 +79,7 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner {
7979
#endif
8080

8181
// note: this is not correct for all platforms, but we only actually use it on macOS.
82-
macOSPackageDescriptionPath = runtimePath.appending(RelativePath("libPackagePlugin.dylib"))
82+
macOSPackageDescriptionPath = runtimePath.appending(component: "libPackagePlugin.dylib")
8383
}
8484

8585
// Use the same minimum deployment target as the PackageDescription library (with a fallback of 10.15).
@@ -98,8 +98,8 @@ public struct DefaultPluginScriptRunner: PluginScriptRunner {
9898
command += ["-swift-version", toolsVersion.swiftLanguageVersion.rawValue]
9999
// if runtimePath is set to "PackageFrameworks" that means we could be developing SwiftPM in Xcode
100100
// which produces a framework for dynamic package products.
101-
if runtimePath.basename == "PackageFrameworks" {
102-
command += ["-I", runtimePath.parentDirectory.pathString]
101+
if runtimePath.extension == "framework" {
102+
command += ["-I", runtimePath.parentDirectory.parentDirectory.pathString]
103103
} else {
104104
command += ["-I", runtimePath.pathString]
105105
}

Sources/Workspace/UserToolchain.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,20 +385,20 @@ public final class UserToolchain: Toolchain {
385385
}
386386
}
387387

388-
let customSwiftPMLibrariesLocation = try Self.deriveCustomSwiftPMLibrariesLocation(swiftCompilerPath: swiftCompilerPath, destination: destination)
388+
let swiftPMLibrariesLocation = try Self.deriveSwiftPMLibrariesLocation(swiftCompilerPath: swiftCompilerPath, destination: destination)
389389

390390
let xctestPath = Self.deriveXCTestPath()
391391

392392
self.configuration = .init(
393393
swiftCompilerPath: swiftCompilers.manifest,
394394
swiftCompilerFlags: self.extraSwiftCFlags,
395-
swiftPMLibrariesLocation: customSwiftPMLibrariesLocation,
395+
swiftPMLibrariesLocation: swiftPMLibrariesLocation,
396396
sdkRootPath: self.destination.sdk,
397397
xctestPath: xctestPath
398398
)
399399
}
400400

401-
private static func deriveCustomSwiftPMLibrariesLocation(
401+
private static func deriveSwiftPMLibrariesLocation(
402402
swiftCompilerPath: AbsolutePath,
403403
destination: Destination
404404
) throws -> ToolchainConfiguration.SwiftPMLibrariesLocation? {
@@ -443,8 +443,8 @@ public final class UserToolchain: Toolchain {
443443
let pluginFrameworksPath = applicationPath.appending(components: "PackageFrameworks", "PackagePlugin.framework")
444444
if localFileSystem.exists(manifestFrameworksPath) && localFileSystem.exists(pluginFrameworksPath) {
445445
return .init(
446-
manifestAPI: manifestFrameworksPath.parentDirectory,
447-
pluginAPI: pluginFrameworksPath.parentDirectory
446+
manifestAPI: manifestFrameworksPath,
447+
pluginAPI: pluginFrameworksPath
448448
)
449449
}
450450

@@ -456,8 +456,8 @@ public final class UserToolchain: Toolchain {
456456
)
457457
}
458458

459-
// default case - no custom location which will use the one from the toolchain
460-
return nil
459+
// we are using a SwiftPM outside a toolchain, use the compiler path to compute the location
460+
return .init(swiftCompilerPath: swiftCompilerPath)
461461
}
462462

463463
// TODO: why is this only required on Windows? is there something better we can do?

0 commit comments

Comments
 (0)