This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
forked from apiaryio/redsnow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (56 loc) · 1.65 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
begin
require 'bundler/gem_tasks'
rescue LoadError
puts 'Cannot load bundler/gem_tasks'
end
begin
require 'rake/testtask'
rescue LoadError
puts 'Cannot load rake/testtask'
end
begin
require 'ffi'
rescue LoadError
puts 'Cannot load ffi'
end
begin
require 'yard'
rescue LoadError
puts 'Cannot load yard'
end
task default: :compile
desc 'Compile extension'
task :compile do
prefix = FFI::Platform.mac? ? '' : 'lib.target/'
# Path to compiled drafter library
path = File.expand_path("ext/drafter/build/out/Release/#{prefix}libdrafter.#{FFI::Platform::LIBSUFFIX}", File.dirname(__FILE__))
puts "Path to library #{path}"
if !File.exist?(path) || ENV['RECOMPILE']
unless File.directory?(File.expand_path('ext/drafter/src'))
puts 'Initializing submodules (if required)...'
`git submodule update --init --recursive 2>/dev/null`
end
puts 'Compiling extension...'
`cd #{File.expand_path('ext/drafter/')} && ./configure --shared && make`
status = $CHILD_STATUS.to_i
if status == 0
puts 'Compiling done.'
else
puts 'Compiling error, exiting.'
next # If i'm using exit, abort I have some errors in rake install but gem can be installed
end
else
puts 'Extension already compiled. To recompile set env variable RECOMPILE=true.'
end
end
desc 'Run tests'
Rake::TestTask.new(:test) do |test|
Rake::Task['compile'].invoke
test.libs << 'lib' << 'test'
test.test_files = FileList['test/*_test.rb']
test.verbose = true
end
# ----- Documentation tasks ---------------------------------------------------
YARD::Rake::YardocTask.new(:doc) do |t|
t.options = %w( --embed-mixins --markup=markdown )
end