Mkmf-bug under mingw without msys

Hi,

I have a problem building an extension with mkmf under windows which
seems to me as a bug: I want to build the extension in an mingw
environment WITHOUT msys, but mkmf contains code that if it runs in an
mingw environment makes the incorrect assumption it runs under msys and
needs an appropriate path conversion:

mkmf.rb (in all Ruby versions I checked)
case CONFIG[‘build_os’]
when ‘mingw32’
def mkintpath(path)
# mingw uses make from msys and it needs special care
# converts from C:\some\path to /C/some/path
path = path.dup
path.tr!(’\’, ‘/’)
path.sub!(/\A([A-Za-z]):(?=/)/, ‘/\1’)
path
end
end

This results in my mingw-only environment in a generated makefile which
can’t find ruby.h.

I don’t know if it is a common solution to check instead of
CONFIG[‘build_os’], if the environment variable OS_TYPE is set to msys.

Regards
Marcel

On Feb 1, 7:47am, “Marcel O.” [email protected] wrote:

Hi,

I have a problem building an extension with mkmf under windows which
seems to me as a bug: I want to build the extension in an mingw
environment WITHOUT msys, but mkmf contains code that if it runs in an
mingw environment makes the incorrect assumption it runs under msys and
needs an appropriate path conversion:

You can build ruby without msys, but then you will have problems about
dependencies like bison, sed, sh and others that Ruby is expecting.

Can I know the reason of your need? RubyInstaller has been built with
MinGW+MSYS and both have been packaged conveniently as ‘DevKit’ for
it’s transparent usage under Ruby for Windows:

http://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Luis L. wrote in post #978878:

On Feb 1, 7:47am, “Marcel O.” [email protected] wrote:

Hi,

I have a problem building an extension with mkmf under windows which
seems to me as a bug: I want to build the extension in an mingw
environment WITHOUT msys, but mkmf contains code that if it runs in an
mingw environment makes the incorrect assumption it runs under msys and
needs an appropriate path conversion:

You can build ruby without msys, but then you will have problems about
dependencies like bison, sed, sh and others that Ruby is expecting.

I don’t have such dependencies. If I manually change the path in the
generated Makefile, I can compile and link and everything works
perfectly.

Can I know the reason of your need? RubyInstaller has been built with
MinGW+MSYS and both have been packaged conveniently as ‘DevKit’ for
it’s transparent usage under Ruby for Windows:

http://github.com/oneclick/rubyinstaller/wiki/Development-Kit

I know of the DevKit (and use it, too). The reasons are more for
convenience purposes: For the deployment of the extension as a gem, the
DevKit will be our way to go, but for the integration in our build
process (using CMake), during which we use the extension, it would be
easier to use the extension directly (without a gem). So I tried to
implement it that way, and the only obstacle I had, does IMO base on an
obvious misconception in the mkmf code: MinGW implies MSYS; although
this is the normal case under windows due to the DevKit.

I made a proposal to use the OS_TYPE environment variable, but I don’t
know if this will work on all systems. If no one can tell if this would
work and no one else is interested in fixing this and supporting the
MinGW-only use case, I must try to integrate the DevKit in our build
environment. In this case: Would it be possible to integrate DevKit’s
MinGW+MSYS environment without the involvement of RubyGems.

Kind regards
Marcel

Gordon T. wrote in post #978911:

On Tue, Feb 1, 2011 at 10:31 AM, Marcel O.
[email protected] wrote:

it’s transparent usage under Ruby for Windows:
this is the normal case under windows due to the DevKit.

I made a proposal to use the OS_TYPE environment variable, but I don’t
know if this will work on all systems. If no one can tell if this would
work and no one else is interested in fixing this and supporting the
MinGW-only use case, I must try to integrate the DevKit in our build
environment. In this case: Would it be possible to integrate DevKit’s
MinGW+MSYS environment without the involvement of RubyGems.

You can require the devkit without rubygems.

ruby -rdevkit extconf.rb

Adding the following to extconf.rb did the job for me. It implements a
workaround hack, by undoing the work of the stupid mkintpath function.

if CONFIG[‘build_os’] == ‘mingw32’ &&
ENV[‘MSYSTEM’] != ‘MINGW32’ # we are using MinGW without MSYS
mf_content = IO.read( “Makefile” )
mf_content.gsub!( /^topdir = /([a-zA-Z])/ ) {
“topdir = #{$1}:” } # Ruby 1.8
mf_content.gsub!( /^hdrdir = /([a-zA-Z])/ ) {
“hdrdir = #{$1}:” } # Ruby 1.9
File.open( “Makefile”, “w” ) { |mf| mf.puts mf_content }
end

On Tue, Feb 1, 2011 at 10:31 AM, Marcel O.
[email protected] wrote:

it’s transparent usage under Ruby for Windows:
this is the normal case under windows due to the DevKit.

I made a proposal to use the OS_TYPE environment variable, but I don’t
know if this will work on all systems. If no one can tell if this would
work and no one else is interested in fixing this and supporting the
MinGW-only use case, I must try to integrate the DevKit in our build
environment. In this case: Would it be possible to integrate DevKit’s
MinGW+MSYS environment without the involvement of RubyGems.

You can require the devkit without rubygems.

ruby -rdevkit extconf.rb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs