-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
117 lines (103 loc) · 3.54 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright 2007-2008 Wincent Colaiuta
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rubygems'
require 'spec/rake/spectask'
require File.join(File.dirname(__FILE__), 'lib', 'wikitext', 'version.rb')
CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
CLOBBER.include Rake::FileList['ext/wikitext_ragel.c']
task :default => :all
desc 'Build all and run all specs'
task :all => [:make, :spec]
extension_makefile = 'ext/Makefile'
ragel = 'ext/wikitext_ragel.c'
built_extension = "ext/wikitext.#{Config::CONFIG['DLEXT']}" # wikitext.bundle (Darwin), wikitext.so (Linux)
extension_files = FileList[
'ext/Makefile',
'ext/ary.c',
'ext/ary.h',
'ext/parser.c',
'ext/parser.h',
'ext/ruby_compat.h',
'ext/str.c',
'ext/str.h',
'ext/token.c',
'ext/token.h',
'ext/wikitext.c',
'ext/wikitext.h',
'ext/wikitext_ragel.c',
'ext/wikitext_ragel.h'
]
desc 'Build C extension'
task :make => [ragel, extension_makefile, built_extension]
file ragel => ['ext/wikitext_ragel.rl'] do
Dir.chdir('ext') do
# pass the -s switch here because otherwise Ragel is totally silent
# I like to have visual confirmation that it's actually run
sh 'ragel -G2 -s wikitext_ragel.rl'
end
end
file extension_makefile => ['ext/extconf.rb', 'ext/depend'] do
Dir.chdir('ext') do
if RUBY_PLATFORM =~ /darwin/
sh "env ARCHFLAGS='-arch i386' ruby extconf.rb"
else
ruby 'extconf.rb'
end
end
end
file built_extension => extension_files do
Dir.chdir('ext') do
sh 'make && touch .built'
end
end
desc 'Run specs'
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ['--color']
end
Rake::RDocTask.new do |t|
t.rdoc_files.include 'doc/README', 'doc/rdoc.rb'
t.options << '--charset' << 'UTF-8' << '--inline-source'
t.main = 'doc/README'
t.title = 'Wikitext documentation'
end
desc 'Upload RDoc to RubyForge website'
task :upload_rdoc => :rdoc do
sh 'scp -r html/* rubyforge.org:/var/www/gforge-projects/wikitext/'
end
SPEC = Gem::Specification.new do |s|
s.name = 'wikitext'
s.version = Wikitext::VERSION
s.author = 'Wincent Colaiuta'
s.email = '[email protected]'
s.homepage = 'http://wikitext.rubyforge.org/'
s.rubyforge_project = 'wikitext'
s.platform = Gem::Platform::RUBY
s.summary = 'Wikitext-to-HTML translator'
s.description = <<-ENDDESC
Wikitext is a fast wikitext-to-HTML translator written in C.
ENDDESC
s.require_paths = ['ext', 'lib']
s.has_rdoc = true
s.files = FileList['spec/*', 'ext/*.{rb,c,h}', 'ext/depend', 'lib/wikitext/*'].to_a
s.extensions = ['ext/extconf.rb']
end
task :package => [:clobber, :all, :gem]
Rake::GemPackageTask.new(SPEC) do |t|
t.need_tar = true
end