-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
110 lines (87 loc) · 2.33 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
# -*- mode: ruby; coding: utf-8 -*-
gem "rdoc"
require "tmpdir"
require "rake"
require "rake/clean"
require "rake/testtask"
require "rubygems/package_task"
require "rdoc/task"
begin
require "rspec/core/rake_task"
rescue LoadError
end
begin
require 'rake/extensiontask'
rescue LoadError
end
ENV["RDOCOPT"] = "" if ENV["RDOCOPT"]
if RDoc::VERSION < "4.1"
TMPSRCDIR = Dir.mktmpdir
CLEAN.include(TMPSRCDIR)
end
CLOBBER.include("rdoc")
load "rwx.gemspec"
Gem::PackageTask.new(GEMSPEC) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
pkg.need_tar_bz2 = true
pkg.need_tar_gz = true
end
unless Rake.const_defined?(:ExtensionTask)
desc "Compiles rwx, outputting ext/rwx.so"
task :compile do
cd "ext"
ruby "extconf.rb"
sh "make"
cd ".."
end
else
Rake::ExtensionTask.new('rwx',GEMSPEC) do |t|
t.ext_dir = "ext"
t.source_pattern = "*.cpp"
end
Rake::ExtensionTask.new('rwx',GEMSPEC) do |t|
t.ext_dir = "ext"
t.source_pattern = "*.cpp"
t.cross_compile = true # enable cross compilation (requires cross compile toolchain)
t.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
end
end
Rake::TestTask.new do |t|
t.verbose = true
end
RSpec::Core::RakeTask.new if Object.const_defined?(:RSpec)
RDoc::Task.new do |rdoc|
rdoc.title = "rwx RDocs"
rdoc.main = "README.rdoc"
if RDoc::VERSION < "4.1"
rdoc.rdoc_files.include("*.rdoc", TMPSRCDIR)
# We will have another 'rdoc' task that depends on this task
rdoc.name = :docs
else
rdoc.rdoc_files.include("*.rdoc", "ext/*.cpp")
end
rdoc.rdoc_dir = "rdoc"
end
if RDoc::VERSION < "4.1"
# This task removes the DLL_LOCAL statements temporarily to
# make RDoc work properly. The stripped sources are to be
# found in TMPSRCDIR afterwards.
task :prepare_sources do
rm_r TMPSRCDIR if File.directory?(TMPSRCDIR)
mkdir TMPSRCDIR
#cp "ext/*.cpp", TMPSRCDIR
Dir["ext/*.cpp"].each do |path|
path = path[/\/(.+)/,1]
puts "Removing DLL_LOCAL in #{path}"
File.write("#{TMPSRCDIR}/#{path}",File.read("ext/#{path}").gsub(/DLL_LOCAL\s?/, ""))
end
end
# Removes the temporary directory created by :prepare_sources.
task :clean_sources do
rm_r TMPSRCDIR
end
desc "Generate the RDoc documentation."
task :rdoc => [:prepare_sources, :docs, :clean_sources]
end
task :default => [:compile, :spec]