1 # Copyright 2007-present Greg Hurrell. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
6 # 1. Redistributions of source code must retain the above copyright notice,
7 # this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright notice,
9 # this list of conditions and the following disclaimer in the documentation
10 # and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 # POSSIBILITY OF SUCH DAMAGE.
28 $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
29 require 'wikitext/version'
31 CLEAN.include Rake::FileList['**/*.so', '**/*.bundle', '**/*.o', '**/mkmf.log', '**/Makefile']
32 CLOBBER.include Rake::FileList['ext/wikitext/wikitext_ragel.c']
36 desc 'Build all and run all specs'
37 task :all => [:make, :spec]
39 extension_makefile = 'ext/wikitext/Makefile'
40 ragel = 'ext/wikitext/wikitext_ragel.c'
41 built_extension = "ext/wikitext/wikitext.#{RbConfig::CONFIG['DLEXT']}" # wikitext.bundle (Darwin), wikitext.so (Linux)
42 extension_files = FileList[
43 'ext/wikitext/Makefile',
46 'ext/wikitext/parser.c',
47 'ext/wikitext/parser.h',
48 'ext/wikitext/ruby_compat.h',
51 'ext/wikitext/token.c',
52 'ext/wikitext/token.h',
53 'ext/wikitext/wikitext.c',
54 'ext/wikitext/wikitext.h',
55 'ext/wikitext/wikitext_ragel.c',
56 'ext/wikitext/wikitext_ragel.h',
59 desc 'Build C extension'
60 task :make => [ragel, extension_makefile, built_extension]
62 file ragel => ['ext/wikitext/wikitext_ragel.rl'] do
63 Dir.chdir('ext/wikitext') do
64 # pass the -s switch here because otherwise Ragel is totally silent
65 # I like to have visual confirmation that it's actually run
66 sh 'ragel -G2 -s wikitext_ragel.rl'
70 file extension_makefile => ['ext/wikitext/extconf.rb', 'ext/wikitext/depend', ragel] do
71 Dir.chdir('ext/wikitext') do
76 file built_extension => extension_files do
77 Dir.chdir('ext/wikitext') do
78 sh 'make && touch .built'
83 task :spec => :make do
84 sh 'bundle exec rspec spec'
87 desc 'Build the YARD HTML files'
89 sh 'bundle exec yardoc -o gh-pages --title Wikitext doc/*.rb - doc/RELEASE-NOTES'
92 desc 'Build gem ("gem build")'
93 task :build => :make do
94 system 'gem build wikitext.gemspec'
97 desc 'Publish gem ("gem push")'
98 task :push => :build do
99 system "gem push wikitext-#{Wikitext::VERSION}.gem"