-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
159 lines (137 loc) · 4.4 KB
/
Copy pathRakefile
File metadata and controls
159 lines (137 loc) · 4.4 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
# -*- ruby -*-
# Rakefile: build ruby libvirt bindings
#
# Copyright (C) 2007,2010 Red Hat, Inc.
#
# Distributed under the GNU Lesser General Public License v2.1 or later.
# See COPYING for details
#
# David Lutterkort <dlutter@redhat.com>
# Rakefile for ruby-rpm -*- ruby -*-
require 'rake/clean'
require 'rake/rdoctask'
require 'rake/testtask'
require 'rake/gempackagetask'
require 'rbconfig'
PKG_NAME='ruby-libvirt'
PKG_VERSION='0.4.0'
EXT_CONF='ext/libvirt/extconf.rb'
MAKEFILE="ext/libvirt/Makefile"
LIBVIRT_MODULE="ext/libvirt/_libvirt.so"
SPEC_FILE="ruby-libvirt.spec"
LIBVIRT_SRC=Dir.glob("ext/libvirt/*.c")
LIBVIRT_SRC << MAKEFILE
#
# Additional files for clean/clobber
#
CLEAN.include [ "ext/**/*.o", LIBVIRT_MODULE,
"ext/**/depend" ]
CLOBBER.include [ "config.save", "ext/**/mkmf.log", "ext/**/extconf.h",
MAKEFILE ]
#
# Build locally
#
file MAKEFILE => EXT_CONF do |t|
Dir::chdir(File::dirname(EXT_CONF)) do
extra = ""
args = ARGV.grep(/^--with-libvirt-include=/)
extra += args[0].chomp unless args.empty?
args = ARGV.grep(/^--with-libvirt-lib=/)
extra += " " + args[0].chomp unless args.empty?
unless sh "ruby #{File::basename(EXT_CONF)} #{extra}"
$stderr.puts "Failed to run extconf"
break
end
end
end
file LIBVIRT_MODULE => LIBVIRT_SRC do |t|
Dir::chdir(File::dirname(EXT_CONF)) do
unless sh "make"
$stderr.puts "make failed"
break
end
end
end
desc "Build the native library"
task :build => LIBVIRT_MODULE
#
# Test task
#
Rake::TestTask.new(:test) do |t|
t.test_files = [ 'tests/test_conn.rb', 'tests/test_domain.rb',
'tests/test_interface.rb', 'tests/test_network.rb',
'tests/test_nodedevice.rb', 'tests/test_nwfilter.rb',
'tests/test_open.rb', 'tests/test_secret.rb',
'tests/test_storage.rb' ]
t.libs = [ 'lib', 'ext/libvirt' ]
end
task :test => :build
#
# Documentation tasks
#
RDOC_FILES = FileList[ "README.rdoc", "lib/libvirt.rb",
"ext/libvirt/_libvirt.c", "ext/libvirt/connect.c",
"ext/libvirt/domain.c", "ext/libvirt/interface.c",
"ext/libvirt/network.c", "ext/libvirt/nodedevice.c",
"ext/libvirt/nwfilter.c", "ext/libvirt/secret.c",
"ext/libvirt/storage.c", "ext/libvirt/stream.c" ]
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_dir = "doc/site/api"
rd.rdoc_files.include(RDOC_FILES)
end
Rake::RDocTask.new(:ri) do |rd|
rd.main = "README.rdoc"
rd.rdoc_dir = "doc/ri"
rd.options << "--ri-system"
rd.rdoc_files.include(RDOC_FILES)
end
#
# Splint task
#
task :splint => [ MAKEFILE ] do |t|
Dir::chdir(File::dirname(EXT_CONF)) do
unless sh "splint -I" + Config::CONFIG['vendorarchdir'] + " *.c"
$stderr.puts "Failed to run splint"
break
end
end
end
#
# Package tasks
#
PKG_FILES = FileList[ "Rakefile", "COPYING", "README", "NEWS", "README.rdoc",
"lib/**/*.rb",
"ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
"tests/**/*",
"spec/**/*" ]
DIST_FILES = FileList[ "pkg/*.src.rpm", "pkg/*.gem", "pkg/*.zip",
"pkg/*.tgz" ]
SPEC = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.email = "libvir-list@redhat.com"
s.homepage = "http://libvirt.org/ruby/"
s.summary = "Ruby bindings for LIBVIRT"
s.files = PKG_FILES
s.required_ruby_version = '>= 1.8.1'
s.extensions = "ext/libvirt/extconf.rb"
s.author = "David Lutterkort, Chris Lalancette"
s.rubyforge_project = "None"
s.description = "Ruby bindings for libvirt."
end
Rake::GemPackageTask.new(SPEC) do |pkg|
pkg.need_tar = true
pkg.need_zip = true
end
desc "Build (S)RPM for #{PKG_NAME}"
task :rpm => [ :package ] do |t|
system("sed -e 's/@VERSION@/#{PKG_VERSION}/' #{SPEC_FILE} > pkg/#{SPEC_FILE}")
Dir::chdir("pkg") do |dir|
dir = File::expand_path(".")
system("rpmbuild --define '_topdir #{dir}' --define '_sourcedir #{dir}' --define '_srcrpmdir #{dir}' --define '_rpmdir #{dir}' --define '_builddir #{dir}' -ba #{SPEC_FILE} > rpmbuild.log 2>&1")
if $? != 0
raise "rpmbuild failed"
end
end
end