-
Notifications
You must be signed in to change notification settings - Fork 226
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
[WIP] Use xcode-select -p
(weak link approach)
#172
Conversation
… active developer directory `checkDepndenciesOfSourceKittenFramework()` called in main.swift does following: - Check whether `libclang.dylib` and `sourcekitd.framework` are loaded or not - If not, coordinates `DYLD_*` environment variables and calls `execv` - New `sourcekitten` process launched by `execv` loads `libclang.dylib` and `sourcekitd.framework` using coordinated `DYLD_*` environment. `DYLD_*` environment variables are coordinated to searching them in following order: 1. `$TOOLCHAIN_DIR/usr/lib` # for debugging on Xcode 2. `\`xcode-select -p\`/Toolchains/XcodeDefault.xctoolchain/usr/lib` 3. `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib` 4. `/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib` 5. `$HOME/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib` 6. `$HOME/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib`
…_PATHS` `TOOLCHAIN_DIR` reflects overrided toolchain on Xcode 7.3 beta
xcode-select -p
xcode-select -p
(weak link approach)
This should also consider |
As far as I tested, |
% xcode-select -p
/Applications/Xcode.app/Contents/Developer
% DEVELOPER_DIR="/Applications/Xcode-beta.app" xcode-select -p
/Applications/Xcode-beta.app/Contents/Developer So, using result of |
let argv = CStringArray(arguments) | ||
execv(path, argv.pointers) // never returns on normal flow | ||
let error = String(UTF8String: strerror(errno))! // swiftlint:disable:this force_unwrapping | ||
fatalError("execv failed: \(error)") |
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.
Why not the stdlib's Process
?
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.
If not, it might be better to follow the way the stdlib does instead of CStringArray
.
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 didn't know Process.unsafeArgv
.
Thanks!
And also consider the I don't think relaunching automatically is the right long-term solution for clients that link or embed SourceKittenFramework directly — for instance, that approach doesn't work right for a Cocoa app embedding SourceKittenFramework. We should |
I agree. |
It seems |
This was replaced by #176 that using |
#167
Overview:
libclang.dylib
andsourcekitd.framework
are weakly linked toSourceKittenFramework
.LC_RPATH
onSourceKittenFramework
.sourcekitten
loadslibclang.dylib
andsourcekitd.framework
from active developer directory by callingcheckDepndenciesOfSourceKittenFramework()
inmain.swift
checkDepndenciesOfSourceKittenFramework()
callsexecv
for re-launching main executable for loadinglibclang.dylib
andsourcekitd.framework
. So, it might not be used on some dependent client ofSourceKittenFramework
checkDepndenciesOfSourceKittenFramework()
does following:libclang.dylib
andsourcekitd.framework
are loaded or notDYLD_*
environment variables and callsexecv
sourcekitten
process launched byexecv
loadslibclang.dylib
andsourcekitd.framework
using coordinatedDYLD_*
environment.DYLD_*
environment variables are coordinated to searching them in following order:$TOOLCHAIN_DIR/usr/lib
# for debugging on Xcodexcode-select -p
/Toolchains/XcodeDefault.xctoolchain/usr/lib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
$HOME/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
$HOME/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
3~6 are fallbacks on
xcode-select -p
pointing Command Line Tools OS X for Xcode, because that does not containssourcekitd.framework
.Problems
execv
needed. I don't know how large this affects to other clients.