2011-06-24 02:11:55 +04:00
|
|
|
|
2008-09-25 11:01:07 +04:00
|
|
|
module Rake
|
2011-06-24 02:11:55 +04:00
|
|
|
require 'rake/alt_system'
|
2009-01-29 06:29:53 +03:00
|
|
|
|
2008-09-25 11:01:07 +04:00
|
|
|
# Win 32 interface methods for Rake. Windows specific functionality
|
|
|
|
# will be placed here to collect that knowledge in one spot.
|
2014-07-15 07:07:37 +04:00
|
|
|
module Win32 # :nodoc: all
|
2011-06-24 02:11:55 +04:00
|
|
|
|
|
|
|
# Error indicating a problem in locating the home directory on a
|
|
|
|
# Win32 system.
|
|
|
|
class Win32HomeError < RuntimeError
|
|
|
|
end
|
|
|
|
|
2008-09-25 11:01:07 +04:00
|
|
|
class << self
|
|
|
|
# True if running on a windows system.
|
2011-06-24 02:11:55 +04:00
|
|
|
def windows?
|
|
|
|
AltSystem::WINDOWS
|
|
|
|
end
|
|
|
|
|
|
|
|
# Run a command line on windows.
|
|
|
|
def rake_system(*cmd)
|
|
|
|
AltSystem.system(*cmd)
|
2008-09-25 11:01:07 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
# The standard directory containing system wide rake files on
|
|
|
|
# Win 32 systems. Try the following environment variables (in
|
|
|
|
# order):
|
|
|
|
#
|
2009-01-29 06:29:53 +03:00
|
|
|
# * HOME
|
2008-09-25 11:01:07 +04:00
|
|
|
# * HOMEDRIVE + HOMEPATH
|
2011-06-24 02:11:55 +04:00
|
|
|
# * APPDATA
|
2008-09-25 11:01:07 +04:00
|
|
|
# * USERPROFILE
|
|
|
|
#
|
2011-06-24 02:11:55 +04:00
|
|
|
# If the above are not defined, the return nil.
|
2008-09-25 11:01:07 +04:00
|
|
|
def win32_system_dir #:nodoc:
|
2011-06-24 02:11:55 +04:00
|
|
|
win32_shared_path = ENV['HOME']
|
|
|
|
if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
|
|
|
win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
|
2008-09-25 11:01:07 +04:00
|
|
|
end
|
2011-06-24 02:11:55 +04:00
|
|
|
|
|
|
|
win32_shared_path ||= ENV['APPDATA']
|
|
|
|
win32_shared_path ||= ENV['USERPROFILE']
|
2013-10-12 01:35:01 +04:00
|
|
|
raise Win32HomeError,
|
|
|
|
"Unable to determine home path environment variable." if
|
|
|
|
win32_shared_path.nil? or win32_shared_path.empty?
|
2011-06-24 02:11:55 +04:00
|
|
|
normalize(File.join(win32_shared_path, 'Rake'))
|
2008-09-25 11:01:07 +04:00
|
|
|
end
|
2009-10-02 23:07:55 +04:00
|
|
|
|
|
|
|
# Normalize a win32 path so that the slashes are all forward slashes.
|
|
|
|
def normalize(path)
|
2011-06-24 02:11:55 +04:00
|
|
|
path.gsub(/\\/, '/')
|
2009-10-02 23:07:55 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2008-09-25 11:01:07 +04:00
|
|
|
end
|