-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SR-1005: [Foundation] Use NSFileHandle instead of fopen #292
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
LGTM but conflicts. |
Indeed it does, it was written against the latest development toolchain snapshot. The Foundation API is being imported now with new rules, so I'm unable to compile until I have an updated toolchain. I've yet to learn to build my own toolchain, maybe I'll just wait for a new toolchain snapshot. |
70d71c0
to
282f165
Compare
I've updated the PR and tested on OS X and Linux against Swift's master branch. |
282f165
to
665ffd5
Compare
I use this script to build my own toolchain: https://gist.github.com/mxcl/05ced0268bbd5db6ab0c |
@ddunbar how do you feel about starting to depend on Foundation? |
Let's do it! :) |
@swift-ci Please test and merge |
Any ideas why the CI reports a failure? From the log I can see that;
|
Hey @Bouke, you are correct that the build scripts will need some changes to facilitate a dependency on Foundation here. Here are some notes and source references that should help get you started on this:
|
I'm hoping that Foundation is available everywhere that Swift is, so using it should not prevent portability of swiftpm. |
In fact, Foundation has an important role to play as an insulator of those same platform differences. |
Sure, that makes sense. So to be clear, you're invisioning that swift-corelibs-foundation will keep its own build system indefinitely, while swift-corelibs-xctest could eventually migrate to be built by SwiftPM, since SwiftPM has no build-time dependency on XCTest. Is that right? |
@briancroom thanks for the pointers in the build script. I'm however stuck at building SwiftPM's stage1, which calls out to swift-build-tool.
Update |
You need to make sure Foundation is accessible through the search paths used during the stage1 build. The stage2 build does this by setting up a dummy toolchain inside the build directory, you might be able to just move that logic early and then use that. |
We have a kind of circular dependency today in the build system for all of the OSes: Foundation builds using xcodebuild, which uses Foundation. Once we get the entire system bootstrapped I don't see a real issue with having these depend on each other. Foundation can continue to use its custom python scripts in the meantime though. |
665ffd5
to
8a99614
Compare
Rebased the PR. The tests should run fine now Foundation is available. |
Conflicts again. :( |
Instead of passing file descriptors, references to NSFileHandle are passed around. `fclose` has been replaced by `closeFile()`, however not strictly necessary as NSFileHandle automatically closes the pointer on deallocation. Rationale for reading the whole file when enumerating the lines: * Iterating over a File instance would read using a buffer, however most usages would concatenate the chunks and work on the complete file (no memory savings). * Files that are read are mostly small files, should not take lots of memory.
8a99614
to
c61b4a0
Compare
@swift-ci please test and merge |
Change LaneBasedExecutionQueue scheduling algorithm to be a priority queue
A partial implementation of SR-1005, replacing POSIX file handling by NSFileHandle.
Instead of passing file descriptors, references to NSFileHandle are passed around.
fclose
has been replaced bycloseFile()
, however not strictly necessary as NSFileHandle automatically closes the pointer on deallocation.Rationale for reading the whole file when enumerating the lines:
however most usages would concatenate the chunks
and work on the complete file (no memory savings).
take lots of memory.
Remarks:
#if os(OSX)
has been used for in the interim.