add Rscons.command_executer to determine command executer
Use "env" to execute commands when in MSYS on Windows
This commit is contained in:
1 parent
ef18c9da35
commit
9f75ea9d21
3 files changed
+74
-1
No files matched your search
@@ -83,6 +83,33 @@ module Rscons
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Return an Array containing a command used to execute commands.
|
||||
#
|
||||
# This will normally be an empty Array, but on Windows if Rscons detects
|
||||
# that it is running in MSYS then ["env"] will be returned.
|
||||
#
|
||||
# @return [Array<String>] Command used to execute commands.
|
||||
def self.command_executer
|
||||
@@command_executer ||=
|
||||
if Object.const_get("RUBY_PLATFORM") =~ /mingw/
|
||||
if ENV.keys.find {|key| key =~ /MSYS/}
|
||||
begin
|
||||
if IO.popen(["env", "echo", "success"]) {|io| io.read.strip} == "success"
|
||||
["env"]
|
||||
end
|
||||
rescue
|
||||
end
|
||||
end
|
||||
end || []
|
||||
end
|
||||
|
||||
# Set the command executer array.
|
||||
#
|
||||
# @param val [Array<String>] Command used to execute commands.
|
||||
def self.command_executer=(val)
|
||||
@@command_executer = val
|
||||
end
|
||||
end
|
||||
|
||||
# Unbuffer $stdout
|
||||
|
||||
@@ -245,7 +245,7 @@ module Rscons
|
||||
end
|
||||
env_args = options[:env] ? [options[:env]] : []
|
||||
options_args = options[:options] ? [options[:options]] : []
|
||||
system(*env_args, *command, *options_args).tap do |result|
|
||||
system(*env_args, *Rscons.command_executer, *command, *options_args).tap do |result|
|
||||
unless result or @echo == :command
|
||||
$stdout.write "Failed command was: "
|
||||
print_command.call
|
||||
|
||||
Reference in new issue
Block a user