Permalink
Browse files

Added some rough extension building tasks

* Currently only for Cabinet and Tyrant, but can be adapted easily
* They work, but they don't build cabinet, then tyrant in sequence... not hard to patch though
* Ignored tmp/ and ext/

Signed-off-by: John Mettraux <jmettraux@gmail.com>
  • Loading branch information...
cheapRoc authored and jmettraux committed Feb 10, 2009
1 parent 96f61ee commit 339c034444f17c82cac808d9f97d0ab208d14efe
Showing with 73 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +1 −1 Rakefile
  3. +70 −0 tasks/dev.rb
View
@@ -0,0 +1,2 @@
+ext/*
+tmp/*
View
@@ -7,7 +7,7 @@ require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
-
+require 'tasks/dev'
load 'rufus-tokyo.gemspec'
View
@@ -0,0 +1,70 @@
+ desc "tasks for handling extension libraries"
+ namespace :ext do
+
+ def git_repo
+ {
+ :cabinet => "git://github.com/etrepum/tokyo-cabinet.git",
+ :tyrant => "git://github.com/etrepum/tokyo-tyrant.git"
+ }
+ end
+
+ def extensions
+ [:cabinet, :tyrant]
+ end
+
+ def ext_root_path
+ File.expand_path(File.join(File.dirname(__FILE__), '..', 'ext'))
+ end
+
+ def ext_local_of type
+ File.join(ext_root_path, "tokyo-#{type}")
+ end
+
+ desc "creates the extensions build directory"
+ task :create do
+ mkdir_p ext_root_path
+ end
+
+ desc "removes the extensions build directory"
+ task :remove do
+ rm_rf ext_root_path
+ end
+
+ desc "builds the extensions, takes PREFIX for where to install"
+ task :build => [:create] do
+ extensions.each do |ext|
+ sh "cd #{ext_local_of ext} &&
+ ./configure --prefix=#{ENV['PREFIX'] || '/usr/local'} &&
+ make"
+ end
+ end
+
+ desc "installs the extensions [REQUIRES SUDO AND BUILD_ALL]"
+ task :install do
+ extensions.each do |ext|
+ sh "cd #{ext_local_of ext} && sudo make install"
+ end
+ end
+
+ desc "clones/pulls and builds all extensions, takes PREFIX for where to install"
+ task :build_all => [:create] + extensions + [:build]
+
+ desc "builds and installs all the extensions"
+ task :install_all => [:build_all, :install]
+
+ desc "update all the extensions"
+ task :update_all => extensions
+
+ extensions.each do |ext|
+ desc "clones and/or updates the etrepum/tokyo-#{ext} repo"
+ task ext => [:create] do
+ repo = ext_local_of ext
+ if ! File.directory?(repo)
+ sh "cd #{ext_root_path} && git clone #{git_repo[ext]}"
+ else
+ sh "cd #{repo} && git checkout master && git pull"
+ end
+ end
+ end
+
+ end

0 comments on commit 339c034

Please sign in to comment.