-
Notifications
You must be signed in to change notification settings - Fork 129
TSCBasic: repair the Windows build after #277 #282
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
Conversation
@swift-ci please test |
@abertelrud I think that this is mostly similar to #281 but missing the changes you found on the test suite, but it has the additional file name generation fix. I think that we need part of your change still, a part of this change, and a part of another change to get this fully correct. |
Thanks for this! Right, at least the unit test's use of |
I should be more explicit: I don't know how to do this M&A exercise - any thoughts on how to accomplish this the most effective way? |
I am not sure about the origins of the original |
I think we should proceed with this PR but just put in the conditional from #281 to skip that part of the unit test. |
Once the dust from these changes settles, I believe that #278 also needs to be updated. |
Yes, absolutely. |
Sources/TSCBasic/Lock.swift
Outdated
.components.joined(separator: "_") | ||
.replacingOccurrences(of: ":", with: "_") + ".lock" | ||
#if os(Windows) | ||
var lockFileUTF8 = lockFilesDirectory.appending(component: lockFileName).pathString.utf8.suffix(Int(MAX_PATH)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be just the filename, so lockFilesDirectory
gets prepended again below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means you'll end up with lockFilesDirectory
twice.
Looking at this more, I think the part about AbsolutePath.root
was try avoid pasting something that starts with /
as a subpath. I kept that part unmodified but it seems odd, since the file name should never have that in the first place.
My view is that we should just compute a SHA1 of the whole path, whatever it is, and then use that as the filename. But it's true that it would be less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see: With non-Windows file paths, the components
returns a /
as the first path component. So this is just stripping that out.
Taking a step back, I think what would make sense here would be to take just the components leading from the root of the path (whether that's /
or C:\
or whatever) and just using those as the basis for the filename. All this is trying to do is to come up with a unique file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an API to return just the path and not the root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better, however, I think that this new version should address the path issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an API to return just the path and not the root?
I don't believe that there is such an API in the TSC Path API today.
This fixes multiple issues with the file locking implementation on Windows. `AbsolutePath.root` is meaningless on Windows - there is no concept of a singular root on Windows, instead you have have 26 individual roots - A-Z. Stripping the count of characters for the root path leaves us with an invalid path string as the root drives have been stripped. The next character is an invalid character on most file systems, and so we must replace `:`. Instead of using a `MAX_NAME` to compute a length of the ARC, enforce a limit for the complete path (though an ARC would be limited to 255 codepoints on NTFS). This incidentally also corrects the emitted path, previous path computation left us with the file in PWD.
These new changes look good to me. The only thing left is to conditionalize the unit test which references |
Then any kind of exceeding of |
@swift-ci please test |
Thanks for helping to deal with this and sorry it landed on you unexpected. I didn't realize this would have a Windows effect, and I never was able to get Swift up and running in a Windows VM (it's not really feasible to manually test all changes in a separate Windows VM locally anyway) |
I'd like to keep the authorship information for the changes to the test case (you noticed that and fixed it) which is why I haven't folded that into this change. |
We need that, though, I think for this to pass? I certainly don't mind folding it in here, unless you specifically want to disavow it. :) But the fix is actually different — now that the Windows side is fixed too, through your changes, I think it makes sense to not conditionalize the unit test but just put the constant 255 instead of |
So what do you suggest as the next step here? I think the only thing missing in this PR is After that I'll update #278 |
I don't mind at all if you push your bits of the changes to this change at all, I just care about the authorship information :) |
Ok, I see, so to check out your branch and add a commit to it? Happy to do that. I think the current CI will fail if we don't, right? This PR still doesn't build on Windows IIUC? |
I've built it on Windows locally, and been able to use the generated TSCBasic.dll to run swift-build, so I expect that this should be okay. |
Ok, sounds good. Did you build the unit tests on Windows too? Because I don't see how those would compile. |
I did not, which is why I never noticed that. |
Ok, I added a commit to your branch in your fork, so the attribution information should be correct. |
@swift-ci please test |
Thanks @abertelrud! |
This fixes multiple issues with the file locking implementation on
Windows.
AbsolutePath.root
is meaningless on Windows - there isno concept of a singular root on Windows, instead you have have 26
individual roots - A-Z. Stripping the count of characters for the
root path leaves us with an invalid path string as the root drives
have been stripped. The next character is an invalid character on
most file systems, and so we must replace
:
. Instead of using aMAX_NAME
to compute a length of the ARC, enforce a limit for thecomplete path (though an ARC would be limited to 255 codepoints on
NTFS). This incidentally also corrects the emitted path, previous
path computation left us with the file in PWD.