Sanitized StringValue() usage.
[ruby-eet.git] / Rakefile
1 # $Id: Rakefile 22 2005-04-09 16:18:02Z tilman $
2
3 require "rbconfig"
4 require "rake/clean"
5 require "rake/testtask"
6 require "rake/rdoctask"
7 require "rake/packagetask"
8 require "rake/contrib/compositepublisher"
9 require "rake/contrib/sshpublisher"
10
11 # make sure we run at least Rake 0.5.0
12 if (RAKEVERSION.split(".").map { |p| p.to_i } <=> [0, 5, 0]) < 0
13         raise("Rake 0.5.0 or greater required")
14 end
15
16 PKG_NAME = "ruby-eet"
17 PKG_VERSION = File.read("lib/eet.rb").
18               match(/^\s*VERSION = \"(.*)\"\s$/).captures.first
19
20 ext_obj = "ext/ext.o"
21 ext_lib = "ext/eet_ext.so"
22
23 CLOBBER.include(ext_obj)
24 CLOBBER.include(ext_lib)
25 CLOBBER.include(FileList["test/*.eet"])
26
27 archdir = Config::CONFIG["archdir"]
28 sitearchdir = Config::CONFIG["sitearchdir"]
29 libdir = Config::CONFIG["libdir"]
30 sitelibdir = Config::CONFIG["sitelibdir"]
31 rubylib = Config::CONFIG["LIBRUBYARG_SHARED"]
32 destdir = "#{ENV["DESTDIR"]}"
33 eet_cflags = `eet-config --cflags`.strip
34 eet_libs = `eet-config --libs`.strip
35 cflags = "#{ENV["CFLAGS"]} #{eet_cflags}"
36 ldflags = "#{ENV["LDFLAGS"]} #{eet_libs}"
37
38 task :default => [ext_lib]
39
40 rule ".o" => [".c"] do |t|
41         sh "cc #{cflags} -fPIC -I #{archdir} #{t.source} -c -o #{t.name}"
42 end
43
44 file ext_lib => ext_obj do |t|
45         sh "cc #{ldflags} -shared -Wl -L #{libdir} #{rubylib} " +
46            "#{t.prerequisites.join(" ")} -o #{t.name}"
47 end
48
49 task :install => [ext_lib] do |t|
50         FileUtils::Verbose.install(ext_lib, destdir + sitearchdir,
51                                    :mode => 0755)
52         FileUtils::Verbose.install("lib/eet.rb", destdir + sitelibdir,
53                                    :mode => 0644)
54 end
55
56 task :test => [ext_lib]
57
58 Rake::TestTask.new do |t|
59         t.libs = ["lib", "ext", "test"]
60         t.test_files = FileList["test/test_*.rb"]
61         t.verbose = true
62 end
63
64 Rake::RDocTask.new do |t|
65         t.rdoc_dir = "doc"
66         t.title = "Ruby-EET - EET bindings for Ruby"
67         t.options = ["--line-numbers", "--inline-source", "--main", "README"]
68         t.rdoc_files.include("README", "COPYING", "AUTHORS", "ChangeLog",
69                              "NEWS", "ext/ext.c", "lib/eet.rb")
70 end
71
72 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
73         t.need_tar_gz = true
74         t.package_files.include("[A-Z]*", "ext/*.c", "lib/*.rb", "test/*.rb")
75 end
76
77 task :publish => [:rdoc, :package] do
78         p = Rake::CompositePublisher.new
79         p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
80                                              "public_html/docs/" +
81                                              PKG_NAME, "doc"))
82         p.add(Rake::SshFilePublisher.new("code-monkey.de",
83                                          ".", "pkg",
84                                          "#{PKG_NAME}-#{PKG_VERSION}.tar.gz"))
85         p.upload
86 end