Skip to content

Commit

Permalink
Limit an SPM bug workaround to Windows
Browse files Browse the repository at this point in the history
In case it's the cause of failures in the GitHub CI devcontainer.
  • Loading branch information
dabrahams committed Nov 28, 2023
1 parent ba05fe8 commit b98f0d0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions SPMBuildToolSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,12 @@ fileprivate extension SPMBuildCommand {
(try? fileManager.subpathsOfDirectory(atPath: pluginSourceDirectory.platformString)) ?? []
).map { pluginSourceDirectory.appendingPath($0) }

let executableSize = try fileManager
.attributesOfItem(atPath: i.executable.platformString)[FileAttributeKey.size] as! UInt64
let executableDependency = executableSize == 0 ? [] : [ i.executable.repaired ]
// Work around an SPM bug on Windows: the path to PWSH is some kind of zero-byte shortcut, and
// SPM complains that it doesn't exist if we try to depend on it.
let executableDependency = try osIsWindows && fileManager.attributesOfItem(
atPath: i.executable.platformString)[FileAttributeKey.size] as! UInt64 == 0 ? []
: [ i.executable.repaired ]

return [
.buildCommand(
displayName: displayName,
Expand All @@ -424,8 +427,6 @@ fileprivate extension SPMBuildCommand {
environment: environment,
inputFiles: inputFiles.map(\.repaired)
+ (pluginSources + i.additionalSources).map(\.spmPath)
// Work around an SPM bug on Windows: the path to PWSH is some kind of zero-byte shortcut, and
// SPM complains that it doesn't exist if we try to depend on it.
+ executableDependency,
outputFiles: outputFiles.map(\.repaired))]

Expand Down

0 comments on commit b98f0d0

Please sign in to comment.