Skip to content

Add paths from compiler arguments spelled with = to the diagnose bundle #1365

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 30, 2024
Merged
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
22 changes: 14 additions & 8 deletions Sources/Diagnose/ReproducerBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ func makeReproducerBundle(for requestInfo: RequestInfo, toolchain: Toolchain, bu
)
}
for compilerArg in requestInfo.compilerArgs {
// Copy all files from the compiler arguments into the reproducer bundle.
// Don't include files in Xcode (.app), Xcode toolchains or usr because they are most likely binary files that aren't user specific and would bloat the reproducer bundle.
if compilerArg.hasPrefix("/"), !compilerArg.contains(".app"), !compilerArg.contains(".xctoolchain"),
!compilerArg.contains("/usr/")
{
let dest = URL(fileURLWithPath: bundlePath.path + compilerArg)
try? FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
try? FileManager.default.copyItem(at: URL(fileURLWithPath: compilerArg), to: dest)
// Find the first slash so we are also able to copy files from eg.
// `-fmodule-map-file=/path/to/module.modulemap`
// `-I/foo/bar`
guard let firstSlash = compilerArg.firstIndex(of: "/") else {
continue
}
let path = compilerArg[firstSlash...]
guard !path.contains(".app"), !path.contains(".xctoolchain"), !path.contains("/usr/") else {
// Don't include files in Xcode (.app), Xcode toolchains or usr because they are most likely binary files that
// aren't user specific and would bloat the reproducer bundle.
continue
}
let dest = URL(fileURLWithPath: bundlePath.path + path)
try? FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
try? FileManager.default.copyItem(at: URL(fileURLWithPath: String(path)), to: dest)
}
}