root / trunk / Rakefile

Revision 107, 2.5 kB (checked in by why, 2 years ago)
  • Rakefile: can no longer be built as a gem, dropped win32 support until the next release of Ruby can be patched.
Line 
1require 'rake'
2require 'rake/clean'
3require 'rake/gempackagetask'
4require 'rake/rdoctask'
5require 'rake/testtask'
6require 'fileutils'
7include FileUtils
8
9NAME = "sandbox"
10REV = File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
11VERS = ENV['VERSION'] || ("0.3" + (REV ? ".#{REV}" : ""))
12FILES = %w(COPYING README Rakefile setup.rb {bin,doc,test,extras}/**/* lib/**/*.rb ext/**/extconf.rb ext/**/*.{h,c})
13CLEAN.include ['ext/sand_table/*.{bundle,o,so,obj,pdb,lib,def,exp}', 'ext/sand_table/Makefile',
14               '**/.*.sw?', '*.gem', '.config']
15
16desc "Does a full compile, test run"
17task :default => [:compile, :test]
18
19desc "Compiles all extensions"
20task :compile => [:sand_table] do
21  if Dir.glob(File.join("lib","sand_table.*")).length == 0
22    STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
23    STDERR.puts "Gem actually failed to build.  Your system is"
24    STDERR.puts "NOT configured properly to build Sandbox."
25    STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
26    exit(1)
27  end
28end
29
30desc "Packages up Sandbox."
31task :package => [:clean]
32Rake::PackageTask.new(NAME, VERS) do |p|
33  p.need_tar = true
34  p.package_files.include FILES
35end
36### Add 'sand_table_win32' to task deps
37# Rake::PackageTask.new(NAME, VERS + "-mswin32") do |p|
38#   p.need_tar = true
39#   p.package_files.include FILES
40#   p.package_files.include %w(lib/i386-msvcrt/**/*)
41# end
42
43desc "Run all the tests"
44Rake::TestTask.new do |t|
45    t.libs << "test"
46    t.test_files = FileList['test/test_*.rb']
47    t.verbose = true
48end
49
50extension = "sand_table"
51ext = "ext/sand_table"
52ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
53ext_files = FileList[
54  "#{ext}/*.c",
55  "#{ext}/*.h",
56  "#{ext}/extconf.rb",
57  "#{ext}/Makefile",
58  "lib"
59]
60
61task "lib" do
62  directory "lib"
63end
64
65desc "Builds just the #{extension} extension"
66task extension.to_sym => ["#{ext}/Makefile", ext_so ]
67
68file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
69  Dir.chdir(ext) do ruby "extconf.rb" end
70end
71
72file ext_so => ext_files do
73  Dir.chdir(ext) do
74    sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
75  end
76  cp ext_so, "lib"
77end
78
79desc "Cross-compile the sand_table extension for win32"
80file "sand_table_win32" do
81  cp "extras/mingw-rbconfig.rb", "ext/sand_table/rbconfig.rb"
82  sh "cd ext/sand_table/ && ruby -I. extconf.rb && make"
83  mkdir "lib/i386-msvcrt"
84  mv "ext/sand_table/sand_table.so", "lib/i386-msvcrt/"
85  rm "ext/sand_table/rbconfig.rb"
86end
87
88task :install do
89  sh %{rake package}
90  sh %{sudo gem install pkg/#{NAME}-#{VERS}}
91end
92
93task :uninstall => [:clean] do
94  sh %{sudo gem uninstall #{NAME}}
95end
Note: See TracBrowser for help on using the browser.