Class: Setup::Compiler

Inherits:
Base
  • Object
show all
Defined in:
lib/setup/compiler.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #force, #io, #project, #quiet, #trace, #trial

Instance Method Summary collapse

Methods inherited from Base

#bash, #force?, #force_remove_file, #initialize, #initialize_hooks, #quiet?, #remove_file, #rm_f, #rmdir, #rootdir, #ruby, #trace?, #trace_off, #trial?

Constructor Details

This class inherits a constructor from Setup::Base

Instance Method Details

#cleanObject



36
37
38
39
40
41
42
# File 'lib/setup/compiler.rb', line 36

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

#compileObject



27
28
29
30
31
32
33
# File 'lib/setup/compiler.rb', line 27

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

#compiles?Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/setup/compiler.rb', line 9

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

#configureObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/setup/compiler.rb', line 15

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

#distcleanObject



45
46
47
48
49
50
51
# File 'lib/setup/compiler.rb', line 45

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

#extdirsObject

TODO: get from project



54
55
56
57
58
# File 'lib/setup/compiler.rb', line 54

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

#make(task = nil) ⇒ Object



61
62
63
64
# File 'lib/setup/compiler.rb', line 61

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