Skip to content

Commit

Permalink
Rake tasks to build extension via SWIG. Clean and ignore intermediate…
Browse files Browse the repository at this point in the history
… files.
  • Loading branch information
wtaysom committed Oct 6, 2010
1 parent 538041e commit dc13602
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
pkg
*.swp

# SWIG Files
swig/Makefile
swig/autom4te.cache/
swig/config.log
swig/config.status
swig/configure
swig/rglpk.c

# ext Files
ext/Makefile
ext/conftest.dSYM/
ext/mkmf.log
ext/rglpk.bundle
ext/rglpk.o
34 changes: 30 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
require 'rake/clean'

# Copied from hoe.
def paragraphs_of(path, *paragraphs)
File.read(path).split(/\n\n+/).values_at(*paragraphs)
end

def in_dir(path)
original_dir = Dir.pwd
Dir.chdir(path)
yield
ensure
Dir.chdir(original_dir)
end

begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
Expand Down Expand Up @@ -30,12 +40,28 @@ desc "Use extconf.rb and make to build the extension."
task :build_extension => EXTENSION

file EXTENSION => 'ext/rglpk.c' do
Dir.chdir('ext')
system("ruby extconf.rb")
system("make")
Dir.chdir('..')
in_dir('ext') do
system("ruby extconf.rb")
system("make")
end
end

CLEAN.include('ext/Makefile', 'ext/conftest.dSYM', 'ext/mkmf.log',
'ext/rglpk.bundle', 'ext/rglpk.o')

file 'ext/rglpk.c' => 'swig/glpk.i' do
in_dir('swig') do
system("autoconf")
system("configure")
system("make wrap")
end
end

CLEAN.include('swig/Makefile', 'swig/autom4te.cache', 'swig/config.log',
'swig/config.status', 'swig/configure', 'swig/rglpk.c')

CLOBBER.include('ext/rglpk.c')

desc "Run Test::Unit tests."
task :test => :build_extension do
system("ruby test/test_all.rb")
Expand Down

0 comments on commit dc13602

Please sign in to comment.