Skip to content
Closed
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
17 changes: 17 additions & 0 deletions Sources/XToolSupport/SDKBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ struct SDKBuilder {
withIntermediateDirectories: false
)

if let local = ProcessInfo.processInfo.environment["XTOOL_TOOLSET_TARBALL"] {
let tar = Process()
// /bin/sh finds tar on PATH (the Nix build sandbox has no /usr/bin/env)
tar.executableURL = URL(fileURLWithPath: "/bin/sh")
tar.arguments = ["-c", "exec tar xzf \"$0\" -C \"$1\"", local, toolsetDir.path]
try tar.run()
tar.waitUntilExit()
guard tar.terminationStatus == 0 else { throw Console.Error("Could not unpack toolset \(local)") }
} else {
@Dependency(\.httpClient) var httpClient
let url = URL(string: """
https://github.com/xtool-org/darwin-tools-linux-llvm/releases/download/\
Expand Down Expand Up @@ -280,6 +289,7 @@ struct SDKBuilder {
try await execution.standardInputWriter.finish()
}
.checkSuccess()
}

// swift-build assumes we have an Apple-flavored librarian for Apple platforms
// (https://github.com/swiftlang/swift-build/blob/b2433e74e/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift#L1735)
Expand Down Expand Up @@ -386,6 +396,13 @@ struct SDKBuilder {
}

private func installMacros(in output: URL) async throws {
if let local = ProcessInfo.processInfo.environment["XTOOL_OAM_SERVER"] {
let dest = output.appendingPathComponent("OpenAppleMacrosServer")
// write a new file: a copy would keep the read-only mode of the Nix store
try Data(contentsOf: URL(fileURLWithPath: local)).write(to: dest)
try FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: dest.path)
return
}
@Dependency(\.httpClient) var httpClient
let url = URL(string: """
https://github.com/xtool-org/OpenAppleMacros/releases/download/\
Expand Down