Use File::PATH_SEPARATOR globally instead of ':'
On Unix, the path separator is ':', whereas on Windows, it is ';'. This is the first of a series of patch to bring macbrew's and winbrew's codebases closer together. The main places the magic constant ':' was being used were: - the $PATH environment variable - CMAKE-related environment variables - pkg-config related environment variables Closes Homebrew/homebrew#21921. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
809a52a6a3
commit
52ace99f14
@ -42,7 +42,7 @@ class Checks
|
|||||||
|
|
||||||
############# HELPERS
|
############# HELPERS
|
||||||
def paths
|
def paths
|
||||||
@paths ||= ENV['PATH'].split(':').collect do |p|
|
@paths ||= ENV['PATH'].split(File::PATH_SEPARATOR).collect do |p|
|
||||||
begin
|
begin
|
||||||
File.expand_path(p).chomp('/')
|
File.expand_path(p).chomp('/')
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
@ -68,7 +68,7 @@ class Checks
|
|||||||
# Sorry for the lack of an indent here, the diff would have been unreadable.
|
# Sorry for the lack of an indent here, the diff would have been unreadable.
|
||||||
# See https://github.com/mxcl/homebrew/pull/9986
|
# See https://github.com/mxcl/homebrew/pull/9986
|
||||||
def check_path_for_trailing_slashes
|
def check_path_for_trailing_slashes
|
||||||
bad_paths = ENV['PATH'].split(':').select { |p| p[-1..-1] == '/' }
|
bad_paths = ENV['PATH'].split(File::PATH_SEPARATOR).select { |p| p[-1..-1] == '/' }
|
||||||
return if bad_paths.empty?
|
return if bad_paths.empty?
|
||||||
s = <<-EOS.undent
|
s = <<-EOS.undent
|
||||||
Some directories in your path end in a slash.
|
Some directories in your path end in a slash.
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Homebrew extend self
|
|||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
if superenv?
|
if superenv?
|
||||||
# superenv stopped adding brew's bin but generally user's will want it
|
# superenv stopped adding brew's bin but generally user's will want it
|
||||||
ENV['PATH'] = ENV['PATH'].split(':').insert(1, "#{HOMEBREW_PREFIX}/bin").join(':')
|
ENV['PATH'] = ENV['PATH'].split(File::PATH_SEPARATOR).insert(1, "#{HOMEBREW_PREFIX}/bin").join(File::PATH_SEPARATOR)
|
||||||
end
|
end
|
||||||
ENV['PS1'] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ '
|
ENV['PS1'] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ '
|
||||||
ENV['VERBOSE'] = '1'
|
ENV['VERBOSE'] = '1'
|
||||||
|
|||||||
@ -36,7 +36,7 @@ module SharedEnvExtension
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def prepend_path key, path
|
def prepend_path key, path
|
||||||
prepend key, path, ':' if File.directory? path
|
prepend key, path, File::PATH_SEPARATOR if File.directory? path
|
||||||
end
|
end
|
||||||
def remove keys, value
|
def remove keys, value
|
||||||
Array(keys).each do |key|
|
Array(keys).each do |key|
|
||||||
@ -65,9 +65,9 @@ module SharedEnvExtension
|
|||||||
|
|
||||||
def userpaths!
|
def userpaths!
|
||||||
paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin}
|
paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w{/usr/X11/bin /opt/X11/bin}
|
||||||
self['PATH'] = paths.unshift(*self['PATH'].split(":")).uniq.join(":")
|
self['PATH'] = paths.unshift(*self['PATH'].split(PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
|
||||||
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
|
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
|
||||||
prepend 'PATH', HOMEBREW_PREFIX/'bin', ':'
|
prepend 'PATH', HOMEBREW_PREFIX/'bin', File::PATH_SEPARATOR
|
||||||
end
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
|
|||||||
@ -72,9 +72,9 @@ module Stdenv
|
|||||||
# For Xcode 4.3 (*without* the "Command Line Tools for Xcode") compiler and tools inside of Xcode:
|
# For Xcode 4.3 (*without* the "Command Line Tools for Xcode") compiler and tools inside of Xcode:
|
||||||
if not MacOS::CLT.installed? and MacOS::Xcode.installed? and MacOS::Xcode.version >= "4.3"
|
if not MacOS::CLT.installed? and MacOS::Xcode.installed? and MacOS::Xcode.version >= "4.3"
|
||||||
# Some tools (clang, etc.) are in the xctoolchain dir of Xcode
|
# Some tools (clang, etc.) are in the xctoolchain dir of Xcode
|
||||||
append 'PATH', "#{MacOS.xctoolchain_path}/usr/bin", ":" if MacOS.xctoolchain_path
|
append 'PATH', "#{MacOS.xctoolchain_path}/usr/bin", File::PATH_SEPARATOR if MacOS.xctoolchain_path
|
||||||
# Others are now at /Applications/Xcode.app/Contents/Developer/usr/bin
|
# Others are now at /Applications/Xcode.app/Contents/Developer/usr/bin
|
||||||
append 'PATH', "#{MacOS.dev_tools_path}", ":"
|
append 'PATH', "#{MacOS.dev_tools_path}", File::PATH_SEPARATOR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ module Stdenv
|
|||||||
paths << HOMEBREW_PREFIX/'share/pkgconfig'
|
paths << HOMEBREW_PREFIX/'share/pkgconfig'
|
||||||
paths << HOMEBREW_REPOSITORY/"Library/ENV/pkgconfig/#{MacOS.version}"
|
paths << HOMEBREW_REPOSITORY/"Library/ENV/pkgconfig/#{MacOS.version}"
|
||||||
paths << '/usr/lib/pkgconfig'
|
paths << '/usr/lib/pkgconfig'
|
||||||
paths.select { |d| File.directory? d }.join(':')
|
paths.select { |d| File.directory? d }.join(File::PATH_SEPARATOR)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deparallelize
|
def deparallelize
|
||||||
@ -217,15 +217,15 @@ module Stdenv
|
|||||||
# Extra setup to support Xcode 4.3+ without CLT.
|
# Extra setup to support Xcode 4.3+ without CLT.
|
||||||
self['SDKROOT'] = sdk
|
self['SDKROOT'] = sdk
|
||||||
# Tell clang/gcc where system include's are:
|
# Tell clang/gcc where system include's are:
|
||||||
append 'CPATH', "#{sdk}/usr/include", ":"
|
append 'CPATH', "#{sdk}/usr/include", File::PATH_SEPARATOR
|
||||||
# The -isysroot is needed, too, because of the Frameworks
|
# The -isysroot is needed, too, because of the Frameworks
|
||||||
append_to_cflags "-isysroot #{sdk}"
|
append_to_cflags "-isysroot #{sdk}"
|
||||||
append 'CPPFLAGS', "-isysroot #{sdk}"
|
append 'CPPFLAGS', "-isysroot #{sdk}"
|
||||||
# And the linker needs to find sdk/usr/lib
|
# And the linker needs to find sdk/usr/lib
|
||||||
append 'LDFLAGS', "-isysroot #{sdk}"
|
append 'LDFLAGS', "-isysroot #{sdk}"
|
||||||
# Needed to build cmake itself and perhaps some cmake projects:
|
# Needed to build cmake itself and perhaps some cmake projects:
|
||||||
append 'CMAKE_PREFIX_PATH', "#{sdk}/usr", ':'
|
append 'CMAKE_PREFIX_PATH', "#{sdk}/usr", File::PATH_SEPARATOR
|
||||||
append 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks", ':'
|
append 'CMAKE_FRAMEWORK_PATH', "#{sdk}/System/Library/Frameworks", File::PATH_SEPARATOR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -250,24 +250,24 @@ module Stdenv
|
|||||||
|
|
||||||
def x11
|
def x11
|
||||||
# There are some config scripts here that should go in the PATH
|
# There are some config scripts here that should go in the PATH
|
||||||
append 'PATH', MacOS::X11.bin, ':'
|
append 'PATH', MacOS::X11.bin, File::PATH_SEPARATOR
|
||||||
|
|
||||||
# Append these to PKG_CONFIG_LIBDIR so they are searched
|
# Append these to PKG_CONFIG_LIBDIR so they are searched
|
||||||
# *after* our own pkgconfig directories, as we dupe some of the
|
# *after* our own pkgconfig directories, as we dupe some of the
|
||||||
# libs in XQuartz.
|
# libs in XQuartz.
|
||||||
append 'PKG_CONFIG_LIBDIR', MacOS::X11.lib/'pkgconfig', ':'
|
append 'PKG_CONFIG_LIBDIR', MacOS::X11.lib/'pkgconfig', File::PATH_SEPARATOR
|
||||||
append 'PKG_CONFIG_LIBDIR', MacOS::X11.share/'pkgconfig', ':'
|
append 'PKG_CONFIG_LIBDIR', MacOS::X11.share/'pkgconfig', File::PATH_SEPARATOR
|
||||||
|
|
||||||
append 'LDFLAGS', "-L#{MacOS::X11.lib}"
|
append 'LDFLAGS', "-L#{MacOS::X11.lib}"
|
||||||
append 'CMAKE_PREFIX_PATH', MacOS::X11.prefix, ':'
|
append 'CMAKE_PREFIX_PATH', MacOS::X11.prefix, File::PATH_SEPARATOR
|
||||||
append 'CMAKE_INCLUDE_PATH', MacOS::X11.include, ':'
|
append 'CMAKE_INCLUDE_PATH', MacOS::X11.include, File::PATH_SEPARATOR
|
||||||
|
|
||||||
append 'CPPFLAGS', "-I#{MacOS::X11.include}"
|
append 'CPPFLAGS', "-I#{MacOS::X11.include}"
|
||||||
|
|
||||||
append 'ACLOCAL_PATH', MacOS::X11.share/'aclocal', ':'
|
append 'ACLOCAL_PATH', MacOS::X11.share/'aclocal', File::PATH_SEPARATOR
|
||||||
|
|
||||||
unless MacOS::CLT.installed?
|
unless MacOS::CLT.installed?
|
||||||
append 'CMAKE_PREFIX_PATH', MacOS.sdk_path/'usr/X11', ':'
|
append 'CMAKE_PREFIX_PATH', MacOS.sdk_path/'usr/X11', File::PATH_SEPARATOR
|
||||||
append 'CPPFLAGS', "-I#{MacOS::X11.include}/freetype2"
|
append 'CPPFLAGS', "-I#{MacOS::X11.include}/freetype2"
|
||||||
append 'CFLAGS', "-I#{MacOS::X11.include}"
|
append 'CFLAGS', "-I#{MacOS::X11.include}"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -96,7 +96,7 @@ module Superenv
|
|||||||
# so xcrun may not be able to find it
|
# so xcrun may not be able to find it
|
||||||
if self['HOMEBREW_CC'] == 'gcc-4.2'
|
if self['HOMEBREW_CC'] == 'gcc-4.2'
|
||||||
apple_gcc42 = Formula.factory('apple-gcc42') rescue nil
|
apple_gcc42 = Formula.factory('apple-gcc42') rescue nil
|
||||||
append('PATH', apple_gcc42.opt_prefix/'bin', ':') if apple_gcc42
|
append('PATH', apple_gcc42.opt_prefix/'bin', File::PATH_SEPARATOR) if apple_gcc42
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -303,6 +303,6 @@ end
|
|||||||
|
|
||||||
class Array
|
class Array
|
||||||
def to_path_s
|
def to_path_s
|
||||||
map(&:to_s).uniq.select{|s| File.directory? s }.join(':').chuzzle
|
map(&:to_s).uniq.select{|s| File.directory? s }.join(File::PATH_SEPARATOR).chuzzle
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -98,7 +98,7 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)
|
|||||||
|
|
||||||
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
|
||||||
|
|
||||||
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
||||||
|
|
||||||
SUDO_BAD_ERRMSG = <<-EOS.undent
|
SUDO_BAD_ERRMSG = <<-EOS.undent
|
||||||
You can use brew with sudo, but only if the brew executable is owned by root.
|
You can use brew with sudo, but only if the brew executable is owned by root.
|
||||||
|
|||||||
@ -62,11 +62,11 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
|
|||||||
# so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
|
# so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
|
||||||
puts "brew: Prepending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
|
puts "brew: Prepending to PYTHONPATH: #{py.site_packages}" if ARGV.verbose?
|
||||||
mkdir_p py.site_packages
|
mkdir_p py.site_packages
|
||||||
ENV.prepend 'PYTHONPATH', py.site_packages, ':'
|
ENV.prepend 'PYTHONPATH', py.site_packages, File::PATH_SEPARATOR
|
||||||
ENV['PYTHON'] = py.binary
|
ENV['PYTHON'] = py.binary
|
||||||
ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
|
ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, File::PATH_SEPARATOR
|
||||||
ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
|
ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, File::PATH_SEPARATOR if py.pkg_config_path
|
||||||
ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
|
ENV.prepend 'PATH', py.binary.dirname, File::PATH_SEPARATOR unless py.from_osx?
|
||||||
#Note: Don't set LDFLAGS to point to the Python.framework, because
|
#Note: Don't set LDFLAGS to point to the Python.framework, because
|
||||||
# it breaks builds (for example scipy.)
|
# it breaks builds (for example scipy.)
|
||||||
|
|
||||||
|
|||||||
@ -122,7 +122,7 @@ class PythonInstalled < Requirement
|
|||||||
else
|
else
|
||||||
# Using the ORIGINAL_PATHS here because in superenv, the user
|
# Using the ORIGINAL_PATHS here because in superenv, the user
|
||||||
# installed external Python is not visible otherwise.
|
# installed external Python is not visible otherwise.
|
||||||
which(@name, ORIGINAL_PATHS.join(':'))
|
which(@name, ORIGINAL_PATHS.join(File::PATH_SEPARATOR))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -252,12 +252,12 @@ class PythonInstalled < Requirement
|
|||||||
file.write(sitecustomize)
|
file.write(sitecustomize)
|
||||||
|
|
||||||
# For non-system python's we add the opt_prefix/bin of python to the path.
|
# For non-system python's we add the opt_prefix/bin of python to the path.
|
||||||
ENV.prepend 'PATH', binary.dirname, ':' unless from_osx?
|
ENV.prepend 'PATH', binary.dirname, File::PATH_SEPARATOR unless from_osx?
|
||||||
|
|
||||||
ENV['PYTHONHOME'] = nil # to avoid fuck-ups.
|
ENV['PYTHONHOME'] = nil # to avoid fuck-ups.
|
||||||
ENV['PYTHONPATH'] = if brewed? then nil; else global_site_packages.to_s; end
|
ENV['PYTHONPATH'] = if brewed? then nil; else global_site_packages.to_s; end
|
||||||
ENV.append 'CMAKE_INCLUDE_PATH', incdir, ':'
|
ENV.append 'CMAKE_INCLUDE_PATH', incdir, File::PATH_SEPARATOR
|
||||||
ENV.append 'PKG_CONFIG_PATH', pkg_config_path, ':' if pkg_config_path
|
ENV.append 'PKG_CONFIG_PATH', pkg_config_path, File::PATH_SEPARATOR if pkg_config_path
|
||||||
# We don't set the -F#{framework} here, because if Python 2.x and 3.x are
|
# We don't set the -F#{framework} here, because if Python 2.x and 3.x are
|
||||||
# used, `Python.framework` is ambiguous. However, in the `python do` block
|
# used, `Python.framework` is ambiguous. However, in the `python do` block
|
||||||
# we can set LDFLAGS+="-F#{framework}" because only one is temporarily set.
|
# we can set LDFLAGS+="-F#{framework}" because only one is temporarily set.
|
||||||
|
|||||||
@ -33,7 +33,7 @@ MACOS = true
|
|||||||
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
|
||||||
MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }.to_f
|
MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }.to_f
|
||||||
|
|
||||||
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
|
||||||
|
|
||||||
module Homebrew extend self
|
module Homebrew extend self
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
|||||||
@ -167,7 +167,7 @@ def puts_columns items, star_items=[]
|
|||||||
end
|
end
|
||||||
|
|
||||||
def which cmd, path=ENV['PATH']
|
def which cmd, path=ENV['PATH']
|
||||||
dir = path.split(':').find {|p| File.executable? File.join(p, cmd)}
|
dir = path.split(File::PATH_SEPARATOR).find {|p| File.executable? File.join(p, cmd)}
|
||||||
Pathname.new(File.join(dir, cmd)) unless dir.nil?
|
Pathname.new(File.join(dir, cmd)) unless dir.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user