module Autorake::Rakefile

Public Class Methods

extended(obj) click to toggle source
# File lib/autorake.rb, line 23
def extended obj
  obj.load_autorake ENV[ "AUTORAKE_CONFIGURE"].notempty?
  Builder.verbose = true
end

Public Instance Methods

compiler(*args) click to toggle source
# File lib/autorake.rb, line 50
def compiler *args
  Compiler.new @autorake.incdirs, @autorake.macros, *args
end
expand(dir, file = nil) click to toggle source
# File lib/autorake.rb, line 46
def expand dir, file = nil
  @autorake.directories.expand dir, file
end
has?(name) click to toggle source
# File lib/autorake.rb, line 38
def has? name
  @autorake.features[ name.to_sym]
end
installer(under, files, destdir = nil, params = nil) click to toggle source
# File lib/autorake.rb, line 59
def installer under, files, destdir = nil, params = nil
  not params and case destdir
    when nil, Hash then
      under, files, destdir, params = nil, under, files, destdir
  end
  destdir = expand destdir
  d = ENV[ "DESTDIR"]
  if d then
    d = File.expand_path d
    destdir = File.join d, destdir
  end
  case files
    when Array then
    when nil   then files = []
    else            files = [ files]
  end
  unless @autorake_install then
    task :install   do install_targets   end
    task :uninstall do uninstall_targets end
    @autorake_install = []
  end
  p = {}
  p.update params if params
  @autorake_install.push [ under, files, destdir, p]
end
linker(*args) click to toggle source
# File lib/autorake.rb, line 54
def linker *args
  Linker.new @autorake.libdirs, @autorake.libs, *args
end
load_autorake(filename = nil) click to toggle source
# File lib/autorake.rb, line 85
def load_autorake filename = nil
  filename ||= Configuration::CONFIG_FILE
  @autorake = begin
    YAML.unsafe_load_file filename
  rescue NoMethodError
    YAML.load_file        filename
  end
  @autorake.do_env
end
method_missing(sym, *args, &block) click to toggle source
Calls superclass method
# File lib/autorake.rb, line 29
def method_missing sym, *args, &block
  case sym
    when /\Ahas_(.*?)\??\z/ then has? $1
    when /\Aparm_/          then parm[ $'.to_sym]
    when /\Aexpand_/        then expand $'.upcase
    else                         super
  end
end
parm() click to toggle source
# File lib/autorake.rb, line 42
def parm
  @autorake.parameters
end

Private Instance Methods

dir_entries(dir) click to toggle source
# File lib/autorake.rb, line 122
def dir_entries dir
  (Dir.entries dir) - %w(. ..)
end
install(under, src, dir, params, depth) click to toggle source
# File lib/autorake.rb, line 126
def install under, src, dir, params, depth
  paths_for_install under, src, dir, depth do |dst,here,there|
    install under, there, dir, params, 0 if there
    if File.directory? here or not File.exist? here then
      mkdir dst unless File.directory? dst
      if params[ :recursive] then
        (dir_entries here).each { |e|
          install under, (File.join src, e), dir, params, depth+1
        }
      end
    elsif File.symlink? here then
      rm dst if File.exist? dst
      rdl = File.readlink here
      ln_s rdl, dst
    else
      cp here, dst
    end
    u = params[ :user]
    g = params[ :group]
    u, g = u.split ":" if u and not g
    chown u, g, dst if u or g
    m = params[ :mode]
    s = params[ :umask]
    m ||= s && (File.stat dst).mode & ~s & 0777
    chmod m, dst if m
  end
end
install_targets() click to toggle source
# File lib/autorake.rb, line 97
def install_targets
  @autorake_install.each { |under,files,destdir,params|
    File.directory? destdir or mkdir_p destdir
    files.each { |f| install under, f, destdir, params, 0 }
  }
end
paths_for_install(under, src, dir, depth) { |dst, here, there| ... } click to toggle source
# File lib/autorake.rb, line 112
def paths_for_install under, src, dir, depth
  dst = File.join dir, src
  here = under ? (File.join under, src) : src
  if depth.zero? then
    there, = File.split src
    there = nil if there == "."
  end
  yield dst, here, there
end
uninstall(under, src, dir, params, depth) click to toggle source
# File lib/autorake.rb, line 154
def uninstall under, src, dir, params, depth
  paths_for_install under, src, dir, depth do |dst,here,there|
    if File.directory? dst then
      if params[ :recursive] then
        (dir_entries dst).each { |e|
          uninstall under, (File.join src, e), dir, params, depth+1
        }
      end
      rmdir dst
    elsif File.exist? dst or File.symlink? dst then
      rm dst
    end
    if there and (dir_entries there).empty? then
      uninstall under, there, dir, params, 0
    end
  end
end
uninstall_targets() click to toggle source
# File lib/autorake.rb, line 104
def uninstall_targets
  @autorake_install.reverse.each { |under,files,destdir,params|
    files.each { |f| uninstall under, f, destdir, params, 0 }
    File.directory? destdir and (dir_entries destdir).empty? and
      rmdir destdir
  }
end