1 # Copyright 2007-2009 Wincent Colaiuta
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 require 'rake/gempackagetask'
18 require 'rake/rdoctask'
20 require 'spec/rake/spectask'
21 require File.join(File.dirname(__FILE__), 'lib', 'wikitext', 'version.rb')
23 CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
24 CLOBBER.include Rake::FileList['ext/wikitext_ragel.c']
28 desc 'Build all and run all specs'
29 task :all => [:make, :spec]
31 extension_makefile = 'ext/Makefile'
32 ragel = 'ext/wikitext_ragel.c'
33 built_extension = "ext/wikitext.#{Config::CONFIG['DLEXT']}" # wikitext.bundle (Darwin), wikitext.so (Linux)
34 extension_files = FileList[
47 'ext/wikitext_ragel.c',
48 'ext/wikitext_ragel.h'
51 desc 'Build C extension'
52 task :make => [ragel, extension_makefile, built_extension]
54 file ragel => ['ext/wikitext_ragel.rl'] do
56 # pass the -s switch here because otherwise Ragel is totally silent
57 # I like to have visual confirmation that it's actually run
58 sh 'ragel -G2 -s wikitext_ragel.rl'
62 file extension_makefile => ['ext/extconf.rb', 'ext/depend', ragel] do
64 if RUBY_PLATFORM =~ /darwin/
65 sh "env ARCHFLAGS='-arch i386' ruby extconf.rb"
72 file built_extension => extension_files do
74 sh 'make && touch .built'
79 Spec::Rake::SpecTask.new('spec') do |t|
80 t.spec_files = FileList['spec/**/*_spec.rb']
81 t.spec_opts = ['--color']
84 Rake::RDocTask.new do |t|
85 t.rdoc_files.include 'doc/README', 'doc/RELEASE-NOTES', 'doc/rdoc.rb'
86 t.options << '--charset' << 'UTF-8' << '--inline-source'
88 t.title = 'Wikitext documentation'
91 desc 'Upload RDoc to RubyForge website'
92 task :upload_rdoc => :rdoc do
93 sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/wikitext/'
96 SPEC = Gem::Specification.new do |s|
98 s.version = Wikitext::VERSION
99 s.author = 'Wincent Colaiuta'
100 s.email = 'win@wincent.com'
101 s.homepage = 'http://wikitext.rubyforge.org/'
102 s.rubyforge_project = 'wikitext'
103 s.platform = Gem::Platform::RUBY
104 s.summary = 'Wikitext-to-HTML translator'
105 s.description = <<-ENDDESC
106 Wikitext is a fast wikitext-to-HTML translator written in C.
108 s.require_paths = ['ext', 'lib']
110 s.files = FileList['spec/*', 'ext/wikitext_ragel.c', 'ext/*.{rb,c,h}', 'ext/depend', 'lib/wikitext/*', 'rails/init.rb'].to_a
111 s.extensions = ['ext/extconf.rb']
116 task :package => [:clobber, :all, :gem]
117 Rake::GemPackageTask.new(SPEC) do |t|