-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
187 lines (167 loc) · 4.33 KB
/
Rakefile
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
# -*- ruby -*-
# Rakefile: build ruby libvirt bindings
#
# Copyright (C) 2007,2010 Red Hat, Inc.
# Copyright (C) 2013,2014 Chris Lalancette <[email protected]>
#
# Distributed under the GNU Lesser General Public License v2.1 or later.
# See COPYING for details
#
# David Lutterkort <[email protected]>
# Rakefile for ruby-rpm -*- ruby -*-
require 'rake/clean'
require 'rake/testtask'
require 'rdoc/task'
require 'rubygems/package_task'
PKG_NAME='ruby-libvirt'
PKG_VERSION='0.8.4'
EXT_DIR = "ext/libvirt"
EXTCONF = "#{EXT_DIR}/extconf.rb"
MAKEFILE = "#{EXT_DIR}/Makefile"
LIBVIRT_MODULE = "#{EXT_DIR}/_libvirt.so"
SPEC_FILE = "#{PKG_NAME}.spec"
SRC_FILES = FileList[
"#{EXT_DIR}/_libvirt.c",
"#{EXT_DIR}/common.c",
"#{EXT_DIR}/common.h",
"#{EXT_DIR}/connect.c",
"#{EXT_DIR}/connect.h",
"#{EXT_DIR}/domain.c",
"#{EXT_DIR}/domain.h",
"#{EXT_DIR}/interface.c",
"#{EXT_DIR}/interface.h",
"#{EXT_DIR}/network.c",
"#{EXT_DIR}/network.h",
"#{EXT_DIR}/nodedevice.c",
"#{EXT_DIR}/nodedevice.h",
"#{EXT_DIR}/nwfilter.c",
"#{EXT_DIR}/nwfilter.h",
"#{EXT_DIR}/secret.c",
"#{EXT_DIR}/secret.h",
"#{EXT_DIR}/storage.c",
"#{EXT_DIR}/storage.h",
"#{EXT_DIR}/stream.c",
"#{EXT_DIR}/stream.h",
]
LIB_FILES = FileList[
"lib/libvirt.rb",
]
GEN_FILES = FileList[
MAKEFILE,
"#{EXT_DIR}/extconf.h",
]
#
# Additional files for clean/clobber
#
CLEAN.include [ "#{EXT_DIR}/*.o", LIBVIRT_MODULE ]
CLOBBER.include [ "#{EXT_DIR}/mkmf.log" ] + GEN_FILES
#
# Build locally
#
task :default => :build
file MAKEFILE => EXTCONF do |t|
Dir::chdir(File::dirname(EXTCONF)) do
sh "ruby #{File::basename(EXTCONF)}"
end
end
file LIBVIRT_MODULE => SRC_FILES + [ MAKEFILE ] do |t|
Dir::chdir(File::dirname(EXTCONF)) do
sh "make"
end
end
desc "Build the native library"
task :build => LIBVIRT_MODULE
#
# Test tasks
#
TEST_FILES = FileList[
"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",
"tests/test_stream.rb",
"tests/test_utils.rb",
]
Rake::TestTask.new(:test) do |t|
t.test_files = TEST_FILES
t.libs << EXT_DIR
end
task :test => :build
#
# Documentation tasks
#
RDOC_MAIN = "doc/main.rdoc"
RDOC_FILES = FileList[ RDOC_MAIN ] + SRC_FILES + LIB_FILES
RDoc::Task.new do |rd|
rd.main = RDOC_MAIN
rd.rdoc_dir = "doc/site/api"
rd.rdoc_files.include(RDOC_FILES)
end
RDoc::Task.new(:ri) do |rd|
rd.main = RDOC_MAIN
rd.rdoc_dir = "doc/ri"
rd.options << "--ri-system"
rd.rdoc_files.include(RDOC_FILES)
end
#
# Package tasks
#
PKG_FILES = FileList[
"Rakefile",
"COPYING",
"README.rst",
"NEWS.rst",
EXTCONF,
RDOC_MAIN,
] + SRC_FILES + LIB_FILES + TEST_FILES
SPEC = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.files = PKG_FILES
s.extensions = EXTCONF
s.required_ruby_version = ">= 1.8.1"
s.summary = "Ruby bindings for libvirt"
s.description = <<~EOF
ruby-libvirt allows applications written in Ruby to use the
libvirt API.
EOF
s.authors = ["David Lutterkort", "Chris Lalancette"]
s.license = "LGPL-2.1-or-later"
s.email = "[email protected]"
s.homepage = "https://ruby.libvirt.org/"
s.metadata = {
"source_code_uri" => "https://gitlab.com/libvirt/libvirt-ruby",
"bug_tracker_uri" => "https://gitlab.com/libvirt/libvirt-ruby/-/issues",
"documentation_uri" => "https://ruby.libvirt.org/api/index.html",
}
end
Gem::PackageTask.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|
pkg_dir = File::expand_path("pkg")
sed = [
"sed",
"-e", "'s/@VERSION@/#{PKG_VERSION}/'",
"#{SPEC_FILE}.in", ">#{pkg_dir}/#{SPEC_FILE}",
]
sh sed.join(" ")
rpmbuild = [
"rpmbuild",
"--clean",
"--define", "'_topdir #{pkg_dir}'",
"--define", "'_sourcedir #{pkg_dir}'",
"--define", "'_srcrpmdir #{pkg_dir}'",
"--define", "'_rpmdir #{pkg_dir}'",
"--define", "'_builddir #{pkg_dir}'",
"-ba", "#{pkg_dir}/#{SPEC_FILE}",
]
sh rpmbuild.join(" ")
end