]> git.wincent.com - wikitext.git/blob - Rakefile
Improve efficiency of _Wikitext_pop_all_from_stack
[wikitext.git] / Rakefile
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.
6 #
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.
11 #
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/>.
14
15 require 'rake'
16 require 'rake/clean'
17 require 'rake/gempackagetask'
18 require 'rake/rdoctask'
19 require 'rubygems'
20 require 'spec/rake/spectask'
21 require File.join(File.dirname(__FILE__), 'lib', 'wikitext', 'version.rb')
22
23 CLEAN.include   Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
24 CLOBBER.include Rake::FileList['ext/wikitext_ragel.c']
25
26 task :default => :all
27
28 desc 'Build all and run all specs'
29 task :all => [:make, :spec]
30
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[
35   'ext/Makefile',
36   'ext/ary.c',
37   'ext/ary.h',
38   'ext/parser.c',
39   'ext/parser.h',
40   'ext/ruby_compat.h',
41   'ext/str.c',
42   'ext/str.h',
43   'ext/token.c',
44   'ext/token.h',
45   'ext/wikitext.c',
46   'ext/wikitext.h',
47   'ext/wikitext_ragel.c',
48   'ext/wikitext_ragel.h'
49 ]
50
51 desc 'Build C extension'
52 task :make => [ragel, extension_makefile, built_extension]
53
54 file ragel => ['ext/wikitext_ragel.rl'] do
55   Dir.chdir('ext') 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'
59   end
60 end
61
62 file extension_makefile => ['ext/extconf.rb', 'ext/depend', ragel] do
63   Dir.chdir('ext') do
64     if RUBY_PLATFORM =~ /darwin/
65       sh "env ARCHFLAGS='-arch i386' ruby extconf.rb"
66     else
67       ruby 'extconf.rb'
68     end
69   end
70 end
71
72 file built_extension => extension_files do
73   Dir.chdir('ext') do
74     sh 'make && touch .built'
75   end
76 end
77
78 desc 'Run specs'
79 Spec::Rake::SpecTask.new('spec') do |t|
80   t.spec_files  = FileList['spec/**/*_spec.rb']
81   t.spec_opts   = ['--color']
82 end
83
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'
87   t.main              = 'doc/README'
88   t.title             = 'Wikitext documentation'
89 end
90
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/'
94 end
95
96 SPEC = Gem::Specification.new do |s|
97   s.name              = 'wikitext'
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.
107   ENDDESC
108   s.require_paths     = ['ext', 'lib']
109   s.has_rdoc          = true
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']
112 end
113
114 task :gem => [:make]
115
116 task :package => [:clobber, :all, :gem]
117 Rake::GemPackageTask.new(SPEC) do |t|
118   t.need_tar      = true
119 end
120