SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
283 stars 16 forks source link

Unescaping file paths found in .compile #18

Closed charshep closed 1 year ago

charshep commented 1 year ago

Compile commands that contain file paths with escaped spaces break when parsing .compile. For example:

-Xcc /Users/charshep/Library/Developer/Xcode/DerivedData/Test_13_4_1-dnwylfechcmuvyhafmkbcvjjrmkh/Build/Intermediates.noindex/Test_13_4_1.build/Debug-iphonesimulator/Test_13_4_1\\ \\(iOS\\).build/Test_13_4_1-generated-files.hmap

Without the fix FlagsForSwift returns the default

["-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"]

because the FlagsForSwiftInCompile fails. With the fix I see the expected flags parsed.

Note that it doesn't appear that the escaped "(" and ")" cause problems, just the spaces. I found this when I created a default iOS App with Xcode 13.4.1 and set it up with xcode-build-server. The same project created with XCode 14.1.0 does not generate path names with " (iOS) " in the name.

Not sure if this is the correct fix. Please disregard if it's not appropriate.

As always, thank you so much for making this project available and keeping it maintained.

SolaWing commented 1 year ago

Thank you for report the issue and made the pr.

I tested in Xcode 14.2, for a name Test (iOS).swiftFiles, it will pass in as Test\ \(iOS\).swiftFiles. and only space is handled, the () pair is not got correctly unescaping, and can't read the FileLists file.

the fileLists path should be preprocessored by the parser, not in the client reader. so I already change the parser to use the shlex.split to extract the fileListsPath, it's ensure the rightness. though it may be a little slow in large projects.

you can test with the newest Head, if you still has any problem, please contact me.