mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
66f79104e6
commit
ae623435e0
1 changed files with 22 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue