Refactor PATH setup

- Make ORIGINAL_PATHS an array of Pathnames instead of strings
 - Append the dev tools path once in global.rb instead of build.rb

Closes Homebrew/homebrew#13075.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-06-29 00:38:00 -05:00
parent f2e076e5cc
commit 60b518278b
2 changed files with 6 additions and 8 deletions

View File

@ -4,8 +4,6 @@
# Rationale: Formula can use __END__, Formula can change ENV # Rationale: Formula can use __END__, Formula can change ENV
# Thrown exceptions are propogated back to the parent process over a pipe # Thrown exceptions are propogated back to the parent process over a pipe
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| File.expand_path p }
require 'global' require 'global'
at_exit do at_exit do
@ -22,10 +20,7 @@ at_exit do
ENV.extend(HomebrewEnvExtension) ENV.extend(HomebrewEnvExtension)
ENV.setup_build_environment ENV.setup_build_environment
# we must do this or tools like pkg-config won't get found by configure scripts etc. # we must do this or tools like pkg-config won't get found by configure scripts etc.
ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? "#{HOMEBREW_PREFIX}/bin" ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin'
# this is a safety measure for Xcode 4.3 which started not installing
# dev tools into /usr/bin as a default
ENV.prepend 'PATH', MacOS.dev_tools_path, ':' unless ORIGINAL_PATHS.include? MacOS.dev_tools_path
# Force any future invocations of sudo to require the user's password to be # Force any future invocations of sudo to require the user's password to be
# re-entered. This is in-case any build script call sudo. Certainly this is # re-entered. This is in-case any build script call sudo. Certainly this is

View File

@ -92,7 +92,10 @@ unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
require 'compatibility' require 'compatibility'
end end
# For Xcode-only installs, we add the path of the included unix tools (like git) ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(File.expand_path(p)) }
if MacOS.dev_tools_path.to_s != '/usr/bin'
# Xcode-only installs place tools in non-standard locations, and we also want
# to ensure the dev tools are in the PATH in build.rb
unless ORIGINAL_PATHS.include? MacOS.dev_tools_path
ENV['PATH'] = ENV['PATH'].to_s + ':' + MacOS.dev_tools_path ENV['PATH'] = ENV['PATH'].to_s + ':' + MacOS.dev_tools_path
end end