Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 166 lines (137 sloc) 4.397 kB
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
1 require 'rubygems'
2 require 'date'
3 require 'rake/gempackagetask'
4443c99 Update rake files to include rdoc.
cfis authored
4 require 'rake/rdoctask'
abb5992 Add rake test patch from Aaron Patterson.
seanc authored
5 require 'rake/testtask'
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
6 require 'date'
7
abb5992 Add rake test patch from Aaron Patterson.
seanc authored
8 # what sort of extension are we building?
9 ext = Config::CONFIG["DLEXT"]
4d99885 Rename libxml.so to ruby_libxml.so
cfis authored
10 SO_NAME = "libxml_ruby.so"
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
11
12 # ------- Default Package ----------
13 FILES = FileList[
14 'README',
15 'LICENSE',
16 'CHANGES',
30ab65e Updated Rakefile.
transami authored
17 'NOTES',
d836a77 Added setup.rb to gem and tgz archives.
cfis authored
18 'setup.rb',
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
19 'doc/**/*',
a6078b9 Fix up gem build script.
cfis authored
20 'ext/**/*',
21 'lib/**/*',
22 'mingw/*.rake',
23 'mingw/*.dll',
24 'mingw/*.so',
221bf90 DOH - The directory test/model was not included in the GEM, thereby m…
cfis authored
25 'test/**/*',
a6078b9 Fix up gem build script.
cfis authored
26 'vc/*.sln',
30ab65e Updated Rakefile.
transami authored
27 'vc/*.vcproj'
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
28 ]
29
30 # Default GEM Specification
31 default_spec = Gem::Specification.new do |spec|
32 spec.name = "libxml-ruby"
33
34 spec.homepage = "http://libxml.rubyforge.org/"
35 spec.summary = "Ruby libxml bindings"
36 spec.description = <<-EOF
37 The Libxml-Ruby project provides Ruby language bindings for the GNOME
38 Libxml2 XML toolkit. It is free software, released under the MIT License.
39 Libxml-ruby's primary advantage over REXML is performance - if speed
40 is your need, these are good libraries to consider, as demonstrated
41 by the informal benchmark below.
42 EOF
43
44 # Determine the current version of the software
45 spec.version =
606f47d Add vc project to built gem.
cfis authored
46 if File.read('ext/libxml/version.h') =~ /\s*RUBY_LIBXML_VERSION\s*['"](\d.+)['"]/
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
47 CURRENT_VERSION = $1
48 else
49 CURRENT_VERSION = "0.0.0"
50 end
51
52 spec.author = "Charlie Savage"
0f6aa2e Minor cleanup of tests and readme files.
cfis authored
53 spec.email = "libxml-devel@rubyforge.org"
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
54 spec.platform = Gem::Platform::RUBY
30ab65e Updated Rakefile.
transami authored
55 spec.require_path = ["lib", "ext/libxml"]
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
56 spec.bindir = "bin"
57 spec.extensions = ["ext/libxml/extconf.rb"]
58 spec.files = FILES.to_a
59 spec.test_files = Dir.glob("test/tc_*.rb")
60
61 spec.required_ruby_version = '>= 1.8.4'
62 spec.date = DateTime.now
30ab65e Updated Rakefile.
transami authored
63 spec.rubyforge_project = 'libxml'
c4ff578 Added rdoc support to package Rakefile.
cfis authored
64
65 spec.has_rdoc = true
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
66 end
67
68 # Rake task to build the default package
69 Rake::GemPackageTask.new(default_spec) do |pkg|
30ab65e Updated Rakefile.
transami authored
70 pkg.package_dir = 'admin/pkg'
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
71 pkg.need_tar = true
72 pkg.need_zip = true
73 end
74
75
76 # ------- Windows Package ----------
a6078b9 Fix up gem build script.
cfis authored
77
78 libraries = [SO_NAME]
79
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
80 # Windows specification
81 win_spec = default_spec.clone
82 win_spec.extensions = []
83 win_spec.platform = Gem::Platform::CURRENT
a6078b9 Fix up gem build script.
cfis authored
84 win_spec.files += libraries.map {|lib_name| "lib/#{lib_name}"}
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
85
86 desc "Create Windows Gem"
87 task :create_win32_gem do
88 # Copy the win32 extension built by MingW - easier to install
89 # since there are no dependencies of msvcr80.dll
90 current_dir = File.expand_path(File.dirname(__FILE__))
91
92 libraries.each do |file_name|
a6078b9 Fix up gem build script.
cfis authored
93 source = File.join(current_dir, 'mingw', file_name)
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
94 target = File.join(current_dir, 'lib', file_name)
95 cp(source, target)
96 end
97
30ab65e Updated Rakefile.
transami authored
98 # Create the gem, then move it to admin/pkg
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
99 Gem::Builder.new(win_spec).build
100 gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
30ab65e Updated Rakefile.
transami authored
101 mv(gem_file, "admin/pkg/#{gem_file}")
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
102
103 # Remove win extension from top level directory
104 libraries.each do |file_name|
105 target = File.join(current_dir, 'lib', file_name)
106 rm(target)
107 end
108 end
109
a8b897d Update to gem file.
cfis authored
110
111 # --------- RDoc Documentation ------
112 desc "Generate rdoc documentation"
113 Rake::RDocTask.new("rdoc") do |rdoc|
114 rdoc.rdoc_dir = 'doc'
115 rdoc.title = "libxml-ruby"
116 # Show source inline with line numbers
117 rdoc.options << "--inline-source" << "--line-numbers"
4443c99 Update rake files to include rdoc.
cfis authored
118 # Make the readme file the start page for the generated html
119 rdoc.options << '--main' << 'README'
120 rdoc.rdoc_files.include('doc/*.rdoc',
121 'ext/**/*.c',
122 'lib/**/*.rb',
123 'CHANGES',
124 'README',
125 'LICENSE',
126 'VERSION')
a8b897d Update to gem file.
cfis authored
127 end
128
504047b Make the package task depend on the rdoc task.
cfis authored
129 task :package => :rdoc
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
130 task :package => :create_win32_gem
30ab65e Updated Rakefile.
transami authored
131
24c0213 Update for building gems, precompiles binaries for Windows.
cfis authored
132 task :default => :package
abb5992 Add rake test patch from Aaron Patterson.
seanc authored
133
134 Rake::TestTask.new do |t|
135 t.libs << "test"
136 t.libs << "ext"
137 end
138
0ba6cd8 Apply patch http://rubyforge.org/tracker/index.php?func=detail&aid=21…
cfis authored
139 if not RUBY_PLATFORM.match(/mswin32/i)
140 Rake::Task[:test].prerequisites << :extensions
141 end
142
abb5992 Add rake test patch from Aaron Patterson.
seanc authored
143 task :build => :extensions
144 task :extension => :build
145
146 task :extensions => ["ext/libxml/libxml_ruby.#{ext}"]
147 file "ext/libxml/libxml_ruby.#{ext}" =>
148 ["ext/libxml/Makefile"] + FileList["ext/libxml/*.{c,h}"].to_a do |t|
149 Dir.chdir("ext/libxml") { sh "make" }
150 end
151
152 namespace :extensions do
153 task :clean do
154 Dir.chdir("ext/libxml") do
155 sh "rm -f Makefile"
156 sh "rm -f *.{o,so,bundle,log}"
157 end
158 end
159 end
160
161 file "ext/libxml/Makefile" => ["ext/libxml/extconf.rb"] do
162
163 command = ["ruby"] + $:.map{|dir| "-I#{File.expand_path dir}"} + ["extconf.rb"]
164 Dir.chdir("ext/libxml") { sh *command }
165 end
Something went wrong with that request. Please try again.