rake-tasks 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/README +29 -0
- data/Rakefile +51 -0
- data/lib/rake/autotoolstask.rb +58 -0
- data/lib/rake/extensiontask.rb +188 -0
- data/lib/rake/rpmtask.rb +144 -0
- data/lib/rake/swigextensiontask.rb +104 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2008 Steve Sloan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= Rake Task Collection
|
2
|
+
|
3
|
+
This package provides a variety of general-purpose Rake tasks.
|
4
|
+
|
5
|
+
=== Requirements
|
6
|
+
|
7
|
+
All:
|
8
|
+
* Rake[http://rake.rubyforge.org] >= 7.0
|
9
|
+
|
10
|
+
Rake::AutoToolsRPMTask:
|
11
|
+
* ruby-rpm[http://rubyforge.org/projects/ruby-rpm] >= 1.2.3
|
12
|
+
* ruby-devel, rpm-devel
|
13
|
+
|
14
|
+
Rake::ExtensionTask:
|
15
|
+
* ruby-devel
|
16
|
+
|
17
|
+
Rake::RPMTask:
|
18
|
+
* ruby-rpm[http://rubyforge.org/projects/ruby-rpm] >= 1.2.3
|
19
|
+
* ruby-devel, rpm-devel
|
20
|
+
|
21
|
+
Rake::SWIGExtensionTask:
|
22
|
+
* SWIG[http://www.swig.org] >= 1.3.30
|
23
|
+
|
24
|
+
|
25
|
+
Author:: Steve Sloan (mailto:steve@finagle.org)
|
26
|
+
Website:: http://rake-tasks.rubyforge.org
|
27
|
+
Rubyforge:: http://rubyforge.org/projects/rake-tasks
|
28
|
+
Copyright:: Copyright (c) 2008 Steve Sloan
|
29
|
+
License:: MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'rake/contrib/rubyforgepublisher'
|
6
|
+
|
7
|
+
GEM_VERSION = '0.1'
|
8
|
+
|
9
|
+
docs = Rake::RDocTask.new :rdoc do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'html'
|
11
|
+
rdoc.title = "Rake Task Collection"
|
12
|
+
rdoc.options += ['--line-numbers', '--inline-source', '--main', 'README']
|
13
|
+
rdoc.rdoc_files.include 'README', 'MIT-LICENSE'
|
14
|
+
rdoc.rdoc_files.include 'lib/rake/*task.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
GEM_FILES = docs.rdoc_files + FileList[
|
18
|
+
'Rakefile',
|
19
|
+
]
|
20
|
+
|
21
|
+
spec = Gem::Specification.new do |s|
|
22
|
+
s.platform = Gem::Platform::RUBY
|
23
|
+
s.name = 'rake-tasks'
|
24
|
+
s.version = GEM_VERSION
|
25
|
+
s.date = Date.today.to_s
|
26
|
+
s.authors = ['Steve Sloan <steve@finagle.org>']
|
27
|
+
s.summary = 'A collection of general-purpose Rake tasks'
|
28
|
+
s.files = GEM_FILES
|
29
|
+
|
30
|
+
# docs
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.extra_rdoc_files = docs.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
33
|
+
s.rdoc_options = docs.options
|
34
|
+
|
35
|
+
s.add_dependency 'rake', '>= 0.7.0'
|
36
|
+
s.add_dependency 'ruby-rpm', '>= 1.2.3' # for rpmtask, autotoolstask
|
37
|
+
|
38
|
+
# s.description =
|
39
|
+
# s.autorequire = ''
|
40
|
+
# s.test_files = Dir["test/test_*.rb"]
|
41
|
+
# s.extensions << './extconf.rb'
|
42
|
+
# s.require_paths << 'ext'
|
43
|
+
|
44
|
+
end
|
45
|
+
Rake::GemPackageTask.new spec do |pkg|
|
46
|
+
pkg.need_zip = pkg.need_tar = false
|
47
|
+
end
|
48
|
+
|
49
|
+
task :default => :gem
|
50
|
+
|
51
|
+
task :cruise => [:clean, :gem]
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rake/rpmtask'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
class AutoToolsRPMTask < RPMTask
|
5
|
+
|
6
|
+
def initialize( args, &blk )
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def project_dir
|
11
|
+
@project_dir ||= File.dirname @spec_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def define_tasks
|
15
|
+
task @name => @prereqs do |t|
|
16
|
+
re = %r{#{spec.name}-#{spec.version}.*\.tar\.bz2$}
|
17
|
+
src = spec.sources.find { |s| re === s.filename }
|
18
|
+
next unless src
|
19
|
+
|
20
|
+
file File.join( project_dir, src.filename ) do |t|
|
21
|
+
path = File.join File.basename( File.dirname(t.name) ), File.basename(t.name)
|
22
|
+
puts '', '-' * 80,
|
23
|
+
"Creating #{path} ...",
|
24
|
+
'-' * 80
|
25
|
+
|
26
|
+
system( "make -C #{File.dirname(t.name)} dist-bzip2" ) and $?.exitstatus.zero? or raise "Make dist-bzip2 failure"
|
27
|
+
end.invoke
|
28
|
+
end
|
29
|
+
|
30
|
+
file @spec_path => [File.join(project_dir, 'configure')]
|
31
|
+
CLEAN.include @spec_path
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# create the configure script from configure.in by running autogen.sh
|
38
|
+
rule( %r{(^|/)configure$} => [ proc { |f| File.join File.dirname(f), 'configure.in' },
|
39
|
+
proc { |f| File.join File.dirname(f), 'autogen.sh' } ] ) do |r|
|
40
|
+
dir = File.dirname r.name
|
41
|
+
path = File.join File.basename( File.dirname(r.name) ), File.basename(r.name)
|
42
|
+
puts '', '-' * 80,
|
43
|
+
"Creating #{path} ...",
|
44
|
+
'-' * 80
|
45
|
+
system( "cd #{dir} && ./autogen.sh" ) and $?.exitstatus.zero? or raise "Autogen failure"
|
46
|
+
end
|
47
|
+
|
48
|
+
# create the .spec file from .spec.in by running configure
|
49
|
+
rule '.spec' => '.spec.in' do |r|
|
50
|
+
file( File.join( File.dirname(r.name), 'configure' ) ).invoke
|
51
|
+
|
52
|
+
dir = File.dirname r.name
|
53
|
+
path = File.join File.basename( File.dirname(r.name) ), File.basename(r.name)
|
54
|
+
puts '', '-' * 80,
|
55
|
+
"Creating #{path} ...",
|
56
|
+
'-' * 80
|
57
|
+
system( "cd #{dir} && ./configure" ) and $?.exitstatus.zero? or raise "Configure failure"
|
58
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
|
5
|
+
# Rake tasks to build Ruby extensions
|
6
|
+
|
7
|
+
module Rake
|
8
|
+
|
9
|
+
# Create a build task that will generate a Ruby extension (e.g. .so) from one or more
|
10
|
+
# C (.c) or C++ (.cc, .cpp, .cxx) files, and is intended as a replcaement for mkmf.
|
11
|
+
# It determines platform-specific settings (e.g. file extensions, compiler flags, etc.)
|
12
|
+
# from rbconfig (note: examples assume *nix file extensions).
|
13
|
+
#
|
14
|
+
# *Note*: Strings vs Symbols
|
15
|
+
# In places where filenames are expected (e.g. lib_name and objs), Strings are used
|
16
|
+
# as verbatim filenames, while, Symbols have the platform-dependant extension
|
17
|
+
# appended (e.g. '.so' for libraries and '.o' for objects). Also, only Symbols
|
18
|
+
# have #dir prepended to them.
|
19
|
+
#
|
20
|
+
# Example:
|
21
|
+
# desc "build sample extension"
|
22
|
+
# # build sample.so (from foo.{c,cc,cxx,cpp}, through foo.o)
|
23
|
+
# Rake::ExtensionTask.new :sample => :foo do |t|
|
24
|
+
# # all extension files under this directory
|
25
|
+
# t.dir = 'ext'
|
26
|
+
# # link libraries (libbar.so)
|
27
|
+
# t.link_libs << 'bar'
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# Author:: Steve Sloan (mailto:steve@finagle.org)
|
31
|
+
# Copyright:: Copyright (c) 2006 Steve Sloan
|
32
|
+
# License:: GPL
|
33
|
+
|
34
|
+
class ExtensionTask < Rake::TaskLib
|
35
|
+
# The name of the extension
|
36
|
+
attr_accessor :name
|
37
|
+
|
38
|
+
# The filename of the extension library file (e.g. 'extension.so')
|
39
|
+
attr_accessor :lib_name
|
40
|
+
|
41
|
+
# Object files to build and link into the extension.
|
42
|
+
attr_accessor :objs
|
43
|
+
|
44
|
+
# The directory where the extension files (source, output, and
|
45
|
+
# intermediate) are stored.
|
46
|
+
attr_accessor :dir
|
47
|
+
|
48
|
+
# Environment configuration -- i.e. CONFIG from rbconfig, with a few other
|
49
|
+
# settings, and converted to lowercase-symbols.
|
50
|
+
attr_accessor :env
|
51
|
+
|
52
|
+
# Additional link libraries
|
53
|
+
attr_accessor :link_libs
|
54
|
+
|
55
|
+
# Same arguments as Rake::define_task
|
56
|
+
def initialize( args, &blk )
|
57
|
+
@env = @@DefaultEnv.dup
|
58
|
+
@name, @objs = resolve_args(args)
|
59
|
+
set_defaults
|
60
|
+
yield self if block_given?
|
61
|
+
define_tasks
|
62
|
+
end
|
63
|
+
|
64
|
+
# Generate default values. This is called from initialize _before_ the
|
65
|
+
# yield block.
|
66
|
+
#
|
67
|
+
# Defaults:
|
68
|
+
# - lib_name: name.so
|
69
|
+
# - objs: name.o (<- name.{c,cxx,cpp,cc})
|
70
|
+
# - dir: .
|
71
|
+
# - link_libs: <none>
|
72
|
+
def set_defaults
|
73
|
+
@lib_name ||= name.to_sym
|
74
|
+
@objs = [name.to_sym] unless @objs and @objs.any?
|
75
|
+
@dir ||= '.'
|
76
|
+
@link_libs ||= []
|
77
|
+
end
|
78
|
+
|
79
|
+
# Defines the library task.
|
80
|
+
def define_tasks
|
81
|
+
output_objs = @objs.collect { |obj| filepath obj, :objext }
|
82
|
+
output_lib = filepath lib_name, :dlext
|
83
|
+
|
84
|
+
task name => output_lib
|
85
|
+
|
86
|
+
file output_lib => output_objs do |t|
|
87
|
+
sh_cmd :ldshared, :dldflags, :ldflags, {'-L' => :libdirs}, '-o', output_lib, output_objs.join(' '),
|
88
|
+
link_libs.collect { |l| "-l#{l}" }.join(' '), :libs, :dldlibs, :librubyarg_shared
|
89
|
+
end
|
90
|
+
|
91
|
+
CLEAN.include output_objs
|
92
|
+
CLOBBER.include output_lib
|
93
|
+
define_rules
|
94
|
+
end
|
95
|
+
|
96
|
+
# Defines C and C++ source-to-object rules, using the source extensions from env.
|
97
|
+
def define_rules
|
98
|
+
for ext in env[:c_exts]
|
99
|
+
Rake::Task.create_rule '.'+env[:objext] => '.'+ext do |r|
|
100
|
+
sh_cmd :cc, :cflags, :cppflags, {'-D' => :defines}, {'-I' => :includedirs}, {'-I' => :topdir},
|
101
|
+
'-c', '-o', r.name, r.sources
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
for ext in env[:cpp_exts]
|
106
|
+
Rake::Task.create_rule '.'+env[:objext] => '.'+ext do |r|
|
107
|
+
sh_cmd :cxx, :cxxflags, :cppflags, {'-D' => :defines}, {'-I' => :includedirs}, {'-I' => :topdir},
|
108
|
+
'-o', r.name, '-c', r.sources
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class << self
|
114
|
+
# The default environment for all extensions.
|
115
|
+
@@DefaultEnv = {}
|
116
|
+
def env
|
117
|
+
@@DefaultEnv
|
118
|
+
end
|
119
|
+
def env=(e)
|
120
|
+
@@DefaultEnv = e
|
121
|
+
end
|
122
|
+
|
123
|
+
Config::CONFIG.merge(ENV).each { |k, v| @@DefaultEnv[k.downcase.to_sym] = v }
|
124
|
+
@@DefaultEnv = {
|
125
|
+
:cxx => 'c++',
|
126
|
+
:cxxflags => '',
|
127
|
+
:c_exts => ['c'],
|
128
|
+
:cpp_exts => ['cc', 'cxx', 'cpp'],
|
129
|
+
:includedirs => [],
|
130
|
+
:libdirs => [],
|
131
|
+
}.update(@@DefaultEnv)
|
132
|
+
end
|
133
|
+
|
134
|
+
protected
|
135
|
+
|
136
|
+
# Handles convenience filenames:
|
137
|
+
# * f (String) => f
|
138
|
+
# * f (Symbol) => dir/f.ext
|
139
|
+
def filepath( f, ext )
|
140
|
+
ext = env[ext] if Symbol === ext
|
141
|
+
Symbol === f ? File.join( dir, "#{f}.#{ext}" ) : f
|
142
|
+
end
|
143
|
+
|
144
|
+
# Convenience function for cnstructing command lines for build tools.
|
145
|
+
def optify( *opts )
|
146
|
+
return optify(*opts.first) if opts.size == 1 and opts.first.kind_of? Array
|
147
|
+
opts.collect do |opt|
|
148
|
+
case opt
|
149
|
+
when String then opt
|
150
|
+
when Symbol then optify env[opt]
|
151
|
+
when Hash
|
152
|
+
opt.collect do |k, v|
|
153
|
+
v = env[v] if v.kind_of? Symbol
|
154
|
+
if v.kind_of? Array
|
155
|
+
optify v.collect { |w| k.to_s + w.to_s }
|
156
|
+
elsif v
|
157
|
+
k.to_s + v.to_s
|
158
|
+
end
|
159
|
+
end
|
160
|
+
else
|
161
|
+
opt.to_s
|
162
|
+
end
|
163
|
+
end.join(' ').squeeze(' ')
|
164
|
+
end
|
165
|
+
|
166
|
+
def sh_cmd( cmd, *opts )
|
167
|
+
sh optify( cmd, *opts )
|
168
|
+
end
|
169
|
+
|
170
|
+
# For some reason, Rake::TaskManager.resolve_args can't be found, so snarf it.
|
171
|
+
def resolve_args(args)
|
172
|
+
case args
|
173
|
+
when Hash
|
174
|
+
fail "Too Many Task Names: #{args.keys.join(' ')}" if args.size > 1
|
175
|
+
fail "No Task Name Given" if args.size < 1
|
176
|
+
task_name = args.keys[0]
|
177
|
+
deps = args[task_name]
|
178
|
+
deps = [deps] if (String===deps) || (Regexp===deps) || (Proc===deps)
|
179
|
+
else
|
180
|
+
task_name = args
|
181
|
+
deps = []
|
182
|
+
end
|
183
|
+
[task_name, deps]
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
data/lib/rake/rpmtask.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'rpm'
|
7
|
+
|
8
|
+
module RPM
|
9
|
+
unless defined? RPMDir
|
10
|
+
RPMDir, SRPMDir, SourceDir, BuildDir, BuildNameFmt =
|
11
|
+
RPM::expand('%_rpmdir %_srcrpmdir %_sourcedir %_builddir %_build_name_fmt').split
|
12
|
+
raise "Unable to find RPM directory" unless RPMDir and ::File.exists? RPMDir
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# RPM::init_macros *%W{
|
17
|
+
# /usr/lib/rpm/macros
|
18
|
+
# /usr/lib/rpm/i686-linux/macros
|
19
|
+
# /etc/rpm/macros.*
|
20
|
+
# /etc/rpm/macros
|
21
|
+
# /etc/rpm/i686-linux/macros
|
22
|
+
# ~/.rpmmacros
|
23
|
+
# }
|
24
|
+
# #{ File.join( File.dirname(__FILE__), '../rpmmacros' ) }
|
25
|
+
|
26
|
+
class RPM::Spec
|
27
|
+
attr_reader :name, :path
|
28
|
+
|
29
|
+
class << RPM::Spec
|
30
|
+
alias _spec_open open
|
31
|
+
def open( spec_path )
|
32
|
+
# need to be in directory of spec file for %{srcdir} to work properly
|
33
|
+
Dir.chdir File.dirname(spec_path) do
|
34
|
+
spec = _spec_open spec_path
|
35
|
+
spec.instance_eval { @path = spec_path }
|
36
|
+
|
37
|
+
if spec.packages.empty?
|
38
|
+
# some specs (i.e. kernel modules) need their sources installed before their specs will properly parse
|
39
|
+
raise "Spec file #{spec_path} has no packages" if spec.install_sources.zero?
|
40
|
+
spec = _spec_open spec_path
|
41
|
+
spec.instance_eval { @path = spec_path }
|
42
|
+
end
|
43
|
+
|
44
|
+
spec
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def name() @name ||= packages.first.name ; end
|
50
|
+
def version() @version ||= packages.first.version.v ; end
|
51
|
+
def release() @release ||= packages.first.version.r ; end
|
52
|
+
|
53
|
+
def install_sources
|
54
|
+
self.sources.select do |src|
|
55
|
+
src_path = File.join File.dirname(@path), src.filename
|
56
|
+
dest_path = File.join RPM::SourceDir, src.filename
|
57
|
+
next unless File.exists? src_path
|
58
|
+
|
59
|
+
file dest_path => src_path do |t|
|
60
|
+
puts "#{src_path} -> #{File.dirname dest_path}"
|
61
|
+
FileUtils.cp src_path, dest_path
|
62
|
+
end.invoke
|
63
|
+
true
|
64
|
+
end.size
|
65
|
+
end
|
66
|
+
|
67
|
+
def sh_build( flags )
|
68
|
+
rpm_opts = "--define='srcdir #{File.dirname @path}'"
|
69
|
+
cmd = "rpmbuild #{rpm_opts} -b" + (flags == RPM::BUILD__ALL_PACKAGE ? 'a' : 'b') + " #{@path}"
|
70
|
+
system(cmd) ? $?.exitstatus : -1
|
71
|
+
end
|
72
|
+
|
73
|
+
# RPM::Spec.build produces packages with the wrong OS ('gnu-linux' instead of 'linux'),
|
74
|
+
# plus other macro weirdness, so use rpmbuild.
|
75
|
+
alias build sh_build
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
class RPM::Package
|
80
|
+
def path
|
81
|
+
unless @path
|
82
|
+
@path = File.join RPM::RPMDir, sprintf( RPM::BuildNameFmt )
|
83
|
+
|
84
|
+
# kludge to fix incorrect package arch
|
85
|
+
@path.sub! 'i686', 'i386' if name != 'kmod-nslink'
|
86
|
+
end
|
87
|
+
@path
|
88
|
+
end
|
89
|
+
|
90
|
+
def has_sig?
|
91
|
+
sprintf( "%{siggpg}" ) != '(none)'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
module Rake
|
97
|
+
class RPMTask < Rake::TaskLib
|
98
|
+
|
99
|
+
attr_accessor :name, :spec_path, :build_srpms
|
100
|
+
|
101
|
+
def initialize( args, &blk )
|
102
|
+
@name, @prereqs = args.keys.first, args.values.first
|
103
|
+
@spec_path = @prereqs.find { |t| File.extname(t.to_s) == '.spec' }
|
104
|
+
@build_srpm = false
|
105
|
+
|
106
|
+
yield self if block_given?
|
107
|
+
|
108
|
+
raise "Unable to find spec file for \"#{@name}\"" unless @spec_path
|
109
|
+
define_tasks
|
110
|
+
end
|
111
|
+
|
112
|
+
def spec
|
113
|
+
unless @spec
|
114
|
+
@spec = RPM::Spec.open @spec_path
|
115
|
+
raise "Unable to parse #{spec_path}" unless @spec
|
116
|
+
end
|
117
|
+
@spec
|
118
|
+
end
|
119
|
+
|
120
|
+
def define_tasks
|
121
|
+
task @name => @prereqs do |t|
|
122
|
+
for rpm in spec.packages
|
123
|
+
spec.install_sources
|
124
|
+
|
125
|
+
file rpm.path => spec.path do |t|
|
126
|
+
rpm_names = spec.packages.map { |p| p.name }.join(', ')
|
127
|
+
puts '', '-' * 80,
|
128
|
+
"Building #{rpm_names} ...",
|
129
|
+
'-' * 80
|
130
|
+
|
131
|
+
flags = @build_srpms ? RPM::BUILD__ALL_PACKAGE : RPM::BUILD__BINARY_PACKAGE
|
132
|
+
raise "RPM Build failed" unless spec.build(flags).zero?
|
133
|
+
end.invoke
|
134
|
+
|
135
|
+
# CLOBBER.include pkg.path
|
136
|
+
end
|
137
|
+
# CLEAN.include File.join( RPM::BuildDir, "#{spec.name}-#{spec.version}" )
|
138
|
+
|
139
|
+
# CLOBBER.include @spec.sources.map { |s| File.join RPM::SRPMDir, s.filename }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/extensiontask'
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
|
6
|
+
MinSWIGVersion = %w/1 3 30/
|
7
|
+
|
8
|
+
# Create a build task that will generate a Ruby wrapper extension from
|
9
|
+
# SWIG interface definition(s). Requires SWIG[http://www.swig.org] version 1.3.30+.
|
10
|
+
#
|
11
|
+
# See ExtensionTask for more information.
|
12
|
+
#
|
13
|
+
# Example (from RDBXML):
|
14
|
+
# # dbxml.i -> dbxml_wrap.cc -> dbxml_wrap.o -> dbxml.so
|
15
|
+
# Rake::SWIGExtensionTask.new :dbxml do |t|
|
16
|
+
# # keep it all under ext/
|
17
|
+
# t.dir = 'ext'
|
18
|
+
# # dbxml.i includes dbxml_ruby.i so rebuild if it changes
|
19
|
+
# t.deps[:dbxml] << :dbxml_ruby
|
20
|
+
# # link in dbxml libraries
|
21
|
+
# t.link_libs += ['db', 'db_cxx', 'dbxml', 'xquery', 'xerces-c', 'pathan']
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# Author:: Steve Sloan (mailto:steve@finagle.org)
|
25
|
+
# Copyright:: Copyright (c) 2006 Steve Sloan
|
26
|
+
# License:: GPL
|
27
|
+
class SWIGExtensionTask < ExtensionTask
|
28
|
+
|
29
|
+
# An Array of interface filenames (Symbol or String) to build and link into
|
30
|
+
# the extension.
|
31
|
+
attr_accessor :ifaces
|
32
|
+
|
33
|
+
# A Hash of interface filenames and their dependencies, i.e. files which
|
34
|
+
# are not built or linked, but cause the corresponding interface to be
|
35
|
+
# rebuild if any of them change.
|
36
|
+
attr_accessor :deps
|
37
|
+
|
38
|
+
# Defaults:
|
39
|
+
# - lib_name: name.so
|
40
|
+
# - ifaces: name.i
|
41
|
+
# - deps: <none>
|
42
|
+
# - dir: .
|
43
|
+
# - link_libs: <none>
|
44
|
+
def set_defaults
|
45
|
+
super
|
46
|
+
@ifaces ||= [name.to_sym]
|
47
|
+
@deps ||= Hash.new []
|
48
|
+
@objs = []
|
49
|
+
end
|
50
|
+
|
51
|
+
def define_tasks
|
52
|
+
for iface in @ifaces
|
53
|
+
deps = @deps[iface]
|
54
|
+
iface = filepath(iface, :swigext)
|
55
|
+
src = iface.sub(/\.#{env[:swigext]}$/, env[:swig_cppext])
|
56
|
+
|
57
|
+
deps = [deps] unless deps.kind_of? Enumerable
|
58
|
+
if deps and deps.any?
|
59
|
+
file src => deps.collect { |dep| filepath(dep, :swigext) } << iface
|
60
|
+
end
|
61
|
+
CLEAN.include src
|
62
|
+
@objs << src.sub(/\.[^.]+$/, '.'+env[:objext])
|
63
|
+
end
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
# Add rule for generating C++ wrapper code (_wrap.cc) from SWIG interface definition (.i).
|
68
|
+
def define_rules
|
69
|
+
verify_swig_version
|
70
|
+
super
|
71
|
+
Rake::Task.create_rule(
|
72
|
+
/#{env[:swig_cppext]}$/ => [proc {|t| t.sub /#{env[:swig_cppext]}$/, '.'+env[:swigext] }]
|
73
|
+
) do |r|
|
74
|
+
sh_cmd :swig, :swig_flags, {'-I' => :swig_includedirs}, {'-I' => :includedirs},
|
75
|
+
'-o', r.name, r.sources
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
ExtensionTask.env = {
|
80
|
+
:swig => 'swig',
|
81
|
+
:swigext => 'i',
|
82
|
+
:swig_cppext => '_wrap.cc',
|
83
|
+
:swig_flags => ['-ruby', '-c++'],
|
84
|
+
:swig_includedirs => ['.']
|
85
|
+
}.update(ExtensionTask.env)
|
86
|
+
|
87
|
+
protected
|
88
|
+
|
89
|
+
# Raise an exception unless we have SWIG version 1.3 or later.
|
90
|
+
def verify_swig_version
|
91
|
+
@@swig_version ||= IO.popen "#{env[:swig]} -version 2>&1" do |swig|
|
92
|
+
banner = swig.readlines.reject { |l| l.strip.empty? }
|
93
|
+
banner = banner[0].match(/swig version ([^ ]+)/i)
|
94
|
+
banner and banner[1]
|
95
|
+
end
|
96
|
+
|
97
|
+
unless @@swig_version and
|
98
|
+
@@swig_version.split('.').zip( MinSWIGVersion ).all? { |a, b| a.to_i >= b }
|
99
|
+
raise "Need SWIG version #{MinSWIGVersion.join '.'} or later (have #{@@swig_version || 'none'})"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: rake-tasks
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2008-04-19 00:00:00 -07:00
|
8
|
+
summary: A collection of general-purpose Rake tasks
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Steve Sloan <steve@finagle.org>
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- MIT-LICENSE
|
34
|
+
- lib/rake/extensiontask.rb
|
35
|
+
- lib/rake/swigextensiontask.rb
|
36
|
+
- lib/rake/autotoolstask.rb
|
37
|
+
- lib/rake/rpmtask.rb
|
38
|
+
- Rakefile
|
39
|
+
test_files: []
|
40
|
+
|
41
|
+
rdoc_options:
|
42
|
+
- --line-numbers
|
43
|
+
- --inline-source
|
44
|
+
- --main
|
45
|
+
- README
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README
|
48
|
+
- MIT-LICENSE
|
49
|
+
executables: []
|
50
|
+
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
dependencies:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.7.0
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: ruby-rpm
|
67
|
+
version_requirement:
|
68
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.2.3
|
73
|
+
version:
|