-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from CocoaPods/dani_fix_chdir
Make chdir chdir again
- Loading branch information
Showing
4 changed files
with
44 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Since Xcode 8 beta 4, calling `PBXProject.projectWithFile` breaks subsequent calls to | ||
# `chdir`. While sounding ridiculous, this is unfortunately true and debugging it from the | ||
# userland side showed no difference at all to successful calls to `chdir`, but the working | ||
# directory is simply not changed in the end. This workaround is even more absurd, monkey | ||
# patching all calls to `chdir` to use `__pthread_chdir` which appears to work. | ||
class Dir | ||
def self.cp_chdir(path) | ||
old_dir = Dir.getwd | ||
res = cp_actually_chdir(path) | ||
|
||
if block_given? | ||
begin | ||
return yield | ||
ensure | ||
cp_actually_chdir(old_dir) | ||
end | ||
end | ||
|
||
res | ||
end | ||
|
||
def self.cp_actually_chdir(path) | ||
libc = Fiddle.dlopen '/usr/lib/libc.dylib' | ||
f = Fiddle::Function.new(libc['__pthread_chdir'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT) | ||
f.call(path.to_s) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters