Skip to content

Windows testing #516

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Sources/SWBBuildService/BuildService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,24 @@ open class BuildService: Service, @unchecked Sendable {
let fs = SWBUtil.localFS
var binariesToCheck = [Path]()
// Check our own bundle's executable.
if let executablePath = try Bundle.main.executableURL?.filePath {
if fs.exists(executablePath) {
binariesToCheck.append(executablePath)
do {
if let executablePath = try Bundle.main.executableURL?.filePath {
if fs.exists(executablePath) {
binariesToCheck.append(executablePath)
}
}
} catch {
throw StubError.error("Couldn't get main bundle executable URL. Error: \(error), bundle: \(Bundle.main), url: \(String(describing: Bundle.main.executableURL)), path: \(String(describing: try? Bundle.main.executableURL?.filePath))")
}
// Check all the binaries of frameworks in the Frameworks folder.
// Note that this does not recurse into the frameworks for other items nested inside them. We also presently don't check the PlugIns folder.
if let frameworksPath = try Bundle.main.privateFrameworksURL?.filePath {
if let frameworksPath = try? Bundle.main.privateFrameworksURL?.filePath {
do {
for subpath in try fs.listdir(frameworksPath) {
let frameworkPath = frameworksPath.join(subpath)
// Load a bundle at this path. This means we'll skip things which aren't bundles, such as the Swift standard libraries.
if let bundle = Bundle(path: frameworkPath.str) {
if let unresolvedExecutablePath = try bundle.executableURL?.filePath {
if let unresolvedExecutablePath = try? bundle.executableURL?.filePath {
let executablePath = try fs.realpath(unresolvedExecutablePath)
if fs.exists(executablePath) {
binariesToCheck.append(executablePath)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SWBUtil/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ extension URL {
throw FileURLError.notRepresentable(self)
}
let fp = Path(String(cString: cString))
precondition(fp.isAbsolute, "path '\(fp.str)' is not absolute")
guard fp.isAbsolute else {
throw FileURLError.pathNotAbsolute(fp)
}
return fp
}
}
Expand All @@ -37,4 +39,5 @@ extension URL {

fileprivate enum FileURLError: Error {
case notRepresentable(URL)
case pathNotAbsolute(Path)
}