forked from cfis/libxml-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
190 lines (156 loc) · 4.81 KB
/
Rakefile
File metadata and controls
190 lines (156 loc) · 4.81 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
#!/usr/bin/env ruby
# Be sure to set ENV['RUBYFORGE_USERNAME'] to use publish.
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'date'
# ------- Default Package ----------
FILES = FileList[
'Rakefile',
'CHANGES',
'LICENSE',
'README',
'setup.rb',
'doc/**/*',
'ext/libxml/*',
'ext/mingw/Rakefile',
'ext/mingw/build.rake',
'ext/vc/*.sln',
'ext/vc/*.vcproj',
'lib/**/*',
'benchmark/**/*',
'test/**/*'
]
# Default GEM Specification
default_spec = Gem::Specification.new do |spec|
spec.name = "libxml-ruby"
spec.homepage = "http://libxml.rubyforge.org/"
spec.summary = "Ruby libxml bindings"
spec.description = <<-EOF
The Libxml-Ruby project provides Ruby language bindings for the GNOME
Libxml2 XML toolkit. It is free software, released under the MIT License.
Libxml-ruby's primary advantage over REXML is performance - if speed
is your need, these are good libraries to consider, as demonstrated
by the informal benchmark below.
EOF
# Determine the current version of the software
spec.version =
if File.read('ext/libxml/ruby_xml_version.h') =~ /\s*RUBY_LIBXML_VERSION\s*['"](\d.+)['"]/
CURRENT_VERSION = $1
else
CURRENT_VERSION = "0.0.0"
end
spec.author = "Charlie Savage"
spec.email = "libxml-devel@rubyforge.org"
spec.platform = Gem::Platform::RUBY
spec.require_paths = ["lib", "ext/libxml"]
spec.bindir = "bin"
spec.extensions = ["ext/libxml/extconf.rb"]
spec.files = FILES.to_a
spec.test_files = Dir.glob("test/tc_*.rb")
spec.required_ruby_version = '>= 1.8.4'
spec.date = DateTime.now
spec.rubyforge_project = 'libxml'
spec.has_rdoc = true
end
spec_file = "#{default_spec.name}.gemspec"
desc "Create #{spec_file}"
file spec_file => "Rakefile" do
File.open(spec_file, "w") do |file|
file.puts default_spec.to_ruby
end
end
# Rake task to build the default package
Rake::GemPackageTask.new(default_spec) do |pkg|
pkg.package_dir = 'admin/pkg'
pkg.need_tar = true
end
# ------- Windows GEM ----------
if RUBY_PLATFORM.match(/win32|mingw32/)
binaries = (FileList['ext/mingw/*.so',
'ext/mingw/*.dll*'])
# Windows specification
win_spec = default_spec.clone
win_spec.extensions = ['ext/mingw/Rakefile']
win_spec.platform = Gem::Platform::CURRENT
win_spec.files += binaries.to_a
# Rake task to build the windows package
Rake::GemPackageTask.new(win_spec) do |pkg|
pkg.package_dir = 'admin/pkg'
pkg.need_tar = false
end
end
# --------- RDoc Documentation ---------
desc "Generate rdoc documentation"
Rake::RDocTask.new("rdoc") do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "LibXML"
# Show source inline with line numbers
rdoc.options << "--line-numbers"
# Make the readme file the start page for the generated html
rdoc.options << '--main' << 'README'
rdoc.rdoc_files.include('doc/*.rdoc',
'ext/**/libxml.c',
'ext/**/ruby_xml.c',
'ext/**/*.c',
'lib/**/*.rb',
'CHANGES',
'README',
'LICENSE')
end
Rake::TestTask.new do |t|
t.libs << "test"
t.libs << "lib"
t.libs << "ext/libxml"
end
if not RUBY_PLATFORM.match(/mswin32/i)
Rake::Task[:test].prerequisites << :extensions
end
task :default => :package
task :build => :extensions
task :extension => :build
ext = Config::CONFIG["DLEXT"]
task :extensions => ["ext/libxml/libxml_ruby.#{ext}"]
namespace :extensions do
task :clean do
Dir.chdir("ext/libxml") do
sh "rm -f Makefile"
sh "rm -f *.{o,so,bundle,log}"
end
end
end
# --------- Publish Website to Rubyforge ---------
desc "publish website (uses rsync)"
task :publish => [:publish_website, :publish_rdoc]
task :publish_website do
unixname = 'libxml'
username = ENV['RUBYFORGE_USERNAME']
dir = 'admin/web'
url = "#{username}@rubyforge.org:/var/www/gforge-projects/#{unixname}"
dir = dir.chomp('/') + '/'
# Using commandline filter options didn't seem to work, so
# I opted for creating an .rsync_filter file for all cases.
protect = %w{usage statcvs statsvn robot.txt wiki}
exclude = %w{.svn}
rsync_file = File.join(dir,'.rsync-filter')
unless File.file?(rsync_file)
File.open(rsync_file, 'w') do |f|
exclude.each{|e| f << "- #{e}\n"}
protect.each{|e| f << "P #{e}\n"}
end
end
# maybe -p ?
cmd = "rsync -rLvz --delete-after --filter='dir-merge #{rsync_file}' #{dir} #{url}"
sh cmd
end
task :publish_rdoc do
unixname = 'libxml'
username = ENV['RUBYFORGE_USERNAME']
dir = 'doc/rdoc'
url = "#{username}@rubyforge.org:/var/www/gforge-projects/#{unixname}/rdoc"
dir = dir.chomp('/') + '/'
# maybe -p ?
cmd = "rsync -rLvz --delete-after #{dir} #{url}"
sh cmd
end