diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index 9172d3cea3..7a40d2e389 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -40,7 +40,7 @@ end class Cmd def initialize path, args - @arg0 = path.basename.freeze + @arg0 = File.basename(path).freeze @args = args.freeze end def mode diff --git a/Library/ENV/4.3/xcrun b/Library/ENV/4.3/xcrun index 16600e2403..6921bb3c47 100755 --- a/Library/ENV/4.3/xcrun +++ b/Library/ENV/4.3/xcrun @@ -4,19 +4,21 @@ # But many build-systems expect it to work. This fixes that. # NOTE only works if the build-tool calls xcrun without a path prefixed! -require "#{File.dirname __FILE__}/../libsuperenv" -SUPERBIN = __FILE__.dirname.cleanpath.freeze +dirname = File.dirname(__FILE__) +require "#{dirname}/../libsuperenv" +SUPERBIN = dirname.cleanpath.freeze # Some build tools are stupid and still set DEVELOPER_DIR to old /Developer ENV['DEVELOPER_DIR'] = ENV['HOMEBREW_DEVELOPER_DIR'] exec "/usr/bin/xcrun", *ARGV if ARGV.empty? or ARGV[0][0..0] == '-' if File.exist?("/usr/bin/#{ARGV.first}") - exec "/usr/bin/#{ARGV.shift}", *ARGV unless ENV['HOMEBREW_SDKROOT'].directory? + sdkroot = ENV['HOMEBREW_SDKROOT'] + exec "/usr/bin/#{ARGV.shift}", *ARGV unless sdkroot and File.directory? sdkroot end def try path - exec path, *ARGV if File.executable?(path) and path.cleanpath.dirname != SUPERBIN + exec path, *ARGV if File.executable?(path) and File.dirname(path.cleanpath) != SUPERBIN end arg0 = ARGV.shift diff --git a/Library/ENV/libsuperenv.rb b/Library/ENV/libsuperenv.rb index e08fbba4da..c87e6a4996 100644 --- a/Library/ENV/libsuperenv.rb +++ b/Library/ENV/libsuperenv.rb @@ -6,22 +6,18 @@ $:.unshift "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8" class String - def directory?; File.directory? self end - def basename; File.basename self end def cleanpath; require 'pathname'; Pathname.new(self).realpath.to_s rescue self end def chuzzle; s = chomp; s unless s.empty? end - def dirname; File.dirname(self) end end class NilClass def chuzzle; end - def directory?; false end def split(x); [] end end class Array def to_flags prefix - select{|path| path.directory? }.uniq.map{|path| prefix+path } + select { |path| File.directory? path }.uniq.map { |path| prefix + path } end end