mkmf-bug under mingw without msys

M

Marcel O.

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
 
L

Luis Lavena

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
 
M

Marcel O.

Luis Lavena wrote in post #978878:
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
 
G

Gordon Thiesfeld

Luis Lavena wrote in post #978878:

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.


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.

You can require the devkit without rubygems.

ruby -rdevkit extconf.rb
 
M

Marcel O.

Gordon Thiesfeld wrote in post #978911:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top