Skip to content

Pass the correct toolchain path to SwiftBuild #8696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025

Conversation

jakepetroules
Copy link
Contributor

SwiftBuild can be initialized with either an Xcode-based developer directory for a Swift toolchain based developer directory, pass the right flags to initialize properly based on what kind of toolchain is in use.

@jakepetroules
Copy link
Contributor Author

@swift-ci test

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

let sessionResult = if toolchainPath.components.contains(where: { $0.hasSuffix(".xctoolchain") }) {
await service.createSession(name: name, developerPath: nil, resourceSearchPaths: packageManagerResourcesDirectory.map { [$0.pathString] } ?? [], cachePath: nil, inferiorProductsPath: nil, environment: nil)
} else {
await service.createSession(name: name, swiftToolchainPath: toolchainPath.pathString, resourceSearchPaths: packageManagerResourcesDirectory.map { [$0.pathString] } ?? [], cachePath: nil, inferiorProductsPath: nil, environment: nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on whether this should use the toolchain from build params or the toolchain this SwiftPM is installed in. I think I've decided I'm happy with this approach though

try resolveSymlinks(swiftCompilerPath)
.parentDirectory // bin
.parentDirectory // usr
.parentDirectory // <toolchain>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably breaks for some platforms like FreeBSD where there's an expectation of using /usr/local but will handle that in a future change.

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

@jakepetroules jakepetroules added the build system Changes to interactions with build systems label May 21, 2025
@jakepetroules
Copy link
Contributor Author

@swift-ci test windows self hosted

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

3 similar comments
@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

SwiftBuild can be initialized with either an Xcode-based developer directory for a Swift toolchain based developer directory, pass the right flags to initialize properly based on what kind of toolchain is in use.
@jakepetroules jakepetroules force-pushed the eng/PR-pass-toolchain-paths branch from 5d4c5d7 to 0a9566c Compare May 24, 2025 06:55
@jakepetroules
Copy link
Contributor Author

@swift-ci test

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

@jakepetroules
Copy link
Contributor Author

@swift-ci test windows

@jakepetroules jakepetroules merged commit 1cbb77a into main May 26, 2025
6 checks passed
@jakepetroules jakepetroules deleted the eng/PR-pass-toolchain-paths branch May 26, 2025 19:42
jakepetroules added a commit that referenced this pull request May 28, 2025
Amendment to #8696 which computes the correct path on Windows and FreeBSD, which use different install layouts from the other platforms.
jakepetroules added a commit that referenced this pull request May 28, 2025
Amendment to #8696 which computes the correct path on Windows and FreeBSD, which use different install layouts from the other platforms.
jakepetroules added a commit that referenced this pull request May 29, 2025
Amendment to #8696 which computes the correct path on Windows and FreeBSD, which use different install layouts from the other platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Changes to interactions with build systems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants