-
Notifications
You must be signed in to change notification settings - Fork 26
/
Rakefile
97 lines (83 loc) · 2.74 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
# -*- ruby -*-
#
# Copyright (C) 2009-2020 Sutou Kouhei <[email protected]>
# Copyright (C) 2017 Masafumi Yokoyama <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
require "bundler/gem_helper"
require "packnga"
require "yard"
base_dir = File.join(File.dirname(__FILE__))
groonga_ext_dir = File.join(base_dir, "ext", "groonga")
groonga_lib_dir = File.join(base_dir, "lib")
$LOAD_PATH.unshift(groonga_ext_dir)
$LOAD_PATH.unshift(groonga_lib_dir)
ENV["RUBYLIB"] = "#{groonga_lib_dir}:#{groonga_ext_dir}:#{ENV['RUBYLIB']}"
helper = Bundler::GemHelper.new(base_dir)
def helper.version_tag
version
end
helper.install
spec = helper.gemspec
Packnga::DocumentTask.new(spec) do |task|
task.original_language = "en"
task.translate_language = "ja"
end
ranguba_org_dir = Dir.glob("{..,../../www}/ranguba.org").first
Packnga::ReleaseTask.new(spec) do |task|
task.index_html_dir = ranguba_org_dir
end
file "Makefile" => ["extconf.rb", "ext/groonga/extconf.rb"] do
ruby("extconf.rb")
end
desc "Configure"
task :configure => "Makefile"
desc "Run test"
task :test => :configure do
ruby("test/run-test.rb")
end
namespace :test do
task :install => "install" do
rroonga_specs = Gem.source_index.find_name("rroonga")
target_rroonga_spec = rroonga_specs.find do |rroonga_spec|
rroonga_spec.version == helper.gemspec.version
end
installed_path = target_rroonga_spec.full_gem_path
ENV["NO_MAKE"] = "yes"
ruby("#{installed_path}/test/run-test.rb")
end
end
def update_version(new_version)
splitted_new_version = new_version.split(".")
type_order = ["MAJOR", "MINOR", "MICRO"]
File.open("ext/groonga/rb-grn.h", "rb+") do |rb_grn_h|
content = rb_grn_h.read
content.gsub!(/(RB_GRN_(MAJOR|MINOR|MICRO)_VERSION) \d+/) do
name = $1
type = $2
"#{name} #{splitted_new_version[type_order.index(type)]}"
end
rb_grn_h.rewind
rb_grn_h.write(content)
end
end
namespace :version do
desc "Update version"
task :update do |_, args|
new_version = ENV["NEW_VERSION"]
raise "NEW_VERSION must be specified" if new_version.nil?
update_version(new_version)
end
end
task :default => :test