public
Description: Multi-player, turn-based games library.
Homepage: http://vying.org
Clone URL: git://github.com/eki/vying.git
vying / Rakefile
100644 197 lines (163 sloc) 4.372 kb
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
require 'rake'
require 'rake/testtask'
require 'rake/clean'
require 'fileutils'
include FileUtils
 
###
### cleanup tasks
###
 
CLEAN.include( 'ext/**/*.o', 'ext/**/*.so', 'ext/**/*.class', 'ext/**/*.jar' )
CLOBBER.include( 'pkg', 'doc/api', 'doc/coverage', 'lib/vying/version.rb' )
 
###
### test tasks
###
 
Rake::TestTask.new do |t|
  t.libs << "test" << "ext"
  t.ruby_opts << "-r rubygems"
  t.test_files = FileList['test/**/*_test.rb']
end
 
task :"test_sans_ext" => [:clobber, :test, :compile]
 
Rake::TestTask.new do |t|
  t.name = "test_core"
  t.libs << "test" << "ext"
  t.ruby_opts << "-r rubygems"
  t.test_files = FileList.new( 'test/**/*_test.rb' ) do |list|
    list.exclude( 'test/vying/rules/**/*' )
  end
end
 
###
### rdoc task
###
 
begin
  require 'hanna/rdoctask'
rescue LoadError
  require 'rake/rdoctask'
end
 
Rake::RDocTask.new do |rd|
  rd.main = "README"
  rd.rdoc_dir = "doc/api"
  rd.rdoc_files.include( "README", "LICENSE", "COPYING",
                         "lib/**/*.rb" ).
                exclude( "lib/**/board/shapes/*.rb",
                         "lib/**/special_moves/*.rb",
                         "lib/**/rules/**/*.rb",
                         "lib/**/cli/*.rb" )
end
 
###
### task to compile the C extension
###
 
desc "compile the C extension part of the vying library"
task :compile do
  ruby = ($0 =~ /rake(.+)/) ? "ruby#{$1}" : "ruby"
  sh %{cd ext/vying/c/parts/board && #{ruby} ./extconf.rb && make}
end
 
###
### task to compile the Java extension
###
 
desc "compile the Java extension part of the vying library"
task :compile_java do
  cp = ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"]
  cp = cp.join( File::PATH_SEPARATOR )
 
  dir = "ext/vying/java/parts/board"
 
  sh %{cd #{dir} && javac -cp #{cp} *.java}
  sh %{cd #{dir} && jar cf vying_board_ext.jar *.class}
  sh %{mv #{dir}/vying_board_ext.jar ext/}
end
 
###
### the default task
###
 
task :default => [:clean, :compile, :test]
 
###
### RubyGems related tasks follow:
###
 
# Try to load the version number -- it's okay if it's not available
 
begin
  require 'lib/vying/version.rb'
rescue Exception
  module Vying; end
end
 
desc "Appends the value in VERSION to lib/vying/version.rb"
task :version do
  v = ENV['VERSION']
  raise "provide a VERSION via the environment variable" unless v
  sh %{echo 'module Vying; VERSION = "#{v}"; end' >> lib/vying/version.rb}
end
 
begin
  require 'rubygems'
  require 'rake/gempackagetask'
rescue Exception
  nil
end
 
if defined?( Gem ) && Vying.const_defined?( 'VERSION' )
  task :gem => [:clean, :compile, :test]
 
  PKG_FILES = FileList[
    'lib/**/*',
    'bin/vying',
    'test/**/*',
    'ext/**/*',
    'doc/**/*',
    'Rakefile',
    'README',
    'LICENSE',
    'COPYING']
 
  spec = Gem::Specification.new do |s|
    s.name = 'vying'
    s.version = Vying::VERSION
    s.summary = 'Vying Game Library'
    s.description = 'Vying is a game library.'
    s.homepage = 'http://vying.org/dev/public'
    s.rubyforge_project = 'silence stupid WARNINGS'
    s.has_rdoc = true
    s.files = PKG_FILES.to_a
    s.extensions = "ext/vying/c/parts/board/extconf.rb"
    s.executables = ['vying']
    s.require_paths << "ext"
    s.author = 'Eric K Idema'
    s.email = 'eki@vying.org'
  end
 
  package_task = Rake::GemPackageTask.new( spec ) do |pkg|
    pkg.need_tar_gz = true
    pkg.need_zip = true
  end
 
  PKG_FILES_NO_EXT = FileList[
    'lib/**/*',
    'bin/vying',
    'test/**/*',
    'doc/**/*',
    'Rakefile',
    'README',
    'LICENSE',
    'COPYING']
 
  spec_pure = Gem::Specification.new do |s|
    s.name = 'vying-pure'
    s.version = Vying::VERSION
    s.summary = 'Vying Game Library (Pure Ruby)'
    s.description = 'Vying is a game library.'
    s.homepage = 'http://vying.org/dev/public'
    s.rubyforge_project = 'silence stupid WARNINGS'
    s.has_rdoc = true
    s.files = PKG_FILES_NO_EXT.to_a
    s.executables = ['vying']
    s.author = 'Eric K Idema'
    s.email = 'eki@vying.org'
  end
 
  package_task = Rake::GemPackageTask.new( spec_pure ) do |pkg|
    pkg.need_tar_gz = true
    pkg.need_zip = true
  end
end
 
###
### Rcov related tasks follow
###
 
begin
  require 'rcov/rcovtask'
rescue Exception
  nil
end
 
if defined?( Rcov )
  Rcov::RcovTask.new do |t|
    t.libs << "test" << "ext"
    t.test_files = FileList['test/**/*_test.rb']
    t.output_dir = "doc/coverage"
  end
end