-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
203 lines (168 loc) · 5.41 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#
# Copyright (c) 2012, NuoDB, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NuoDB, Inc. nor the names of its contributors may
# be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL NUODB, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rdoc/task'
require 'date'
require 'bundler'
require 'bundler/gem_tasks'
require File.expand_path(File.dirname(__FILE__)) + "/spec/support/config"
require File.expand_path(File.dirname(__FILE__)) + "/tasks/rspec"
Bundler::GemHelper.install_tasks
load 'nuodb.gemspec'
#############################################################################
#
# Helper functions
#
#############################################################################
def name
@name ||= Dir['*.gemspec'].first.split('.').first
end
def version
require File.expand_path('../lib/nuodb/version', __FILE__)
NuoDB::VERSION
end
def rubyforge_project
name
end
def date
Date.today.to_s
end
def gemspec_file
"#{name}.gemspec"
end
def gem_file
"#{name}-#{version}.gem"
end
def replace_header(head, header_name)
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'" }
end
def so_ext
case RUBY_PLATFORM
when /bsd/i, /darwin/i
# extras here...
@sh_extension = 'bundle'
when /linux/i
# extras here...
@sh_extension = 'so'
when /solaris|sunos/i
# extras here...
@sh_extension = 'so'
else
puts
puts "Unsupported platform '#{RUBY_PLATFORM}'. Supported platforms are BSD, DARWIN, and LINUX."
exit
end
end
#############################################################################
#
# Standard tasks
#
#############################################################################
CLEAN.include('doc/ri')
CLEAN.include('doc/site')
CLEAN.include('pkg')
CLEAN.include('ext/**/*{.o,.log,.so,.bundle}')
CLEAN.include('ext/**/Makefile')
CLEAN.include('lib/**/*{.so,.bundle}')
Dir['tasks/**/*.rb'].each { |file| load file }
file "lib/#{name}/#{name}.#{so_ext}" => Dir.glob("ext/#{name}/*{.rb,.cpp}") do
Dir.chdir("ext/#{name}") do
# this does essentially the same thing
# as what RubyGems does
ruby "extconf.rb"
sh "make"
end
cp "ext/#{name}/#{name}.#{so_ext}", "lib/#{name}"
end
namespace :nuodb do
task :install do
if ENV['NUODB_ROOT'].nil?
case RUBY_PLATFORM
when /linux/i
unless File.exists? '/etc/redhat-release'
puts %x(wget http://www.nuodb.com/latest/releases/nuodb-1.1.linux.x64.deb --output-document=/var/tmp/nuodb.deb)
puts %x(sudo dpkg -i /var/tmp/nuodb.deb)
end
else
puts "Unsupported platform '#{RUBY_PLATFORM}'. Supported platforms are BSD, DARWIN, SOLARIS, and LINUX."
end
end
end
task :remove do
if ENV['NUODB_ROOT'].nil?
case RUBY_PLATFORM
when /linux/i
unless File.exists? '/etc/redhat-release'
puts %x(sudo dpkg -r nuodb)
end
else
puts "Unsupported platform '#{RUBY_PLATFORM}'. Supported platforms are BSD, DARWIN, SOLARIS, and LINUX."
end
end
end
task :create_user do
#puts %x( echo "create user arunit password 'arunit';" | nuosql arunit@localhost --user dba --password baz )
end
task :start_server do
end
task :stop_server do
end
task :restart_server => [:stop_server, :start_server, :create_user]
end
task :spec => "lib/#{name}/#{name}.#{so_ext}"
task :default => :spec
#############################################################################
#
# Packaging tasks
#
#############################################################################
desc "Build #{gem_file} into the pkg directory"
task :build do
sh "mkdir -p pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end
task :install => :build do
sh %{gem install pkg/#{name}-#{version}.gem}
end
task :uninstall do
sh %{gem uninstall #{name} -x -v #{version}}
end
desc "Tags git with the latest gem version"
task :tag do
sh %{git tag v#{version}}
end
desc "Push gem packages"
task :push => :build do
sh "gem push pkg/#{name}*.gem"
end
desc "Release version #{version}"
task :release => [:tag, :push]