class Detroit::ExtConf

The ExtConf tool utilizes extconf.rb script and Autotools standard Makefile to compile native extensions.

Targets the following standard toolchain stations:

@note By neccessity this tool shells out to the command line.

@todo Can we implement a win32 cross-compile?

Constants

MAKE_COMMAND

Platform specific make command.

MANPAGE

Location of manpage for tool.

Attributes

static[RW]

Compile statically? Applies only to compile method. (false)

Public Instance Methods

assemble?(station, options={}) click to toggle source

This tool ties into the `compile`, `clean` and `purge` stations of the standard assembly.

@return [Boolean]

# File lib/detroit-extconf.rb, line 107
def assemble?(station, options={})
  return true if station == :compile
  return true if station == :clean
  return true if station == :purge
  return false
end
clean() click to toggle source

Remove enough compile products for a clean compile.

# File lib/detroit-extconf.rb, line 67
def clean
  make 'clean'
end
clean?()
Alias for: compiles?
compile() click to toggle source

Compile extensions.

# File lib/detroit-extconf.rb, line 57
def compile
  configure
  if static
    make 'static'
  else
    make
  end
end
compile?()
Alias for: compiles?
compiles?() click to toggle source

Check to see if this project has extensions that need to be compiled.

# File lib/detroit-extconf.rb, line 83
def compiles?
  !extensions.empty?
end
Also aliased as: compile?, clean?, purge?
configure() click to toggle source

Create Makefile(s).

@return [void]

# File lib/detroit-extconf.rb, line 46
def configure
  extensions.each do |directory|
    next if File.exist?(File.join(directory, 'Makefile'))
    report "configuring #{directory}"
    cd(directory) do
      sh "ruby extconf.rb"
    end
  end
end
distclean() click to toggle source

Remove all compile products.

# File lib/detroit-extconf.rb, line 72
def distclean
  make 'distclean'
  extensions.each do |directory|
    makefile = File.join(directory, 'Makefile')
    rm(makefile) if File.exist?(makefile)
  end
end
Also aliased as: purge
extensions() click to toggle source

Extension directories. Often this will simply be 'ext'. but sometimes more then one extension is needed and are kept in separate directories. This works by looking for ext/*/.c files, where ever they are is considered an extension directory.

# File lib/detroit-extconf.rb, line 95
def extensions
  @extensions ||= Dir['ext/**/*.c'].collect{ |file| File.dirname(file) }.uniq
end
prerequisite() click to toggle source

Set attribute defaults.

@return [void]

# File lib/detroit-extconf.rb, line 36
def prerequisite
  @static = false
end
purge()
Alias for: distclean
purge?()
Alias for: compiles?

Private Instance Methods

make(target='') click to toggle source
# File lib/detroit-extconf.rb, line 117
def make(target='')
  extensions.each do |directory|
    report "compiling #{directory}"
    cd(directory) do
      shell "#{MAKE_COMMAND} #{target}"
    end
  end
end