Skip to content

Commit b7b225c

Browse files
authored
Merge pull request #1365 from ahoppen/modulemap-in-diagnose-bundle
Add paths from compiler arguments spelled with `=` to the diagnose bundle
2 parents a6786cd + 9677a00 commit b7b225c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Sources/Diagnose/ReproducerBundle.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ func makeReproducerBundle(for requestInfo: RequestInfo, toolchain: Toolchain, bu
4747
)
4848
}
4949
for compilerArg in requestInfo.compilerArgs {
50-
// Copy all files from the compiler arguments into the reproducer bundle.
51-
// 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.
52-
if compilerArg.hasPrefix("/"), !compilerArg.contains(".app"), !compilerArg.contains(".xctoolchain"),
53-
!compilerArg.contains("/usr/")
54-
{
55-
let dest = URL(fileURLWithPath: bundlePath.path + compilerArg)
56-
try? FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
57-
try? FileManager.default.copyItem(at: URL(fileURLWithPath: compilerArg), to: dest)
50+
// Find the first slash so we are also able to copy files from eg.
51+
// `-fmodule-map-file=/path/to/module.modulemap`
52+
// `-I/foo/bar`
53+
guard let firstSlash = compilerArg.firstIndex(of: "/") else {
54+
continue
5855
}
56+
let path = compilerArg[firstSlash...]
57+
guard !path.contains(".app"), !path.contains(".xctoolchain"), !path.contains("/usr/") else {
58+
// Don't include files in Xcode (.app), Xcode toolchains or usr because they are most likely binary files that
59+
// aren't user specific and would bloat the reproducer bundle.
60+
continue
61+
}
62+
let dest = URL(fileURLWithPath: bundlePath.path + path)
63+
try? FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
64+
try? FileManager.default.copyItem(at: URL(fileURLWithPath: String(path)), to: dest)
5965
}
6066
}

0 commit comments

Comments
 (0)