mkmf-bug under mingw without msys

Discussion in 'Ruby' started by Marcel O., Feb 1, 2011.

  1. Marcel O.

    Marcel O. Guest

    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

    --
    Posted via http://www.ruby-forum.com/.
     
    Marcel O., Feb 1, 2011
    #1
    1. Advertising

  2. Marcel O.

    Luis Lavena Guest

    On Feb 1, 7:47 am, "Marcel O." <> 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 Lavena
     
    Luis Lavena, Feb 1, 2011
    #2
    1. Advertising

  3. Marcel O.

    Marcel O. Guest

    Luis Lavena wrote in post #978878:
    > On Feb 1, 7:47am, "Marcel O." <> 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Marcel O., Feb 1, 2011
    #3
  4. On Tue, Feb 1, 2011 at 10:31 AM, Marcel O.
    <> wrote:
    > Luis Lavena wrote in post #978878:
    >> On Feb 1, 7:47am, "Marcel O." <> 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.
    >


    You can require the devkit without rubygems.

    ruby -rdevkit extconf.rb

    > Kind regards
    > Marcel
    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >




    --
    Gordon Thiesfeld
    http://vert.igino.us
     
    Gordon Thiesfeld, Feb 1, 2011
    #4
  5. Marcel O.

    Marcel O. Guest

    Gordon Thiesfeld wrote in post #978911:
    > On Tue, Feb 1, 2011 at 10:31 AM, Marcel O.
    > <> 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Marcel O., Feb 7, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Kenneth Casson Leighton
    Replies:
    0
    Views:
    379
    Luke Kenneth Casson Leighton
    Jan 15, 2009
  2. Luke Kenneth Casson Leighton
    Replies:
    1
    Views:
    354
    Ross Ridge
    Jan 25, 2009
  3. Kaspar Schiess

    Ruby 1.9 on XP using mingw/msys

    Kaspar Schiess, Aug 18, 2004, in forum: Ruby
    Replies:
    0
    Views:
    166
    Kaspar Schiess
    Aug 18, 2004
  4. Replies:
    1
    Views:
    314
  5. Wolfgang Nádasi-Donner
    Replies:
    3
    Views:
    189
    Wolfgang Nádasi-Donner
    May 4, 2007
Loading...

Share This Page