Sha256: 1ebffec26d1476f744a80aeb007b4568736b99589d99021a6f5a852268ed6609

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require 'setup/base'

module Setup

  #
  class Compiler < Base

    #
    def compiles?
      !extdirs.empty?
      #extdirs.any?{ |dir| File.exist?(File.join(dir, 'extconf.rb')) }
    end

    #
    def configure
      extdirs.each do |dir|
        Dir.chdir(dir) do
          if File.exist?('extconf.rb') && !FileUtils.uptodate?('Makefile', ['extconf.rb'])
            #load("extconf.rb", true)
            ruby("extconf.rb")
          end
        end
      end
    end

    #
    def compile
      extdirs.each do |dir|
        Dir.chdir(dir) do
          make
        end
      end
    end

    #
    def clean
      extdirs.each do |dir|
        Dir.chdir(dir) do
          make('clean')
        end
      end
    end

    #
    def distclean
      extdirs.each do |dir|
        Dir.chdir(dir) do
          make('distclean')
        end
      end
    end

    # TODO: get from project
    def extdirs
      Dir['ext/**/*/{MANIFEST,extconf.rb}'].map do |f|
        File.dirname(f)
      end.uniq
    end

    #
    def make(task=nil)
      return unless File.exist?('Makefile')
      bash(*[config.makeprog, task].compact)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
setup-5.2.0 lib/setup/compiler.rb
setup-5.1.0 lib/setup/compiler.rb
setup-5.0.1 lib/setup/compiler.rb
setup-5.0.0 lib/setup/compiler.rb