in Sources/XCRemoteCache/Artifacts/ArtifactSwiftProductsBuilder.swift [94:120]
func includeModuleDefinitionsToTheArtifact(arch: String, moduleURL: URL) throws {
let zipModuleDir = buildingArtifactSwiftModulesLocation()
// Embed the swiftmodule|doc to the swiftmodule/arch/ directory (XCRemoteCache arbitrary format)
let artifactModuleURL = zipModuleDir.appendingPathComponent(arch)
let moduleURLDir = moduleURL.deletingLastPathComponent()
let swiftModuleFilename = moduleURL.deletingPathExtension().lastPathComponent
let swiftArtifactModuleBase = moduleURLDir.appendingPathComponent(swiftModuleFilename)
let filesToInclude: [URL] = try SwiftmoduleFileExtension.SwiftmoduleExtensions.compactMap { ext, type in
let file = swiftArtifactModuleBase.appendingPathExtension(ext.rawValue)
guard fileManager.fileExists(atPath: file.path) else {
if case .required = type {
throw ArtifactSwiftProductsBuilderError.missingGeneratedModuleFile(path: file.path)
} else {
return nil
}
}
return file
}
// Product module dir may not exist, even if the `moduleName` is present
try fileManager.createDirectory(at: artifactModuleURL, withIntermediateDirectories: true, attributes: nil)
for fileToInclude in filesToInclude {
let filename = fileToInclude.lastPathComponent
let artifactLocation = artifactModuleURL.appendingPathComponent(filename)
try fileManager.spt_forceLinkItem(at: fileToInclude, to: artifactLocation)
}
}