view Rakefile @ 28:a666afdaa9c9

Added rakefile and manual
author unexist
date Fri, 22 Jan 2010 15:44:28 +0100
parents
children
line wrap: on
line source
#
# @package sur
#
# @file Rake build file
# @copyright (c) 2005-2010 Christoph Kappel <unexist@dorfelite.net>
# @version $Id: Rakefile,v 28 1264171468.0-3600 unexist $
#
# This program can be distributed under the terms of the GNU GPL.
# See the file COPYING.
#

require("mkmf")
require("fileutils")

# 
# Settings
#
# Options {{{
@options = {
  "destdir"   => "",
  "prefix"    => "/usr",
  "manprefix" => "$(prefix)/share/man",
  "bindir"    => "$(destdir)/$(prefix)/bin",
  "extdir"    => "$(destdir)/$(sitelibdir)/subtly",
  "mandir"    => "$(destdir)/$(manprefix)/man1"
} # }}}

# Lists {{{
PG_SUY = "bin/subtly"
PG_SRC = FileList["subtly/*.rb"]
# }}}

# 
# Tasks
#
# Task: default {{{
desc("Just install")
task(:default => [:install])
# }}}

# Task: install {{{
desc("Install sur")
task(:install) do
  # Get options
  @options.each_key do |k|
    if(!ENV[k].nil?)
      @options[k] = ENV[k]
    end
  end

  # Expand options
  @options.each do |k, v|
    @options[k] = Config.expand(v, CONFIG.merge(@options))
  end

  # Make install dirs
  FileUtils.mkdir_p( 
    [
      @options["bindir"],
      @options["extdir"],
      @options["mandir"]
    ]
  )

  # Install files
  message("INSTALL %s\n" % [File.basename(PG_SUY)])
  FileUtils.install(PG_SUY, @options["bindir"], :mode => 0755, :verbose => false)

  PG_SRC.collect do |f|
    message("INSTALL %s\n" % [File.basename(f)])
    FileUtils.install(f, @options["extdir"], :mode => 0644, :verbose => false)
  end

  # Install manpage
  FileList["dist/man/*.*"].collect do |f|
    message("INSTALL %s\n" % [File.basename(f)])
    FileUtils.install(f, @options["mandir"], :mode => 0644, :verbose => false)
  end

  # Set revision
  if(File.exists?(".hg") && (hg = find_executable0("hg")) && (sed = find_executable0("sed")))
    match = `#{hg} tip`.match(/changeset:\s*(\d+).*/)

    if(!match.nil? && 2 == match.size)
      revision = match[1]
    else
      revision = "999999"
    end

    # Update version variable
    file = File.join(@options["extdir"], "runner.rb")
    if(File.file?(file))
      `#{sed} -i -e 's#VERSION = "\\([0-9]\\).\\([0-9]\\)"#VERSION = "\\1.\\2.#{revision}"#' #{file}`
    end
  end  
end # }}}

# Task: help {{{
desc("Show help")
task(:help) do
  puts <<EOF
destdir=PATH     Set intermediate install prefix (current: #{@options["destdir"]})
prefix=PATH      Set install prefix (current: #{@options["prefix"]})
bindir=PATH      Set binary directory (current: #{@options["bindir"]})
mandir=PATH      Set man directory (current: #{@options["mandir"]})
EOF
end # }}}

# Task: test {{{
desc("Run tests")
task(:test => [:build]) do
  if(!ENV["sublet"].nil?)
    require("test/unit/sublet_test")
    require(ENV["sublet"])
  else
    require("test/subtlext_suite")
  end
end # }}}

# vim:ts=2:bs=2:sw=2:et:fdm=marker