aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-12 06:39:43 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-12 06:39:43 +0000
commitd18463398a1ac1a9f81a6969544600feb8de3525 (patch)
treeb5424d0018a34bb5967b5fd5f8abd9aaa561ebcc /spec
parentd040a490318c9860ad42828ed32bf628bf69f2f3 (diff)
downloadruby-d18463398a1ac1a9f81a6969544600feb8de3525.tar.gz
Support building exts of spec on mswin
* spec/rubyspec/optional/capi/spec_helper.rb: building command of extensions on mswin differs from Unixen's one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/rubyspec/optional/capi/spec_helper.rb32
1 files changed, 22 insertions, 10 deletions
diff --git a/spec/rubyspec/optional/capi/spec_helper.rb b/spec/rubyspec/optional/capi/spec_helper.rb
index ce8a07aeba..e60016f4a7 100644
--- a/spec/rubyspec/optional/capi/spec_helper.rb
+++ b/spec/rubyspec/optional/capi/spec_helper.rb
@@ -25,7 +25,6 @@ def compile_extension(name)
# TODO use rakelib/ext_helper.rb?
arch_hdrdir = nil
- ruby_hdrdir = nil
if RUBY_NAME == 'rbx'
hdrdir = RbConfig::CONFIG["rubyhdrdir"]
@@ -33,7 +32,6 @@ def compile_extension(name)
if hdrdir = RbConfig::CONFIG["rubyhdrdir"]
arch_hdrdir = RbConfig::CONFIG["rubyarchhdrdir"] ||
File.join(hdrdir, RbConfig::CONFIG["arch"])
- ruby_hdrdir = File.join hdrdir, "ruby"
else
hdrdir = RbConfig::CONFIG["archdir"]
end
@@ -69,32 +67,46 @@ def compile_extension(name)
cflags = (ENV["CFLAGS"] || RbConfig::CONFIG["CFLAGS"]).dup
cflags += " #{RbConfig::CONFIG["ARCH_FLAG"]}" if RbConfig::CONFIG["ARCH_FLAG"]
cflags += " #{RbConfig::CONFIG["CCDLFLAGS"]}" if RbConfig::CONFIG["CCDLFLAGS"]
- incflags = "-I#{path} -I#{hdrdir}"
+ cppflags = (ENV["CPPFLAGS"] || RbConfig::CONFIG["CPPFLAGS"]).dup
+ incflags = "-I#{path}"
incflags << " -I#{arch_hdrdir}" if arch_hdrdir
- incflags << " -I#{ruby_hdrdir}" if ruby_hdrdir
+ incflags << " -I#{hdrdir}"
+ csrcflag = RbConfig::CONFIG["CSRCFLAG"]
+ coutflag = RbConfig::CONFIG["COUTFLAG"]
- output = `#{cc} #{incflags} #{cflags} -c #{source} -o #{obj}`
+ compile_cmd = "#{cc} #{incflags} #{cflags} #{cppflags} #{coutflag}#{obj} -c #{csrcflag}#{source}"
+ output = `#{compile_cmd}`
unless $?.success? and File.exist?(obj)
- puts "ERROR:\n#{output}"
+ puts "\nERROR:\n#{compile_cmd}\n#{output}"
puts "incflags=#{incflags}"
puts "cflags=#{cflags}"
+ puts "cppflags=#{cppflags}"
raise "Unable to compile \"#{source}\""
end
ldshared = RbConfig::CONFIG["LDSHARED"]
ldshared += " #{RbConfig::CONFIG["ARCH_FLAG"]}" if RbConfig::CONFIG["ARCH_FLAG"]
- libpath = "-L#{path}"
libs = RbConfig::CONFIG["LIBS"]
dldflags = "#{RbConfig::CONFIG["LDFLAGS"]} #{RbConfig::CONFIG["DLDFLAGS"]} #{RbConfig::CONFIG["EXTDLDFLAGS"]}"
dldflags.sub!(/-Wl,-soname,\S+/, '')
- dldflags.sub!("$(TARGET_ENTRY)", "Init_#{ext}")
- link_cmd = "#{ldshared} #{obj} #{libpath} #{dldflags} #{libs} -o #{lib}"
+ if /mswin/ =~ RUBY_PLATFORM
+ dldflags.sub!("$(LIBPATH)", RbConfig::CONFIG["LIBPATHFLAG"] % path)
+ libs += RbConfig::CONFIG["LIBRUBY"]
+ outflag = RbConfig::CONFIG["OUTFLAG"]
+
+ link_cmd = "#{ldshared} #{outflag}#{lib} #{obj} #{libs} -link #{dldflags} /export:Init_#{ext}"
+ else
+ libpath = "-L#{path}"
+ dldflags.sub!("$(TARGET_ENTRY)", "Init_#{ext}")
+
+ link_cmd = "#{ldshared} #{obj} #{libpath} #{dldflags} #{libs} -o #{lib}"
+ end
output = `#{link_cmd}`
unless $?.success?
- puts "ERROR:\n#{link_cmd}\n#{output}"
+ puts "\nERROR:\n#{link_cmd}\n#{output}"
raise "Unable to link \"#{source}\""
end