aboutsummaryrefslogtreecommitdiffstats
path: root/spec/rubyspec/optional/capi/spec_helper.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 19:45:19 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 19:45:19 +0000
commit9e4233aecb8a7f83ea501b43615f9cdac12de9c5 (patch)
treefbb46bda84733397995715b924b1f786ea94f7f1 /spec/rubyspec/optional/capi/spec_helper.rb
parentf28709ec41eff0f6498d0a01cf1432d457bd4bf7 (diff)
downloadruby-9e4233aecb8a7f83ea501b43615f9cdac12de9c5.tar.gz
Update to ruby/spec@e3b6811
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/optional/capi/spec_helper.rb')
-rw-r--r--spec/rubyspec/optional/capi/spec_helper.rb44
1 files changed, 26 insertions, 18 deletions
diff --git a/spec/rubyspec/optional/capi/spec_helper.rb b/spec/rubyspec/optional/capi/spec_helper.rb
index b82ce69b0e..21d2cd04c5 100644
--- a/spec/rubyspec/optional/capi/spec_helper.rb
+++ b/spec/rubyspec/optional/capi/spec_helper.rb
@@ -55,25 +55,8 @@ def compile_extension(name)
$stderr.puts output if debug
end
- make = ENV['MAKE']
- make ||= (RbConfig::CONFIG['host_os'].include?("mswin") ? "nmake" : "make")
- if File.basename(make, ".*").casecmp?("nmake")
- # suppress logo of nmake.exe to stderr
- ENV["MAKEFLAGS"] = "l#{ENV["MAKEFLAGS"]}"
- end
-
- opts = {}
- if /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ ENV["MAKEFLAGS"]
- begin
- r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
- w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
- rescue Errno::EBADF
- else
- opts[r] = r
- opts[w] = w
- end
- end
# Do not capture stderr as we want to show compiler warnings
+ make, opts = setup_make
output = IO.popen([make, "V=1", "DESTDIR=", opts], &:read)
raise "#{make} failed:\n#{output}" unless $?.success?
$stderr.puts output if debug
@@ -88,6 +71,31 @@ def compile_extension(name)
lib
end
+def setup_make
+ make = ENV['MAKE']
+ make ||= (RbConfig::CONFIG['host_os'].include?("mswin") ? "nmake" : "make")
+ make_flags = ENV["MAKEFLAGS"] || ''
+
+ # suppress logo of nmake.exe to stderr
+ if File.basename(make, ".*").downcase == "nmake" and !make_flags.include?("l")
+ ENV["MAKEFLAGS"] = "l#{make_flags}"
+ end
+
+ opts = {}
+ if /(?:\A|\s)--jobserver-(?:auth|fds)=(\d+),(\d+)/ =~ make_flags
+ begin
+ r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
+ w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
+ rescue Errno::EBADF
+ else
+ opts[r] = r
+ opts[w] = w
+ end
+ end
+
+ [make, opts]
+end
+
def load_extension(name)
require compile_extension(name)
rescue LoadError