class Autorake::Definitions

Attributes

directories[R]
environment[R]
features[R]

Public Class Methods

new() click to toggle source
# File lib/autorake/definition.rb, line 17
def initialize
  @environment = {}
  @directories = Directories.new
  @features = {}
  @args = { :par => {}, :inc => {}, :lib => {}, }
  @checks = []
end

Public Instance Methods

dump() click to toggle source
# File lib/autorake/definition.rb, line 25
def dump
  c = perform
  c.dump
end
incpath() click to toggle source
# File lib/autorake/definition.rb, line 14
def incpath    ; @args[ :inc] ; end
libpath() click to toggle source
# File lib/autorake/definition.rb, line 15
def libpath    ; @args[ :lib] ; end
parameters() click to toggle source
# File lib/autorake/definition.rb, line 13
def parameters ; @args[ :par] ; end
perform() click to toggle source
# File lib/autorake/definition.rb, line 30
def perform
  Builder.quiet = true
  c = Configuration.new @environment, @directories
  c.do_env
  c.features.update @features
  c.incdirs.push std_incdir
  c.libdirs.push std_libdir
  af = @features.keys.map { |k| AddFeature.new k }
  am = @args[ :par].map { |k,v| AddMacro.new k, v }
  ai = @args[ :inc].map { |k,v| AddIncdir.new k, v }
  al = @args[ :lib].map { |k,v| AddLibdir.new k, v }
  [ af, am, ai, al, @checks].each { |a| a.each { |k| k.perform c } }
  c
end

Protected Instance Methods

directory(name, dir) click to toggle source
# File lib/autorake/definition.rb, line 50
def directory name, dir
  @directories[ name]= dir
end
disable(name, &block) click to toggle source
# File lib/autorake/definition.rb, line 66
def disable name, &block
  feature name, false, &block
end
enable(name, &block) click to toggle source
# File lib/autorake/definition.rb, line 63
def enable name, &block
  feature name, true, &block
end
extending_ruby() click to toggle source
# File lib/autorake/definition.rb, line 75
def extending_ruby
  if RUBY_VERSION < "1.9" then
    incdir :ruby, RbConfig::CONFIG[ "topdir"]
  else
    h = RbConfig::CONFIG[ "rubyhdrdir"]
    incdir :ruby, h
    incdir :ruby_arch, (File.join h, RbConfig::CONFIG[ "arch"])
    #incdir :ruby_backward, (File.join h, "ruby/backward")
  end
  libdir :ruby, RbConfig::CONFIG[ "libdir"]
  l = RbConfig::CONFIG[ "LIBRUBY"]
  l.slice! /\Alib/
  l.slice! /\.so(?:\..*)?\z/
  have_library l
end
feature(name, enabled = nil) { || ... } click to toggle source
# File lib/autorake/definition.rb, line 54
def feature name, enabled = nil
  name = name.to_sym
  @current and raise "Features may not be nested."
  @current = name
  @features[ name] = enabled
  yield if block_given?
ensure
  @current = nil
end
have_func(name)
Alias for: have_function
have_function(name) click to toggle source
# File lib/autorake/definition.rb, line 101
def have_function name
  c = CheckFunction.new @current, name
  @checks.push c
end
Also aliased as: have_func
have_header(name) click to toggle source
# File lib/autorake/definition.rb, line 91
def have_header name
  c = CheckHeader.new @current, name
  @checks.push c
end
have_library(name) click to toggle source
# File lib/autorake/definition.rb, line 107
def have_library name
  c = CheckLibrary.new @current, name
  @checks.push c
end
have_macro(name) click to toggle source
# File lib/autorake/definition.rb, line 96
def have_macro name
  c = CheckMacro.new @current, name
  @checks.push c
end
incdir(name, dir ;) click to toggle source
# File lib/autorake/definition.rb, line 72
def incdir name, dir ; argdef :inc, name, dir ; end
libdir(name, dir ;) click to toggle source
# File lib/autorake/definition.rb, line 73
def libdir name, dir ; argdef :lib, name, dir ; end
std_incdir() click to toggle source
# File lib/autorake/definition.rb, line 47
def std_incdir ; @directories.expand "INCLUDE" ; end
std_libdir() click to toggle source
# File lib/autorake/definition.rb, line 48
def std_libdir ; @directories.expand "LIB"     ; end
with(name, val ;) click to toggle source
# File lib/autorake/definition.rb, line 70
def with   name, val ; argdef :par, name, val ; end

Private Instance Methods

argdef(type, name, dir) click to toggle source
# File lib/autorake/definition.rb, line 114
def argdef type, name, dir
  return unless dir
  dir.chomp!
  return if dir.empty?
  name = "#@current/#{name}" if @current
  @args[ type][ name.to_sym] = dir
end