ruby-changes:46556
From: usa <ko1@a...>
Date: Fri, 12 May 2017 15:39:49 +0900 (JST)
Subject: [ruby-changes:46556] usa:r58671 (trunk): Support building exts of spec on mswin
usa 2017-05-12 15:39:43 +0900 (Fri, 12 May 2017) New Revision: 58671 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58671 Log: 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. Modified files: trunk/spec/rubyspec/optional/capi/spec_helper.rb Index: spec/rubyspec/optional/capi/spec_helper.rb =================================================================== --- spec/rubyspec/optional/capi/spec_helper.rb (revision 58670) +++ spec/rubyspec/optional/capi/spec_helper.rb (revision 58671) @@ -25,7 +25,6 @@ def compile_extension(name) https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb#L25 # 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) https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb#L32 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) https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/optional/capi/spec_helper.rb#L67 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/