diff options
| author | Markus Reiter | 2017-04-27 09:56:16 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-04-30 21:11:27 +0200 |
| commit | 314483f75c8893eb68073f5863e7784797d6ea2a (patch) | |
| tree | 69a485913529f95a77449b6715e6cf9888aa919e /Library | |
| parent | a16746906d463ce9e4dc129bc5a76b81585ee1dd (diff) | |
| download | brew-314483f75c8893eb68073f5863e7784797d6ea2a.tar.bz2 | |
Remove `Array#to_path_s`.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/ENV.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/std.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/extend/ENV/super.rb | 78 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 8 |
4 files changed, 50 insertions, 54 deletions
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb index 811737f10..283e90b69 100644 --- a/Library/Homebrew/extend/ENV.rb +++ b/Library/Homebrew/extend/ENV.rb @@ -3,12 +3,6 @@ require "extend/ENV/shared" require "extend/ENV/std" require "extend/ENV/super" -class Array - def to_path_s - map(&:to_s).uniq.select { |s| File.directory?(s) }.join(File::PATH_SEPARATOR).chuzzle - end -end - def superenv? ARGV.env != "std" && Superenv.bin end diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index d64f2185a..cf828cf20 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -57,12 +57,12 @@ module Stdenv end def determine_pkg_config_libdir - paths = [] - paths << "#{HOMEBREW_PREFIX}/lib/pkgconfig" - paths << "#{HOMEBREW_PREFIX}/share/pkgconfig" - paths += homebrew_extra_pkg_config_paths - paths << "/usr/lib/pkgconfig" - paths.to_path_s + PATH.new( + HOMEBREW_PREFIX/"lib/pkgconfig", + HOMEBREW_PREFIX/"share/pkgconfig", + homebrew_extra_pkg_config_paths, + "/usr/lib/pkgconfig", + ).validate end # Removes the MAKEFLAGS environment variable, causing make to use a single job. diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 166973e09..90215da28 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -101,29 +101,28 @@ module Superenv end def determine_path - paths = [Superenv.bin] + path = PATH.new(Superenv.bin) # Formula dependencies can override standard tools. - paths += deps.map { |d| d.opt_bin.to_s } - - paths += homebrew_extra_paths - paths += %w[/usr/bin /bin /usr/sbin /sbin] + path.append(deps.map { |d| d.opt_bin.to_s }) + path.append(homebrew_extra_paths) + path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin") # Homebrew's apple-gcc42 will be outside the PATH in superenv, # so xcrun may not be able to find it begin case homebrew_cc when "gcc-4.2" - paths << Formulary.factory("apple-gcc42").opt_bin + path.append(Formulary.factory("apple-gcc42").opt_bin) when GNU_GCC_REGEXP - paths << gcc_version_formula($&).opt_bin + path.append(gcc_version_formula($&).opt_bin) end rescue FormulaUnavailableError # Don't fail and don't add these formulae to the path if they don't exist. nil end - paths.to_path_s + path.validate end def homebrew_extra_pkg_config_paths @@ -131,15 +130,17 @@ module Superenv end def determine_pkg_config_path - paths = deps.map { |d| "#{d.opt_lib}/pkgconfig" } - paths += deps.map { |d| "#{d.opt_share}/pkgconfig" } - paths.to_path_s + PATH.new( + deps.map { |d| d.opt_lib/"pkgconfig" }, + deps.map { |d| d.opt_share/"pkgconfig" }, + ).validate end def determine_pkg_config_libdir - paths = %w[/usr/lib/pkgconfig] - paths += homebrew_extra_pkg_config_paths - paths.to_path_s + PATH.new( + "/usr/lib/pkgconfig", + homebrew_extra_pkg_config_paths, + ).validate end def homebrew_extra_aclocal_paths @@ -147,10 +148,11 @@ module Superenv end def determine_aclocal_path - paths = keg_only_deps.map { |d| "#{d.opt_share}/aclocal" } - paths << "#{HOMEBREW_PREFIX}/share/aclocal" - paths += homebrew_extra_aclocal_paths - paths.to_path_s + PATH.new( + keg_only_deps.map { |d| d.opt_share/"aclocal" }, + HOMEBREW_PREFIX/"share/aclocal", + homebrew_extra_aclocal_paths, + ).validate end def homebrew_extra_isystem_paths @@ -158,13 +160,14 @@ module Superenv end def determine_isystem_paths - paths = ["#{HOMEBREW_PREFIX}/include"] - paths += homebrew_extra_isystem_paths - paths.to_path_s + PATH.new( + HOMEBREW_PREFIX/"include", + homebrew_extra_isystem_paths, + ).validate end def determine_include_paths - keg_only_deps.map { |d| d.opt_include.to_s }.to_path_s + PATH.new(keg_only_deps.map(&:opt_include)).validate end def homebrew_extra_library_paths @@ -172,10 +175,11 @@ module Superenv end def determine_library_paths - paths = keg_only_deps.map { |d| d.opt_lib.to_s } - paths << "#{HOMEBREW_PREFIX}/lib" - paths += homebrew_extra_library_paths - paths.to_path_s + PATH.new( + keg_only_deps.map(&:opt_lib), + HOMEBREW_PREFIX/"lib", + homebrew_extra_library_paths, + ).validate end def determine_dependencies @@ -183,9 +187,10 @@ module Superenv end def determine_cmake_prefix_path - paths = keg_only_deps.map { |d| d.opt_prefix.to_s } - paths << HOMEBREW_PREFIX.to_s - paths.to_path_s + PATH.new( + keg_only_deps.map(&:opt_prefix), + HOMEBREW_PREFIX.to_s, + ).validate end def homebrew_extra_cmake_include_paths @@ -193,9 +198,7 @@ module Superenv end def determine_cmake_include_path - paths = [] - paths += homebrew_extra_cmake_include_paths - paths.to_path_s + PATH.new(homebrew_extra_cmake_include_paths).validate end def homebrew_extra_cmake_library_paths @@ -203,9 +206,7 @@ module Superenv end def determine_cmake_library_path - paths = [] - paths += homebrew_extra_cmake_library_paths - paths.to_path_s + PATH.new(homebrew_extra_cmake_library_paths).validate end def homebrew_extra_cmake_frameworks_paths @@ -213,9 +214,10 @@ module Superenv end def determine_cmake_frameworks_path - paths = deps.map { |d| d.opt_frameworks.to_s } - paths += homebrew_extra_cmake_frameworks_paths - paths.to_path_s + PATH.new( + deps.map(&:opt_frameworks), + homebrew_extra_cmake_frameworks_paths, + ).validate end def determine_make_jobs diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 972732ffe..2ac195cdb 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -190,10 +190,10 @@ module Homebrew Gem::Specification.reset # Add Gem binary directory and (if missing) Ruby binary directory to PATH. - paths = ENV["PATH"].split(File::PATH_SEPARATOR) - paths.unshift(RUBY_BIN) if which("ruby") != RUBY_PATH - paths.unshift(Gem.bindir) - ENV["PATH"] = paths.to_path_s + path = PATH.new(ENV["PATH"]) + path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH + path.prepend(Gem.bindir) + ENV["PATH"] = path.validate if Gem::Specification.find_all_by_name(name, version).empty? ohai "Installing or updating '#{name}' gem" |
