in Sources/SKCore/FileBuildSettings.swift [53:78]
func patching(newFile: String, originalFile: String) -> FileBuildSettings {
var arguments = self.compilerArguments
let basename = originalFile.pathBasename
let fileExtension = originalFile.pathExtension
if let index = arguments.lastIndex(where: {
// It's possible the arguments use relative paths while the `originalFile` given
// is an absolute/real path value. We guess based on suffixes instead of hitting
// the file system.
$0.hasSuffix(basename) && originalFile.hasSuffix($0)
}) {
arguments[index] = newFile
// The `-x<lang>` flag needs to be before the possible `-c <header file>`
// argument in order for Clang to respect it. If there is a pre-existing `-x`
// flag though, Clang will honor that one instead since it comes after.
if cExtensions.contains(fileExtension) {
arguments.insert("-xc", at: 0)
} else if cppExtensions.contains(fileExtension) {
arguments.insert("-xc++", at: 0)
} else if objcExtensions.contains(fileExtension) {
arguments.insert("-xobjective-c", at: 0)
} else if (objcppExtensions.contains(fileExtension)) {
arguments.insert("-xobjective-c++", at: 0)
}
}
return FileBuildSettings(compilerArguments: arguments, workingDirectory: self.workingDirectory)
}